How do I create random Enemy in Infinite Jump game?

Get help using Construct 2

Post » Fri Sep 11, 2015 11:51 am

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?
B
3
Posts: 9
Reputation: 199

Post » Fri Sep 11, 2015 12:17 pm

Example:

EVENT: WHEN YOU CREATE AN ETAGE OBJECT
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)
B
6
S
1
Posts: 50
Reputation: 502

Post » Fri Sep 11, 2015 12:32 pm

@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?
B
3
Posts: 9
Reputation: 199

Post » Fri Sep 11, 2015 1:06 pm

@gaelsev

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

Please help.
B
3
Posts: 9
Reputation: 199

Post » Fri Sep 11, 2015 6:23 pm

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
B
9
S
3
Posts: 113
Reputation: 1,009

Post » Sat Sep 12, 2015 7:52 am

@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.
B
3
Posts: 9
Reputation: 199

Post » Sat Sep 12, 2015 7:56 am

@Aher0 Here is my game looks like.

http:// postimg*org/image/wyl4aqetb/ >>>remove the space before postimg and replace the * with a dot.
B
3
Posts: 9
Reputation: 199

Post » Sat Sep 12, 2015 1:37 pm

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
and
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
B
9
S
3
Posts: 113
Reputation: 1,009

Post » Mon Sep 14, 2015 7:52 am

@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.
B
3
Posts: 9
Reputation: 199

Post » Mon Sep 14, 2015 4:23 pm

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
or
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
B
9
S
3
Posts: 113
Reputation: 1,009


Return to How do I....?

Who is online

Users browsing this forum: Jeremy450, Kyatric, norman74, VitorLeKunz and 25 guests