Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » help meh plz!
- potatobatman11
-
10 posts
help meh plz!
i am very new to scratch and i am trying to perfect the game of pong as a learning experience, i am stuck on a few things, i cant figure out how to get the paddle to work as a CPU so you wont have to play against your self and i cant figure out how to add a point limit so the game will stop if you reach so much points, if i can get some help that would be great, thank you
- potatobatman11
-
10 posts
help meh plz!
i think i have, i shared it so you check it out on my acount http://scratch.mit.edu.ezproxyberklee.flo.org/users/Davidtcg/
- drmcw
-
1000+ posts
help meh plz!
For a cpu paddle then something like;
In the bat scripts;
if y position of ball > y position of bat then
change y by someamount
else
change y by -someamount
The bigger someamount is the faster the cpu bat will move. You could also surround the above script with an if random 1 to 100 > 25 then in this case the cpu will move 75 % of the time so you can make the cpu play better of worse by changing those numbers too.
For points make a variable called points; You then need to initialise points to 0 when gf flag clicked and change points by 1 at some point too.
If you don't have a main game loop then put this in a forever block on the stage;
if points > limit
stop all scripts
In the bat scripts;
if y position of ball > y position of bat then
change y by someamount
else
change y by -someamount
The bigger someamount is the faster the cpu bat will move. You could also surround the above script with an if random 1 to 100 > 25 then in this case the cpu will move 75 % of the time so you can make the cpu play better of worse by changing those numbers too.
For points make a variable called points; You then need to initialise points to 0 when gf flag clicked and change points by 1 at some point too.
If you don't have a main game loop then put this in a forever block on the stage;
if points > limit
stop all scripts
Last edited by drmcw (July 11, 2013 06:52:11)
- potatobatman11
-
10 posts
help meh plz!
i am very new to scratch and i am trying to perfect the game of pong as a learning experience, i am stuck on a few things, i cant figure out how to get the paddle to work as a CPU so you wont have to play against your self and i cant figure out how to add a point limit so the game will stop if you reach so much points, if i can get some help that would be great, thank you
- RUBIXS
-
60 posts
help meh plz!
could you share the project so we could get an idea on how exactly to help

- potatobatman11
-
10 posts
help meh plz!
i have go check my account
Last edited by potatobatman11 (July 12, 2013 04:23:27)
- AgentRoop
-
100+ posts
help meh plz!
they probably mean the CPU's board. @drmcw what's a bat?
- drmcw
-
1000+ posts
help meh plz!
bat=paddle=board=racquet=thing that hit's the ball!they probably mean the CPU's board. @drmcw what's a bat?
- AgentRoop
-
100+ posts
help meh plz!
yes, that!bat=paddle=board=racquet=thing that hit's the ball!they probably mean the CPU's board. @drmcw what's a bat?

- Discussion Forums
- » Help with Scripts
-
» help meh plz!