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

#1 2012-07-23 14:41:46

ZombieHappines
Scratcher
Registered: 2012-01-19
Posts: 100+

random moving of character

im making a game call zombie surivival im using x and y velocity but i need to know how to get the zombies to move randomly using x and y velocity


http://i47.tinypic.com/10wr3bq.jpg
http://i50.tinypic.com/2w7onpy.png

Offline

 

#2 2012-07-23 14:42:53

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: random moving of character

Try the wiki.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#3 2012-07-23 15:10:16

ZombieHappines
Scratcher
Registered: 2012-01-19
Posts: 100+

Re: random moving of character

Firedrake969 wrote:

Try the wiki.

i cant find anything about this


http://i47.tinypic.com/10wr3bq.jpg
http://i50.tinypic.com/2w7onpy.png

Offline

 

#4 2012-07-23 15:15:52

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: random moving of character

You could use a variable set to between 1 and 4, and from there, use that to tell if the zombie goes up, down, left, or right, and add in another random variable to set the amout of strides he takes in the random direction. To make it more realistic, add in random pauses of random lengths. If you want an example of a script that is close to this, then you can look at my Chalkboard Pac-Man project. Remember that the script I'm talking about is the ghost's script. If you like it, then just chop of the top part of the script in the repeat loop, edit it a bit for use in open spaces, and you should be fine!


http://i46.tinypic.com/35ismmc.png

Offline

 

#5 2012-07-23 15:55:43

ZombieHappines
Scratcher
Registered: 2012-01-19
Posts: 100+

Re: random moving of character

ErnieParke wrote:

You could use a variable set to between 1 and 4, and from there, use that to tell if the zombie goes up, down, left, or right, and add in another random variable to set the amout of strides he takes in the random direction. To make it more realistic, add in random pauses of random lengths. If you want an example of a script that is close to this, then you can look at my Chalkboard Pac-Man project. Remember that the script I'm talking about is the ghost's script. If you like it, then just chop of the top part of the script in the repeat loop, edit it a bit for use in open spaces, and you should be fine!

your scripts confuse me im not that good at scripting yet maybe you can look at my preview of my game and try to make a script for me http://scratch.mit.edu/projects/ZombieHappines/2652393


http://i47.tinypic.com/10wr3bq.jpg
http://i50.tinypic.com/2w7onpy.png

Offline

 

#6 2012-07-23 18:30:15

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: random moving of character

ZombieHappines wrote:

ErnieParke wrote:

You could use a variable set to between 1 and 4, and from there, use that to tell if the zombie goes up, down, left, or right, and add in another random variable to set the amout of strides he takes in the random direction. To make it more realistic, add in random pauses of random lengths. If you want an example of a script that is close to this, then you can look at my Chalkboard Pac-Man project. Remember that the script I'm talking about is the ghost's script. If you like it, then just chop of the top part of the script in the repeat loop, edit it a bit for use in open spaces, and you should be fine!

your scripts confuse me im not that good at scripting yet maybe you can look at my preview of my game and try to make a script for me http://scratch.mit.edu/projects/ZombieHappines/2652393

Sorry that they confuse you. I will look at your project and try adding some scripts to it. Then, I will post the project on Scratch for two days and I will let you know when I do, but it won't be today.


http://i46.tinypic.com/35ismmc.png

Offline

 

#7 2012-07-23 22:03:30

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

Re: random moving of character

Download my project 'HumHum Round-Up'. I used a random moving script (for the humhum sprites) on hard mode.  smile

Offline

 

#8 2012-07-23 22:23:38

ZombieHappines
Scratcher
Registered: 2012-01-19
Posts: 100+

Re: random moving of character

ErnieParke wrote:

ZombieHappines wrote:

ErnieParke wrote:

You could use a variable set to between 1 and 4, and from there, use that to tell if the zombie goes up, down, left, or right, and add in another random variable to set the amout of strides he takes in the random direction. To make it more realistic, add in random pauses of random lengths. If you want an example of a script that is close to this, then you can look at my Chalkboard Pac-Man project. Remember that the script I'm talking about is the ghost's script. If you like it, then just chop of the top part of the script in the repeat loop, edit it a bit for use in open spaces, and you should be fine!

