How do I create random Enemy in Infinite Jump game?

  • Hi, I am creating an Infinite Jump game, Everything is done except the Enemy now, I want them to spawn randomly in every few floor. Can anyone help please?

  • Example:


    ACTION: call the function enemy(floor(random(2)))

    EVENT: Function enemy : If parameter (compare parameter value) = 1

    ACTION: create enemy object and set position (etage.x,etage.y)

  • gaelsev I am sorry but I don't really understand, I am very new to this, if you can simplified it maybe i can understand or can I just upload the capx file to you and you edit it for me?

  • gaelsev

    http:// postimg*org/image/yfl98l2zv/ >> delete the space before postimg >> change the * with a dot

    Please help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • not sure what your game looks like.

    you can spawn an enemy to a position (or a random position) of your choosing (i use spawn-ers)

    are you doing it in a single straight line vertical or horizontal layout?

    if vertical you could just spawn the enemy at the top of the level, and let it fall, with add input left or right depending on where the player is. Then on contact, destroy it/ - score, or whatever you want

    if horizontal layout: you could have the enemy simulate a jump if the player Y > than the enemy y.

    this works if the player has the platform behavior, give the enemy the platform behavior but cancel the keyboard input on its behavior settings

    (don't forget to add a for each enemy (possibly is on screen) event so it affects a single enemy not all of them.

    also destroy the enemy when it fall behind the player by a set amount

  • Aher0 Hi, thanks for the reply, my game looks the cat jump infinite jump, I modified the my game from the template from construct. My game Player jump vertically into a platform, I already make the platform to appear at a specific height.

    Could you tell me the event and action I have to put in the game please so the Enemy spawn and fall into the platform at random, not in every platform. Thanks.

  • Aher0 Here is my game looks like.

    http:// postimg*org/image/wyl4aqetb/ >>>remove the space before postimg and replace the * with a dot.

  • i wrote so much, got logged out.... rrr... damn forum

    the easiest way would be

    every x seconds spawn enemy at x=random(5,50)

    give the enemy bullet behavior


    enemy on created set angle to 180 (so it flys down not right)

    as an addendum you may want to either rotate the enemy sprite so its not flying sideways or have a separate bullet behavior on a square thats opacity = 0 then pin the enemy to it, this can be complicated but the rts tank example gives good example on how to do this for multiple items

    don't forget to destroy the sprite when it leaves the layout to save on lag

  • Aher0 Hi, thanks for the reply, I already did what you suggested, it is working but when the Player stop jumping the Enemy keeps on coming in the next platform, because we use the x second spawn, do you have a solution for this? thanks.

  • add a branch condition to the every x seconds (press b when the event is highlighted), like player is jumping. this may throw the time off a little, but you could reduce the time till it seems right.

    so every 6 seconds + player is jumping = spawn enemy


    every x seconds +player is falling(inverted) = spawn enemy

    this would stop it from spawning while you are falling.. but without testing it, im not sure how frequently it would spawn

    ps(u might not need the branch condition, just another condition (press C) but its good if you want to test construct 2's mechanics)

    hope this helps, if not, write me and i'll make it, and test out a solution

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)