-
I have an object that I move with the arrow keys. If you open up movement-thrust.fla example in program files\macromedia\flash mx\samples\fla you will see what I am working with. If you replace the current action script for the bug with this:
Code:
onClipEvent (load) {
// declare and set initial variables
thrust = 1;
decay = 1;
maxSpeed = 5;
xthrust = 1;
flames._visible = 0;
ySpeed = -1;
xSpeed = -1;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
//Move right
xSpeed += xthrust;
flames._visible = 0;
}
if (Key.isDown(Key.LEFT)) {
// move left
xSpeed -= xthrust;
flames._visible = 0;
}
//
if (Key.isDown(Key.UP)) {
//move up
ySpeed += thrust;
}
if (Key.isDown(Key.DOWN)) {
//move down
ySpeed -= thrust;
}
// maintain speed limit
speed = Math.sqrt((xSpeed*xSpeed)+(ySpeed*ySpeed));
if (speed>maxSpeed) {
xSpeed *= maxSpeed/speed;
ySpeed *= maxSpeed/speed;
}
//
// move beetle based on calculations above
_y -= ySpeed;
_x += xSpeed;
//
// Keep the bug from moving off screen.
if (_y<0) {
_y = 0;
}
if (_y>232) {
_y = 232;
}
if (_x<0) {
_x = 0;
}
if (_x>465) {
_x = 465;
}
}
You will see what I am working with.
Eventually I want to apply this script to the hot air balloon in this picture:
My problem is that I would like to somehow output a correlation between the xSpeed, ySpeed, and the various forces. I would like to do this using dynamic text. For example, when the ySpeed=2, I would like the gravity to be 20,000 and the air pressure to be 40,000.
Does anyone have any ideas on how I can do this?
Thanks.
Brian
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|