Discuss Scratch

MrEsch
Scratcher
13 posts

Collecting another sprite: Is there an easy way?

Hello

I have a lot of students interested in making football games. They want to do the following and I was wondering whether anyone would be interested in making a simple game which shows the following concepts? The students have only been programming in Scratch for a couple of months, so I want them to be able to develop this is in a simple way, but will allow them to think of ways in making it better.

  1. Collecting the football (or soccer ball!) and dribbling with it
    Pressing space bar to shoot


Any help or advice would be gratefully received!

Last edited by MrEsch (June 15, 2013 18:29:22)

drmcw
Scratcher
1000+ posts

Collecting another sprite: Is there an easy way?

Try this.

10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
MrEsch
Scratcher
13 posts

Collecting another sprite: Is there an easy way?

Thank you so much drmcw. I am going to have some very happy students next week!

Would you mind explaining why “broadcast and wait” and “stop all scripts in sprite” are needed?

drmcw
Scratcher
1000+ posts

Collecting another sprite: Is there an easy way?

Both broadcast and wait and the stop all scripts are playing safe really. The main player loop, as you can see, is a forever loop and checking for various key presses and moving the player accordingly. I put in the broadcast and wait so that the ball would do all its movement which is relative to the player and effectively block the player loop from doing anything to spoil things. The shoot broadcast is a repeat loop to send the ball bouncing around the screen. What may happen is that the ball bounces and hits the player; if this happens then because dribbling happens when the sprites touch we need to stop the shoot and go back to dribbling which the stop all scripts in sprite should do. You may also notice the initial move for the shoot this is to prevent the sprites from touching so the shoot has a chance to work.
I hope they have fun and I look forward to Scratch FIFA 2013 !

10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
MrEsch
Scratcher
13 posts

Collecting another sprite: Is there an easy way?

Thank you for this. I have made a copy of the game and put some comments in for the students to understand. I will post their finished games for you to look at once they have finished!
Lawnmowersarefast
Scratcher
9 posts

Collecting another sprite: Is there an easy way?

when green flag clicked
forever
if <<touching [ sprite1 v] ?>> then
set [dribbling] to [yes]
else
set [dribbling] to [no]

when green flag clicked
forever
if <(dribbling)=[yes]> then
go to [sprite1 v]
when green flag clicked
forever
if <(dribbling)=[yes]> then
change y by (bounce height)
change y by <(bounce height)-<(bounce height)*[2]>
when [space v] key pressed
if <touching [sprite1 v]> then
change x by (kick/throw amount)



this should work

Powered by DjangoBB