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

#1 2010-06-22 08:31:54

tooteaching
Scratcher
Registered: 2009-08-15
Posts: 5

Two Player Basketball-Score Help

I'm teaching Scratch to kids this summer at a Boys and Girls Club. I have two kids who have a basketball game with two players. I want to use one basket for two different scores (i.e. if one makes a basket he gets a point, if the other makes a basket he gets a point. I have it set up so that if one of the players touches the ball it throws the ball at an angle (not a jump shot). If the ball hits a dot on the basket, it increases the score. How do I do two different scores with two different players for one basket and not have the opposite players basket affect the opposite players score?

Offline

 

#2 2010-06-22 08:39:06

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: Two Player Basketball-Score Help

Make a variable that is set by whichever player last touched the ball. Then use an if/else when changing score based on that variable.


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#3 2010-06-22 08:42:00

tooteaching
Scratcher
Registered: 2009-08-15
Posts: 5

Re: Two Player Basketball-Score Help

How do I do that?

Offline

 

#4 2010-06-22 08:57:41

Buggy132KX
New Scratcher
Registered: 2010-06-21
Posts: 29

Re: Two Player Basketball-Score Help

For the Variable go into variables and Make Variable
Call It Player or something.
Then put a script on the ball saying something like Forever If Touching Player 1 Set Player (Your Variable) to 1.
Else If Touching Player 2 Set Player (Variable) to 2.

It'll be hard to say what to put on the basket sprite because i don't know how your scripting it.
Personally I'd use a broadcast.

So

When I recieve 'Score'
If Player (Variable) = 1
Change Score 1 by -number-
Else
Change Score 2 by -number-

That should do it.

I would put it into blocks but I have to rush this as i'm also working on my project XD

Good Luck!

~Buggy

Offline

 

#5 2010-06-23 19:50:18

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: Two Player Basketball-Score Help

nice Buggy  big_smile


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

Board footer