Alice Community  

Go Back   Alice Community > Alice 2 > Works-In-Progress

Reply
 
Thread Tools Display Modes
Stop my car
Old
pedrodantas
Junior Member
 
Status: Offline
Posts: 2
Join Date: Oct 2011
Default Stop my car - 11-30-2011, 04:09 PM

Well i am doing this game that the user control a car that moves at a constant speed. I put the car to move when the user presses enter and i put the duration infinite so it never stops moving. The problem is: how do i make it stop when you reach the finish line. Ive tried putting a distance to function in a while something is true but it doesnt work... Help!
   
Reply With Quote
Old
davidghemer
Member
 
Status: Offline
Posts: 38
Join Date: Nov 2011
Default 11-30-2011, 04:43 PM

Attached is a partial solution to this problem.
I've used a while something is true event to drive the car until it passes a fire hydrant.
You can also use the spacebar to start/stop the car.
A boolean valued variable, stopped, is used to indicate whether or not the car is stopped - this is toggled when you press the spacebar and set to true when you pass the fire hydrant.
Attached Files
File Type: a2w cardriveuntil.a2w (229.7 KB, 17 views)


For video tutorials on programming in Alice 2.2 check out my YouTube channel

http://www.youtube.com/user/drdave785

Also check out my Programming in Alice blog at

http://programminginalice.com
   
Reply With Quote
Old
pedrodantas
Junior Member
 
Status: Offline
Posts: 2
Join Date: Oct 2011
Default 11-30-2011, 07:36 PM

I got it! Thank you very very much... but now I have another problem. I want so that the car can not go on the grass... take a look at my code

(remember it is just a simple game for 7 year old kids so it doesnt need to be all sphisticated)
Attached Files
File Type: a2w finalproject.a2w (7.99 MB, 19 views)
   
Reply With Quote
Old
davidghemer
Member
 
Status: Offline
Posts: 38
Join Date: Nov 2011
Default 11-30-2011, 08:35 PM

To make sure the car doesn't go off of the road you could place a dummy object on the edge of each side of the first road. Then put your move left and move right commands inside of an if condition. Use the "is to left of" function to check that the convertible is to the left of the dummy object on the right hand side. Similar for the other side.

I also suggest changing your left and right movement events to while key is pressed events. This will give much smoother movement. Also decrease the distance in your left and right move methods (1 metre will be enough).

Finally, you might want to change the vehicle for the camera (look under properties) to the convertible. That way the camera follows the vehicle. You can do this instead of moving the camera forward.

Other than those changes it looks good.


For video tutorials on programming in Alice 2.2 check out my YouTube channel

http://www.youtube.com/user/drdave785

Also check out my Programming in Alice blog at

http://programminginalice.com
   
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 ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.