I am trying to create a 'Pong' type of game , simply where the bat moves horizontally and you try and make the bouncing ball hit it , if you miss the game is over.
Their are plenty of these programs on the site but i am stuck
How do you get the ball to move randomly all over the screen?
Last edited by ayrshirelad123 (2007-11-06 05:10:33)
Offline
There are many ways to let a sprite move randomly across the screen. For a 'Pong' type of game you probably wouldn't want your ball to move completely at random, but rather to start off in a random direction and bounce off the edges in a predictable way. So you could start by setting the ball-sprite's direction to a random number from 1 to 360. Then you could use a forever-loop let the ball move a certain amount of steps and bounce off the edge.
This will pretty much get you started. Now you have to think about a way to find out if the ball hits the bat or the bottom.... (hint: have a look at some of the pong projects around, I'm sure these will give you some inspiration).
Hope that helps
Jens
P.S. I moved this topic to the All About Scratch section http://scratch.mit.edu/forums/viewtopic.php?id=2094
Offline
download the scrips of some1 elses...
Offline
here http://scratch.mit.edu/projects/yambanshee/49606 download that some where in the balls scripts it has that
Last edited by yambanshee (2007-11-06 13:42:30)
Offline