Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   2 car driving game (http://www.alice.org/community/showthread.php?t=3170)

dwilcoxson 10-08-2009 08:51 AM

2 car driving game
 
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?

uzack3 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.

x2495iiii 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.

dwilcoxson 10-12-2009 08:30 PM

thanks guys, it's working better.

maxf 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.


All times are GMT -5. The time now is 03:36 PM.

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