your scripts confuse me im not that good at scripting yet maybe you can look at my preview of my game and try to make a script for me http://scratch.mit.edu/projects/ZombieHappines/2652393

Sorry that they confuse you. I will look at your project and try adding some scripts to it. Then, I will post the project on Scratch for two days and I will let you know when I do, but it won't be today.

oh no its not your fault they confuse me im just not that good yet and thanks for helping

Last edited by ZombieHappines (2012-07-23 22:43:39)


http://i47.tinypic.com/10wr3bq.jpg
http://i50.tinypic.com/2w7onpy.png

Offline

 

#9 2012-07-24 02:35:14

hunter6690
Scratcher
Registered: 2012-05-12
Posts: 36

Re: random moving of character

ZombieHappines wrote:

im making a game call zombie surivival im using x and y velocity but i need to know how to get the zombies to move randomly using x and y velocity

The Script Is...

when gf clicked
forever
  move [(pick random [1] to [10])] steps
   wait [1] secs 
  point in direction [(pick random [-90] to [90]
Also add another point in direction pickrandom [0] to [180]

Last edited by hunter6690 (2012-07-24 02:36:13)

Offline

 

#10 2012-07-24 09:55:31

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: random moving of character

hunter6690 wrote:

ZombieHappines wrote:

im making a game call zombie surivival im using x and y velocity but i need to know how to get the zombies to move randomly using x and y velocity

The Script Is...

when gf clicked
forever
  move [(pick random [1] to [10])] steps
   wait [1] secs 
  point in direction [(pick random [-90] to [90]
Also add another point in direction pickrandom [0] to [180]

I think that he wants a script that has two variables describing the sprites motion; x velocity and y velocity. I don't see that in your script. Also, when turning, you should pick between -90 and 180, not 0 and 180. This will then give it a fuller range of motion.

Last edited by ErnieParke (2012-07-24 09:56:02)


http://i46.tinypic.com/35ismmc.png

Offline

 

#11 2012-07-24 11:16:14

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: random moving of character

ZombieHappines, I have a question that I would like answered before I start working on the AI.

1). Do you want the zombies to move:
  a). Only left, right, up, down, and diagonally.
  b). Any Direction.

I will still work on the AI, but this info will be greatly appreciated.


http://i46.tinypic.com/35ismmc.png

Offline

 

#12 2012-07-24 11:30:24

JH1010
Scratcher
Registered: 2012-05-31
Posts: 1000+

Re: random moving of character

Try this:

when gf clicked
forever
glide <pick random (1) to (5)> secs to x: <pick random (-240) to (240)> y: <pick random (-180) to (180)>
end

Offline

 

#13 2012-07-24 11:36:14

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: random moving of character

JH1010 wrote:

Try this:

when gf clicked
forever
glide <pick random (1) to (5)> secs to x: <pick random (-240) to (240)> y: <pick random (-180) to (180)>
end

He needs to be able to have the variables x velocity and y velocity describing the zombie's motion. Also, in his project notes, he said that the zombies will slowly move towards the charcter, and I don't see that in your script.


http://i46.tinypic.com/35ismmc.png

Offline

 

#14 2012-07-24 12:08:59

ZombieHappines
Scratcher
Registered: 2012-01-19
Posts: 100+

Re: random moving of character

ErnieParke wrote:

ZombieHappines, I have a question that I would like answered before I start working on the AI.

1). Do you want the zombies to move:
  a). Only left, right, up, down, and diagonally.
  b). Any Direction.

I will still work on the AI, but this info will be greatly appreciated.

b any direction and thanks for helping its really appreciated


http://i47.tinypic.com/10wr3bq.jpg
http://i50.tinypic.com/2w7onpy.png

Offline

 

#15 2012-07-24 13:34:37

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: random moving of character

I'm am done!

Here's a link to the project:
http://scratch.mit.edu/projects/ErnieParke/2693911

About b, well the zombies will move left/right/up/down when they aren't chasing you, but they will move towards you when they are. It's extremely difficult to make a script with x and y velocities and have the zombie move in any random direction (ex. 57 degrrees, -13 degrees, ect..) because then you have to go into trigonometry, and I don't want to do that. The zombies still move around randomly, but only at 90 degree intervals. Right now, there are 3 zombies.

