Alice Community  

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

Reply
 
Thread Tools Display Modes
Car speed up over time?
Old
dubastot
Senior Member
 
dubastot's Avatar
 
Status: Offline
Posts: 661
Join Date: Apr 2009
Location: Two Steps From Hell
Question Car speed up over time? - 06-16-2009, 11:51 AM

How do you make a car speed up over time?
   
Reply With Quote
Car speed up
Old
ploply
Guest
 
Status:
Posts: n/a
Default Car speed up - 06-16-2009, 03:11 PM

Quote:
Originally Posted by dubastot View Post
How do you make a car speed up over time?
Set duration to begin gently.

ploply
   
Reply With Quote
Old
ttkrakus
Guest
 
Status:
Posts: n/a
Default 06-17-2009, 11:36 PM

Quote:
Originally Posted by ploply View Post
Set duration to begin gently.

ploply
This will work for when the car first starts moving, but if you want acceleration, then you need something else. Let's start with velocity.

Velocity is usually represented as unit-of-distance over unit-of-time, like miles/hour, for example.

So, if you use the 'move' method with a *fixed* duration to make the car move, then by increasing the value of the argument 'amount' will make the car looks as it is moving faster (it is covering more distance in the same amount of time)

So, what to do.
Declare a Number variable for the car object; call it 'velocity' --somewhat misleading, but it will do the trick.

Use this variable as the argument 'Amount' for the 'move' method of the car object.

If you want the speed of the car to change by pressing certain keys, then define two 'When a Key is pressed' events (say, one for the + key to increase the speed, and one for the - key to decrease it). Increase (decrease) the value of the variable 'velocity' by a fixed amount every time the event for increasing (decreasing) the speed is triggered.

If you just want the car to accelerate by itself, you could have a little loop with two tiles: one in which you increase the value of variable 'velocity', and the other for moving the car using 'velocity' as the 'Amount' argument.

Hope this helps

Last edited by ttkrakus; 06-17-2009 at 11:40 PM.
   
Reply With Quote
Old
dubastot
Senior Member
 
dubastot's Avatar
 
Status: Offline
Posts: 661
Join Date: Apr 2009
Location: Two Steps From Hell
Unhappy 06-19-2009, 06:38 PM

Quote:
Originally Posted by ttkrakus View Post
This will work for when the car first starts moving, but if you want acceleration, then you need something else. Let's start with velocity.

Velocity is usually represented as unit-of-distance over unit-of-time, like miles/hour, for example.

So, if you use the 'move' method with a *fixed* duration to make the car move, then by increasing the value of the argument 'amount' will make the car looks as it is moving faster (it is covering more distance in the same amount of time)

So, what to do.
Declare a Number variable for the car object; call it 'velocity' --somewhat misleading, but it will do the trick.

Use this variable as the argument 'Amount' for the 'move' method of the car object.



Hope this helps

So I make a method where car move 5m in 10secs and then car move 5m in 9secs and then car move 5m at 8secs...????
So
   
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 ©2023, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.