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

#1 2012-02-19 21:30:58

BlueNeonStreak
Scratcher
Registered: 2012-02-18
Posts: 7

How To Count Laps

Hello. My name is BlueNeonStreak, and I'm making a two-player racing game. I need a script that will accurately count how many laps each player completes. If you have any useful information, please post it in this thread. Thank you!

Offline

 

#2 2012-02-20 10:58:02

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: How To Count Laps

when gf clicked
set [laps v] to (0)
forever
    wait until <touching [#00FF00]?>
    wait until <not <touching [#00FF00]?>>
    change [laps v] by (1)
So when the sprite touches something Green then goes off of it, it will changes the variable "laps" by one. So you can have the finish line be green and it should work.

Offline

 

#3 2012-02-20 11:40:43

PencilFactory
Scratcher
Registered: 2011-11-11
Posts: 100+

Re: How To Count Laps

when gf clicked
forever if <touching color [#FAFF00] ?>
  change [laps v] by [1]
  wait until <not <touching color [#FAFF00] ?>>
end

Last edited by PencilFactory (2012-02-20 12:25:01)


PencilFactory is http://blocks.scratchr.org/API.php?user=PencilFactory&amp;action=onlineStatus&amp;type=text, see my computerhttp://mag.racked.eu/cimage/i9002/Achievement+get%21/Computer+crashed/mca.png

Offline

 

#4 2012-02-20 11:47:12

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: How To Count Laps

PencilFactory wrote:

[scratchblocks]
when gf clicked
forever if <touching color [#FAFF00]>
  change [laps v] by [1]
  wait until <not <touching color [#FAFF00]>>
end

You need a [ /scratchblocks] tag at the end.  I put a space in there, becuase last time I didn't, it really messed things up.  So put that tag at the end without the space, and it will show up properly.   smile

Offline

 

#5 2012-02-20 12:25:29

PencilFactory
Scratcher
Registered: 2011-11-11
Posts: 100+

Re: How To Count Laps

fixed


PencilFactory is http://blocks.scratchr.org/API.php?user=PencilFactory&amp;action=onlineStatus&amp;type=text, see my computerhttp://mag.racked.eu/cimage/i9002/Achievement+get%21/Computer+crashed/mca.png

Offline

 

Board footer