Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
How many times has it passed?
Old
Kirbya
Guest
 
Status:
Posts: n/a
Default How many times has it passed? - 10-23-2006, 10:46 AM

Im creating a racing game for my final project right now and I need to know how to check if the racecar has passed the flag twice, then when it has passed it for the third time so i can change the flag's accordingly.

Also if you could show me how to make it so the cars can't move until the text "GO!" shows up that would help greatly.
Attached Files
File Type: a2w racecar.a2w (524.6 KB, 366 views)

Last edited by Kirbya; 10-23-2006 at 10:59 AM.
   
Reply With Quote
First thoughts only
Old
DrJim
Guest
 
Status:
Posts: n/a
Unhappy First thoughts only - 10-23-2006, 08:16 PM

First of all - nice start. It looks good and the cars control well.

Re your two questions. First, you need a "lap counter" variable for each car and a monitor loop to increment the counter each time the car passes within a threshold of the flag.

For the second, you are going to have to change the while statements controlling the car from world events, like they are now to conditional loops inside a general "While race is on" loop in one of the top level methods. The condition "race is on" goes true when the GO shows up and stay true until one car passes the flag three times. When it's false, the key controls don't work and thus the cars can't be move. (Right now, there is nothing to stop them from moving any time the world is running.)

I know this is pretty sketchy but didn't have time to work out the details. Hope it helps at least a bit and good luck.
   
Reply With Quote
Old
Kirbya
Guest
 
Status:
Posts: n/a
Default 10-24-2006, 10:43 AM

How would I make a monitor loop?


EDIT: Nevermind, I figured it out, thanks
Now onto the second part...

Last edited by Kirbya; 10-24-2006 at 11:04 AM.
   
Reply With Quote
Old
Kirbya
Guest
 
Status:
Posts: n/a
Default 10-24-2006, 11:04 AM

If you could explain your answer to the second answer a little more I would appreciate it, I can't figure out what you mean.
   
Reply With Quote
Run this first (only W works) to see if it's what you want.
Old
DrJim
Guest
 
Status:
Posts: n/a
Question Run this first (only W works) to see if it's what you want. - 10-24-2006, 12:36 PM

See attached - ugly code (mine, not yours), large file, only done for the "W" key and not really what I described ("Aside from that, Mrs. Lincoln, how did you like the play?") - but it may give you the general idea.

The event call will always happen when the world is running so you have to modify the "forward" command - in this case it only does something after GO was displayed and before the loop counter (you would replace that with the lap counter) reaches 4.
Attached Files
File Type: a2w QuickCarTest.a2w (522.8 KB, 385 views)
   
Reply With Quote
Old
Kirbya
Guest
 
Status:
Posts: n/a
Default 10-25-2006, 03:43 PM

I get what your saying now, I have it working great.

Last edited by Kirbya; 10-26-2006 at 10:42 AM.
   
Reply With Quote
Old
DrJim
Guest
 
Status:
Posts: n/a
Default 10-25-2006, 08:22 PM

Glad you got it running - maybe you could post it in the share worlds section of this forum.
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2020, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.