I'm making a XY scrolling zombie game and I need to know, how do I make the zombies move in a scrolling game? Example, the goombas in the Mario series, they move according to the scrolling but also move by themselves- does anyone know how to do it?
Offline
NeilWest wrote:
I'm making a XY scrolling zombie game and I need to know, how do I make the zombies move in a scrolling game? Example, the goombas in the Mario series, they move according to the scrolling but also move by themselves- does anyone know how to do it?
That's AI. AI stands for Artificial Intelligence.
What you want to do is create a script for many scenarios. If you want zombies to be provoked and attack when the player comes near, you should create a script telling the zombie that if the player is in such a distance, it should attack it. If you just want a plain goomba like thing, it should be able to sense walls, tiles, blocks and of course, the PLAYER!
I'm sure if you searched the Scratch Website, you could find a few examples.
If you'd like to read up on it , then click here.
Offline
Servine wrote:
NeilWest wrote:
I'm making a XY scrolling zombie game and I need to know, how do I make the zombies move in a scrolling game? Example, the goombas in the Mario series, they move according to the scrolling but also move by themselves- does anyone know how to do it?
That's AI. AI stands for Artificial Intelligence.
What you want to do is create a script for many scenarios. If you want zombies to be provoked and attack when the player comes near, you should create a script telling the zombie that if the player is in such a distance, it should attack it. If you just want a plain goomba like thing, it should be able to sense walls, tiles, blocks and of course, the PLAYER!
I'm sure if you searched the Scratch Website, you could find a few examples.
If you'd like to read up on it , then click here.
I think he means how can he make it so the enemies can move in the scrolling game, rather than staying in the same spot.
Offline
Well, you do it the same way with the terrain. You need a variable x and variable y (not the blue ones) and then you have the sprite go to (x of sprite) - (x of player) and same with y. So basically, it goes to it's own position subtracted by the player's position.
So if the player's position is 50x 50y and the sprite/object's position is 25x 25y then it goes to -25x -25y. Then when you want it to move, just change the variables x and y to it's new position.
I'm sure you could do it with addition, but I learned using subtraction.
Player Script:
when gf clicked set [x v] to (0) set [y v] to (0) forever go to x:(0) y:(0) if <key [up arrow v] pressed?> change [y v] by (2) end if <key [down arrow v] pressed?> change [y v] by (-2) end if <key [right arrow v] pressed?> change [x v] by (2) end if <key [left arrow v] pressed?> change [x v] by (-2) end endObject Script:
when gf clicked set [object_x v] to (25) set [object_y v] to (25) forever go to ( (object_x) - (x) ) ( (object_y) - (y) ) endThen you can add you own AI code to change the x and y of the object to make it move around.
Last edited by Magnie (2012-02-21 21:02:47)
Offline
The way I have done it is to make it, when idle, go to the X or Y of the scrolling, and when it needs to move just use the
change x by ().
Offline