farflamex's Forum Posts

  • As for 'is it possible', yes it is. I haven't found anything impossible in C2 that can be done in other games (except 3d stuff). How to achieve it specifically, would depend on exactly which piece of their AI you're trying to achieve, but yes, it'll be doable.

  • Do you mean stepping through a loop? E.G For X = 0 to 10 step 2? If so, as far as I know, you need to do it manually.

  • Ah yes, the problem as you say is that when the mouse leaves the window, it's no longer tracked at all in C2 (if you track Mouse.X and Mouse.Y for example, they just 'stick' if you leave the window). There might be a solution to this, but I'd consider a different control method as it's too confusing. Or at least have the mouse cursor really prominent so it's very clear to the player that it's being used as the focal point. All I can think of, sorry.

  • Yay, cool

  • It seems to be the examples only. If I just load up a new project and add my own tables, they seem to work fine (actually they do in the examples too, but just give an error when loading). Here's the bug it reported.

    ---------------------------

    Construct 2 Check failure

    ---------------------------

    Check failure! This is probably a bug:

    Encountered second <i> before first was closed with </i>

    Condition: italic_flag == false

    File: Controls\EventString.cpp

    Line: 213

    Function: void __cdecl EventString::FragmentString(void)

    Build: release 174 (64-bit) checked

    Component: Construct 2 IDE

    (Last Win32 error: 0)

    You are using a 'checked' release of Construct 2, intended for testing, which causes certain errors to be reported this way. Hit Ctrl+C to copy this messagebox - it's useful information for the developers, so please include it with any bug reports! Click 'Abort' to quit (unsaved data will be lost!),'Retry' to turn off messages for this session and continue, or 'Ignore' to continue normally.

    ---------------------------

    Abort Retry Ignore

    ---------------------------

  • It's not a bug, when I was confused about it, Ashley set me straight. Now I just use the layout values to find the width and height, since it's always correct and up to date (perhaps not if you zoom, I don't know).

  • Does the distance to the mouse cursor matter, or just the angle? If it's just the angle, it shouldn't matter should it? The angle to the mouse will still be the same, if it just moves around the edges of the screen?

  • Looks excellent, you've done lots of work on that, seems to be very comprehensive too with every option I can think of. It did report a couple of errors when I loaded it up, but then went ahead and worked fine anyway, maybe something to do with newer versions of C2 or something?

  • Cool, this looks really interesting and seems to cut out much of the work. It's not really the work that bothers me, just that I don't like messy code, and this looks nice and neat. Especially since the code looks similar on both sides, which will really help with readability.

    Going to give it a try. Only downside I can see is that I'll need the add-on pretty much forever and I suppose that there's a danger of losing access to it in the future (mind you, I could store a copy on my server with all my data or something, just in case).

  • Yeah that's true, thanks for the explanation. If JSON is better, I'd rather just stick with it (I've grown very patient with old age) until I'm comfortable with it. All new languages/concepts are difficult at first anyway.

    Certainly I'd never need a pipe in any normal circumstance, so I don't see that being a problem.

    Wow, I've been using C2 for years and for some reason, I'd never noticed that you can mix types in an array, so that does help make JSON more appealing. I was thinking I'd have to send the strings and integers in 2 seperate arrays, but apparently not.

    This is almost tempting me to KEEP everything in an array during my C2 processing, but I absolutely hate arrays nowadays (used to swear by them until I became comfortable with objects). My old program (written in 1991) is all arrays and it's very difficult trying to work out what's happening when you read Rating(2,21) etc, it just makes no sense. So I always parse everything into an object when receiving in C2, then load it into an array to send it back to PHP, then split it again using your code and save it. Does sound long-winded when I could just keep it all in the array all of the time. But arrays are so hard to read and bug-ridden, I don't like that idea at all.

    Plus, when returning the data to PHP, I don't intend to send all of the data anyway, only selected bits (i.e the bits that have changed). So I'm effectively creating a small temporary custom-array, just to post it as my JSON string. That seems sensible instead of constantly sending the whole object back and forth when only a single value might have changed, though it also means more PHP scripts. Hmmm, lots to think about, but for now I'll stick with the JSON code until I understand it better (actually I understand the JSON part now, just the PHP is still confusing me).

  • Ok that's cool and I thought perhaps that was the reason. As far as sharing it, never going to happen as this game is my business and is run/operated entirely by me. I suppose it's feasible that some time in the future I may be dead and somebody else may wish to run the game for me, but even then, it's not like my code is that hard to understand (I do comment for example, only for my own sake though).

    In terms of ease and bugs, I personally find my method better since I need to move my objects into an array first anyway. And for me, it's easier to understand, although at some point, obviously I'll start to understand the PHP code better, but right now it's all completely unreadable to me and I'm relying on help to code even small code such as the bits above. Though of course, I need to use PHP so the more code I play around with, the better.

    Plus surely you do need to parse the JSON array at the PHP end? That's what the code above is for that Troublesum has written out for me. Is there a more straightforward way to get the C2 array into a PHP array?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I know what you mean, but I would say give C2 a try. It's really incredibly powerful and amazingly easy to use... apart from a few things which occasionally break my brain, but that's true in any language. It also has a good community and constant updates, although that's true of Unity of course. The problem, like anything, would be the learning curve. It did take me some time to get my head around C2 but I'm glad I did, and while it's not perfect, it's closer to perfect than anything else I've seen.

    I suppose much depends on what you're trying to do too. C2 isn't for 3D games so if you're planning any 3D, I assume Unity is the way to go.

  • troublesum, just wondering if you know if there's a good reason not to create my own strings and parse them in PHP myself? For example, when I started this last week, I simply made a string of my data with a pipe '|' separator. In my case, I'm making Soccer players for my game and they're stored as objects, with name/skills etc. So my string would look something like 'John Smith|300|400|100|200' etc. So I'd send that to the PHP file as data, then just 'explode' it in PHP and update my tables with the resulting array.

    Now the thing is, not only did I find that very easy to understand, but it's also easier at the C2 side, because the players are already stored as objects. So to create the string I could do something like 'Str = Str & Player.Name&'|'&Player.Age&'|' ' etc. Nice and easy. What I have to do now is, put the values into the array first, then send the array.AsJSON.

    Also on the PHP side of things, I found it very easy to just parse the string with explode, then put the separate elements into my table.

    When I got stuck and explained this on some PHP boards, they basically told me it wasn't a good method and I'm better of using JSON, but never really explained why. I'm not sure if they're worried that I'm 'reinventing the wheel', because if that's all it is, frankly I'd rather use my own wheel that I understand... and it's actually easier anyway. I suppose there's also the problem that maybe I'm adding extra bytes to my string with the separators, but the JSON string looks huge anyway and has loads of extra characters. Or is it a security issue? If it's security, I'd rather go for the most secure method. But if they're suggesting that JSON is the easier method, maybe it is for C++ programmers etc, but for C2 it doesn't seem to be, and building my own strings is something I'm comfortable with.

    Any ideas? Is my method ok in your eyes?

  • Not sure I have any links, but where are you stuck? If you use layoutright(mylayer) - layoutleft(mylayer) you'll get the correct width of your window, unless you've done some other changes (not sure if it works if that layout is scaled/zoomed etc).

  • Does your table have an ID column? If it does, then when you retrieve the data, retrieve the ID too and send it to C2, and store it with your object/array/whatever. Then when you send it back to be updated, send back the ID too, so that you know which row you're updating.

    The MySql for updating goes something along the lines of 'UPDATE MyTable SET Age = Value WHERE ID = MyID'.