This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-01-27 11:01:54

NeilWest
Scratcher
Registered: 2010-01-06
Posts: 1000+

Help.

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

 

#2 2012-01-27 11:07:25

Servine
Scratcher
Registered: 2011-03-19
Posts: 1000+

Re: Help.

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.


http://bluetetrarpg.x10.mx/usercard/?name=Servine

Offline

 

#3 2012-01-27 11:22:28

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Help.

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.


Why

Offline

 

#4 2012-01-27 14:05:57

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Help.

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.  smile

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
end
Object 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) )
end
Then you can add you own AI code to change the x and y of the object to make it move around.  smile

Last edited by Magnie (2012-02-21 21:02:47)

Offline

 

#5 2012-02-16 07:44:38

iampie
Scratcher
Registered: 2011-10-30
Posts: 72

Re: Help.

Man, I have to try that.


Don't tell me I've lost my sanity...can't lose what you never had.  tongue http://tinyurl.com/7m32p3u

Offline

 

#6 2012-02-16 10:41:18

QuizMaster
Scratcher
Registered: 2010-06-01
Posts: 16

Re: Help.

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 ()
.
Using this method you should be able to create some sort of basic movement, while still making it work with scrolling.


Coming soon! A sig.

Offline

 

#7 2012-04-20 22:39:23

humhumgames
Scratcher
Registered: 2012-03-26
Posts: 1000+

Re: Help.

This helps me a lot!

Offline

 

Board footer