Here is what I've changed:

1). 3 zombies to chase/kill you.
2). New hamburger image.
3). Hamburgers give 2 hearts now.
4). Better movement.
5). Sword added to kill zombies with.
6). Various bug fixes.
7). Move with the arrow keys or WASD.

Last edited by ErnieParke (2012-07-24 13:58:15)


http://i46.tinypic.com/35ismmc.png

Offline

 

#16 2012-07-24 13:43:17

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: random moving of character

I just added the ability to lose/win.

To win, kill all of the zombies. You'll find the script for this in Sprite3.
To lose, die. You'll also find the script for this in Sprite 3.


http://i46.tinypic.com/35ismmc.png

Offline

 

#17 2012-07-24 13:47:34

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: random moving of character

Just quickly updated it to fix a couple of bugs.


http://i46.tinypic.com/35ismmc.png

Offline

 

#18 2012-07-24 15:03:53

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: random moving of character

I don't know if you've seen my posts, so please say if you have/haven't. Thanks!


http://i46.tinypic.com/35ismmc.png

Offline

 

#19 2012-07-24 15:26:27

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: random moving of character

Just updated it with some bug fixes.


http://i46.tinypic.com/35ismmc.png

Offline

 

#20 2012-07-24 21:02:50

ZombieHappines
Scratcher
Registered: 2012-01-19
Posts: 100+

Re: random moving of character

ErnieParke wrote:

Just updated it with some bug fixes.

i really appreciate the help youve done for me thanks


http://i47.tinypic.com/10wr3bq.jpg
http://i50.tinypic.com/2w7onpy.png

Offline

 

#21 2012-07-24 21:16:38

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: random moving of character

ZombieHappines wrote:

ErnieParke wrote:

Just updated it with some bug fixes.

i really appreciate the help youve done for me thanks

No, thank you. I really like to help people when I don't have my hands tied up.


http://i46.tinypic.com/35ismmc.png

Offline

 

#22 2012-07-24 21:30:55

ZombieHappines
Scratcher
Registered: 2012-01-19
Posts: 100+

Re: random moving of character

ErnieParke wrote:

ZombieHappines wrote:

ErnieParke wrote:

Just updated it with some bug fixes.

i really appreciate the help youve done for me thanks

No, thank you. I really like to help people when I don't have my hands tied up.

hey Ernie i moved some stuff around changed zombies health a little and i made a new lose broadcast thing because the one you made only made sprite three disappear and not the lose sign pop up and it doesnt work and the health glitches out every once in a while can you help me again


http://i47.tinypic.com/10wr3bq.jpg
http://i50.tinypic.com/2w7onpy.png

Offline

 

#23 2012-07-24 21:34:47

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: random moving of character

I'll look into it and help. So, let me guess, you've updated your online version and that is what is having the problems. Okay. It's late right now (9:30 pm), so I won't update the project today.

Last edited by ErnieParke (2012-07-24 21:36:25)


http://i46.tinypic.com/35ismmc.png

Offline

 

#24 2012-07-25 11:20:02

ZombieHappines
Scratcher
Registered: 2012-01-19
Posts: 100+

Re: random moving of character

ErnieParke wrote:

I'll look into it and help. So, let me guess, you've updated your online version and that is what is having the problems. Okay. It's late right now (9:30 pm), so I won't update the project today.

Hey Ernie I Have a proposition for you would you like to join Destructive Pixels Inc As Head Programmer


http://i47.tinypic.com/10wr3bq.jpg
http://i50.tinypic.com/2w7onpy.png

Offline

 

#25 2012-07-25 13:27:37

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: random moving of character

I'll think about it. Anyway, I've updated the project to version 0.1.4.

Here's a link:
http://scratch.mit.edu/projects/ErnieParke/2695575

Here is what I've added so far:

1). 1 more zombie added.
2). Half hearts added.
3). Cheeseburgers now give 1.5 hearts.
4). Zombies/weapons/food now don't spawn on top of you.
5). A new zombie appears after two seconds of a zombie's death.
6). Performance optimization.
7). Numerous bug fixes.


http://i46.tinypic.com/35ismmc.png

Offline

 

Board footer