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

#1 2012-12-15 11:46:01

caspar92
New Scratcher
Registered: 2012-12-15
Posts: 1

Help with football game?

I'm trying to make a football/soccer- type game where the net moves from side to side at the top and you have to try to get the ball in the net as many times as you can in 1 minute.

So far all i can figure out is how to get the ball to follow the mouse.. How do I make it so when you click or press the space button the ball will go up towards the net?
And how to make the net move?

Offline

 

#2 2012-12-15 11:51:45

BetaSmozzick
Scratcher
Registered: 2012-02-25
Posts: 51

Re: Help with football game?

For the net something like this maybe? :

when gf clicked
forever if <(shooting) = [no]>
repeat until <(x position) > [120]> 
change x by [5]
end
repeat until <(x position) < [-120]> 
change x by [-5]
end

Though maybe with waits or a lower x change to make it a bit slower.

For shooting:

when gf clicked
set [shooting v] to [no]
set [score v] to [0]
forever
set x to <mouse x>
if <mouse down?>
set [shooting v] to [yes]
wait until <not <mouse down?>>
repeat until <<<y position > > <[y position v] of [net v]>> or <touching [net v]?>>
change y by [1]
end
if <touching [net v]?>
change [score v] by [1]
end
end
set [shooting v] to [no]
end

Note: These two pieces of code go together.

Last edited by BetaSmozzick (2012-12-15 15:34:56)

Offline

 

#3 2012-12-15 13:50:18

letmethink
Scratcher
Registered: 2010-05-09
Posts: 100+

Re: Help with football game?

For to make the ball to go towards the net you could have something like:

when gf clicked
forever
repeat until <key [space v] pressed?>//Why won't it go blue!
  go to [mouse pointer v]
end
point towards [Goal v]
repeat until <<touching [Goal v]?>or<touching [edge v]?>>// ah it has a question mark at the end
  move (10) steps
end 
if <touching [Goal v]?>
  change [Score v] by (1)
end
end

Last edited by letmethink (2012-12-15 13:54:48)


Clicky Clicky!!!               I am writing a book...             Look here

Offline

 

Board footer