Alice Community  

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

Reply
 
Thread Tools Display Modes
2 car driving game
Old
dwilcoxson
Guest
 
Status:
Posts: n/a
Default 2 car driving game - 10-08-2009, 08:51 AM

I have just started using alice and it's great. I've created a couple of simple games with one object that is created with the arrows on the keyboard. I am now working on a race car game with 2 cars. one is controlled with the arrows and the other with a,w,s,e. the movements are jerkey because I can't hold down the a button and continuously turn left, i have to hit it each time. Can anyone help me with how to program it to turn continuously like the arrow keys?
   
Reply With Quote
Old
uzack3
Guest
 
Status:
Posts: n/a
Talking 10-08-2009, 09:16 AM

you could put it on a loop variable but then do a lot of work to make it stop so instead i would reccomend combining the let arrow keys move (and then select your object) along with let (any) key move (and then select object) and then do right and left. that may not work though.
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 10-08-2009, 01:08 PM

Here's what you can do:

Make an event for each of the four movements keys "when a key is typed."

Right-click that event and change it to "while a key is pressed."

In the during part, have your character turn or move a very small amount (.05 meters, .01 revolutions) in zero seconds.

In the end part, have your character stand up (not necessary, but sometimes the character can get tipped over, which this will fix)

With this setup, as long as you hold the key, the character will move, and move smoothly.
   
Reply With Quote
Old
dwilcoxson
Guest
 
Status:
Posts: n/a
Default 10-12-2009, 08:30 PM

thanks guys, it's working better.
   
Reply With Quote
Old
maxf
Guest
 
Status:
Posts: n/a
Default 10-17-2009, 07:26 PM

create a 'when key is typed' method. right click on in and change it to 'while key is pressed'. then in the during put your method. in the the method instead of telling your object to move forward # or meters. use a move at speed block (or if your turning a turn at speed block) that tells it how fast to turn in meters per second. This makes it so the object will start moving smoothly when you press the key and stop when you release.
   
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 ©2020, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.