Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   Driving Test (http://www.alice.org/community/showthread.php?t=4225)

MikeC 04-11-2010 11:43 PM

Driving Test
 
Hello. I am having trouble with project 3 in chapter 6. I can get the car to move freely but not sure how to stop the car and have text appear when I touch a cone. Help would be much appreciated. Thanks!

MikeC 04-12-2010 06:38 PM

Any one?

bjia56 04-12-2010 06:40 PM

[QUOTE=MikeC;19712]Hello. I am having trouble with project 3 in chapter 6. I can get the car to move freely but not sure how to stop the car and have text appear when I touch a cone. Help would be much appreciated. Thanks![/QUOTE]

Unfortunately, I have no idea what you mean by "project 3 in chapter 6," probably because I don't have any of the Alice textbooks.

MikeC 04-12-2010 06:58 PM

[QUOTE=bjia56;19761]Unfortunately, I have no idea what you mean by "project 3 in chapter 6," probably because I don't have any of the Alice textbooks.[/QUOTE]

I have to maneuver a car around some cones and if the car hits a cone the car stops and text appears. I have created three methods for the car movements forward, left and right using the while ... is pressed. I'm not sure how to make the car stop and the text appear when I hit a cone.

shaydon 04-12-2010 07:02 PM

umm.. try if car is (1mtr)... of 'cone1' do method 'crash'

MikeC 04-12-2010 07:18 PM

[QUOTE=shaydon;19769]umm.. try if car is (1mtr)... of 'cone1' do method 'crash'[/QUOTE]

Ok I made a car.method crash to move car 0 meters and set is showing to true then in world I put if/else if car is within .05 meter of cone; car.crash but nothing happens so I know im doing something wrong?

bjia56 04-12-2010 07:24 PM

Are you able to post your current world? I'll take a look and see what I can suggest.

MikeC 04-12-2010 07:31 PM

1 Attachment(s)
[QUOTE=bjia56;19771]Are you able to post your current world? I'll take a look and see what I can suggest.[/QUOTE]

Yes I can. Thanks!

bjia56 04-12-2010 07:55 PM

Ok I would suggest having a Boolean variable to see whether you can move or not, then have each of the "while [key] is pressed do" include an "if" statement to test whether the car can be moved.

Then you can do what shaydon suggested, only include at the beginning of the method a statement that changes the variable value.

MikeC 04-12-2010 08:10 PM

[QUOTE=bjia56;19773]Ok I would suggest having a Boolean variable to see whether you can move or not, then have each of the "while [key] is pressed do" include an "if" statement to test whether the car can be moved.

Then you can do what shaydon suggested, only include at the beginning of the method a statement that changes the variable value.[/QUOTE]

Thanks!! I'll see what I can do.


All times are GMT -5. The time now is 07:45 PM.

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