Alice Community  

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

Reply
 
Thread Tools Display Modes
Change speed with key press
Old
ICS
Guest
 
Status:
Posts: n/a
Default Change speed with key press - 04-26-2009, 02:03 PM

I have an airplane that changes speed with a "When a key is typed" event. I have set up 5 speeds each getting a little faster. The problem I am having is that I can go from speed 1 to 5 but when I try to reverse the order, nothing happens. I am trying to set up a game where the user can control the speed and turning of the airplane.

Each speed is set up in an infinite loop which I think may be the problem. But, this is the only way I can figure to keep the plane moving until the user changes the speed with a different key stroke.

Last edited by ICS; 04-26-2009 at 02:28 PM. Reason: adding detail
   
Reply With Quote
Old
HisWorld
Guest
 
Status:
Posts: n/a
Default 04-26-2009, 02:47 PM

Not sure where your problem is, it would help if you posted some of your code and how you are trying to implement this.

I don't think that should be to hard to accomplish, one of the best ways may be to create a global world varible of type number that changes based on what button you push and then inside your "While the world is running event" have several conditional If-else statements that determine at what speed your plane should go.

This can be down like this.
when "1" is typed "world.currentspeed" set value to "1"

Well I went ahead and made an example using global variables. I'll try to attach in a bit.
Attached Files
File Type: a2w practiceplane.a2w (329.4 KB, 39 views)

Last edited by HisWorld; 04-26-2009 at 02:57 PM.
   
Reply With Quote
I get it!
Old
ICS
Guest
 
Status:
Posts: n/a
Default I get it! - 04-26-2009, 04:18 PM

Thank you. I was trying something like this but I was not handling the variables correctly.
   
Reply With Quote
Old
HisWorld
Guest
 
Status:
Posts: n/a
Default 04-26-2009, 05:07 PM

No problem, I've only started today to really get into this program.
   
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 ©2021, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.