farflamex's Forum Posts

  • I had something similar in a space game I wrote last year ( http://korelos.clay.io/ ). I need the ships to follow and attack the player ship, though not necessarily directly on top of it. It turned out to be very simple, what I did was have the ships constantly move towards a point near the player ship (adjusted slightly on both axes by a random number, e.g -100, -100 so they move to a point above/left of the ship). Then they just constantly move towards that point, by changing their angle to the correct angle (and you can use bullet behaviour to keep the car moving). Every 5 seconds or so, change the random point that they're heading for, to make them bob about to different positions (makes them look as if they're trying manouvers etc).

  • I had some problems with this at first, there are some more detailed answers on the forums. I always make sure that I get my own values whenever I need them, using layoutright(layer) - layoutleft(layer) or something similar.

  • Ah yes. Families are very useful in situations where you've already picked one object and then suddenly require all of the same objects in the subevents (you can't access them because you've already picked one). For example where you need to compare a value of one object against all of the same type of object. You can do it with variables but families are nicer usually.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm in a similar stage to you, so I may be able to help. I've been working away at communicating with a database for the past week, so I'm still in the early stages, but I'm able to retrieve info, update it etc, just the basics.

    From what I understand, you want to send a value from C2 to your database, to update it, presumably that value has already been collected from the database earlier?

    So (you probably know most of this), if you already have your value in C2 and want to send it to your database, you need to POST (not update), I think. Actually I'll be honest, I haven't even looked at the method section yet. All I do in your situation is, I send the information in the data, using the default method, then collect it in my PHP file and do the MYSql work in PHP. It's fairly simple, just takes a bit of getting used to (PHP isn't very complicated anyway, just taking me a while to get the hang of the syntax).

  • It's not so much that the information is stored in the 'first' object, as in the default object as created in the editor. Say you deleted the existing object when starting your game (as I often do), at this point you have zero of those objects. If you then create a new object of that type, it begins with the default properties as laid out in the editor. So yes, if you want certain properties upon setup, set them in the editor.

    Honestly, C2 is awesome but it does have a few peculiarities which you need to get your head around (they're usually very good and helpful, just not entirely clear until you understand the flow of the engine better). I personally delete most of my objects on start of layout and when I create my own, set my own values during run-time anyway, just to be clear in my own head.

    By the way, I'm not absolutely 100% sure that everything I just said is even right, so double-check the values during runtime with a text-box or something (or the debugger).

  • Yay, thank you. I'm sure I would have worked this out myself eventually, but this will save me loads of time. I've programmed in BASIC for 30 years, so transitioning to PHP is taking some time due to the different syntax. I'm getting there, but even the simplest things are taking me hours as I try to work out the new syntax. As I said, this will save me hours, so thank you

  • Any chance you could help me out with turning this code into a 2d array in PHP? I understand the basic PHP syntax for 2d arrays, i.e array[0] [0] instead of just array [0]. Just struggling to work out how this is chopping it up into the array in the first place. For example, right now I'm sending a 10 x 3 array asJSON.

    This was your code from above to turn it into a 1d array. How do I adjust it?

    foreach ($c2ArrayData as $z) {

    foreach ($z as $y) {

    foreach ($y as $x) {

    $output[count($output)] = $x;

    }

    }

    }

  • Have you looked at this tutorial? Should get you started.

    https://www.scirra.com/tutorials/346/on ... -php-mysql

  • How are the questions stored? If as some kind of object, just give them a variable which can be flagged once the question is asked, and reset it when you restart the layout.

  • You basically just need to check if ANY invader has reached a certain coordinate (left or right). At that point, ALL invaders make the downwards movement and change direction.

    Check the entire batch of aliens (with them all picked) to see if any has reached that point. If any were picked, you can set a variable and then in the next event, reverse the aliens if that variable is set. Alternatively, you can use a family to avoid the use of the variable, but it's a bit more complicated.

  • In the 'data' part right? As array.AsJSON as data? It's going through fine, now I just need to work out how to alter your PHP code from the other day to break it into a 2-dimensional array instead of a 1D one... find the PHP syntax tricky still xD

  • I have a few hundred variables that I want to post to my PHP file, to update into a database. My plan is to add these to an array, then post them array.AsJSON. Are there any limits on the amount of data you can send (either strict limits or suggested limits?). Is a few kilobytes of data too much?

  • So even in a sub-event they won't be accessible? I need to wait till the entire event finishes? This keeps tripping me up with C2.

  • But surely if the function creates the sprites, then immediately after returning from the function, sprite.count should show 10 (I made 10). Or is your point that the objects don't actually 'exist' at that point? If so, when do they begin to exist?

    I should say that I'm happy with having these as permanent objects anyway really, I can just keep them offscreen when they're not needed. But it'd still be interesting to know what happened.

  • Unfortunately not because it's huge and won't work without the access to my database. I've had no choice but to make the objects permanent from the start of the game instead of creating them just for a certain screen (and then deleting them later). It's working now, but I'm not sure what was causing that problem before.