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

#1 2012-07-05 09:23:55

crazy_red_elf
New Scratcher
Registered: 2012-07-05
Posts: 1

Help with making a counter

hi I was just wondering how to make a lap counter for a car game
can anyone help me with this?

Offline

 

#2 2012-07-05 14:28:34

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Help with making a counter

The above post has been moved from http://scratch.mit.edu/forums/viewtopic.php?id=100761 to its own thread.


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#3 2012-07-05 20:14:17

sonicgames20
Scratcher
Registered: 2012-06-13
Posts: 100+

Re: Help with making a counter

Make a blue line to mark each lap. Make a variable that says LAP. Use the following script:

when gf clicked
forever
 if <touching color[#0000FF]>
  change [LAPS v] by (1)
 end
end


if there is no I in TEAM and there  is no U in TEAM then who's on the team?
I am-http://blocks.scratchr.org/API.php?user=sonicgames20&amp;action=onlineStatus&amp;type=square-green=online grey=offline

Offline

 

#4 2012-07-06 03:02:48

JH1010
Scratcher
Registered: 2012-05-31
Posts: 1000+

Re: Help with making a counter

sonicgames20 wrote:

Make a blue line to mark each lap. Make a variable that says LAP. Use the following script:

when gf clicked
forever
 if <touching color[#0000FF]>
  change [LAPS v] by (1)
 end
end

This has one flaw. You can just go around in circles and get loads of laps. To prevent this you need to make it impossible to reverse and/or have a colour surrounding the track it sends you back to just after the lap line.

Offline

 

#5 2012-07-06 09:14:34

benjamin2
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: Help with making a counter

JH1010 wrote:

sonicgames20 wrote:

Make a blue line to mark each lap. Make a variable that says LAP. Use the following script:

when gf clicked
forever
 if <touching color[#0000FF]>
  change [LAPS v] by (1)
 end
end

This has one flaw. You can just go around in circles and get loads of laps. To prevent this you need to make it impossible to reverse and/or have a colour surrounding the track it sends you back to just after the lap line.

Or put a few lines in the lap that match the background so the player can't see them, and to get a lap you have to pass over all of them in order.


http://i.imgur.com/gp6tZ.gif

Offline

 

#6 2012-07-06 10:01:53

Smozzick
Scratcher
Registered: 2011-10-23
Posts: 100+

Re: Help with making a counter

benjamin2 wrote:

Or put a few lines in the lap that match the background so the player can't see them, and to get a lap you have to pass over all of them in order.

This works but you don't need to worry about people seeing them; just set the ghost of the lap lines to 99.


http://i50.tinypic.com/ded8m.png

Offline

 

Board footer