Alice Community  

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

Reply
 
Thread Tools Display Modes
make a car stop
Old
Katrina 68
Guest
 
Status:
Posts: n/a
Default make a car stop - 04-20-2008, 07:21 PM

I have to do the problem called driving test, where I have set up to make a car go forward when I press a key. The problem is that when the car starts I don't know how to make it stop when I let go of the key. Help!
   
Reply With Quote
Old
John_Clark
Guest
 
Status:
Posts: n/a
Default 04-21-2008, 11:24 AM

Use a while a key is pressed event and only make the car move while the key is pressed.
   
Reply With Quote
Stopping the car ?
Old
itrimble
Guest
 
Status:
Posts: n/a
Default Stopping the car ? - 08-20-2008, 06:24 PM

The problem I am having is that I want to make a car start when I press a button and stop when I press a second button. What would the methods be for me to stop the car when I press the button ?
   
Reply With Quote
Old
DrJim
Guest
 
Status:
Posts: n/a
Default 08-21-2008, 03:32 AM

Your safest way is to make a specific boolean variable to control the movement of the object and then use it in a stand-alone method for the object that executes a "while loop" while that parameter is true.

Now you can use the event(s) of your choice to control the state of the variable.

There are several examples of "walk methods" in the forum that use this approach and can provide more detail.

For beginners, I would recommend a world level variable using the world parameters window. The way Alice resets a variable to its default value isn't always obvious - so this is the safest way, even though it really isn't good programming practice. For more experienced programmers, the preferred way is to make control variable a property of the object itself.
   
Reply With Quote
Smooth Start/Stop Under Key Control
Old
DrJim
Guest
 
Status:
Posts: n/a
Default Smooth Start/Stop Under Key Control - 08-22-2008, 02:10 AM

For faster response to the control parameter, use the "move at speed", "turn at speed" and "roll at speed" commands, with fairly short durations, in the while loop. One example is in the attached screenshot - see also the walk examples elswhere in the forum.

(Note: This is in response to a private message. It's always better to do this in the public part of the forum - lots of other people may be having the same problem(s). )
Attached Images
File Type: jpg chick turn.jpg (39.7 KB, 145 views)
   
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.