Alice Community Stop my car

 Stop my car
 pedrodantas Junior Member   Status: Offline Posts: 2 Join Date: Oct 2011 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!
davidghemer
Member

Status: Offline
Posts: 38
Join Date: Nov 2011
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
 cardriveuntil.a2w (229.7 KB, 16 views)

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

Also check out my Programming in Alice blog at

http://programminginalice.com

pedrodantas
Junior Member

Status: Offline
Posts: 2
Join Date: Oct 2011
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
 finalproject.a2w (7.99 MB, 19 views)

 davidghemer Member   Status: Offline Posts: 38 Join Date: Nov 2011 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

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     Community News and Announcements Alice 3     How Do I?     Works In Progress     Share Your World     Share Custom Classes     Bugs and Trouble Shooting     Suggestion Box Alice 2     How do I...?     Works-In-Progress     Share Worlds     Share Objects     Bugs and Troubleshooting     Suggestion Box Educators     Teaching with Alice     Teaching Using Alice 3     Teaching Using Alice 2     CS Principles and Alice     AP CSA and Intro to Java and Alice     Workshops General Discussion     Questions and Comments     The Lounge