Forum Topic: Gliding Airplane- Actionscript Help

(97 views • 4 replies)

This topic is 1 page long.

<< < > >>
Resigned

bugsandinsects

Reply To Post Reply & Quote

Posted at: 5/11/08 05:32 AM

bugsandinsects NEUTRAL LEVEL 07

Sign-Up: 04/08/08

Posts: 5

I'm trying to put a part into my game where the player controllers a gliding airplane (side view).

I want the airplane the go upwards and slow down when the back key is pressed, and downwards and faster when the forwards key is pressed.

For some reason I am having a hard time getting it to work, and I would really love some tips or pieces of code for help.

Thanks in advance.


None

West-End-Pro

Reply To Post Reply & Quote

Posted at: 5/11/08 05:36 AM

West-End-Pro NEUTRAL LEVEL 23

Sign-Up: 02/15/06

Posts: 2,359

Show us what you've done? / Your current code?


None

bugsandinsects

Reply To Post Reply & Quote

Posted at: 5/11/08 05:51 AM

bugsandinsects NEUTRAL LEVEL 07

Sign-Up: 04/08/08

Posts: 5

OK

I'm not happy at all with how this works, I might delete it all and start fresh. The code is pretty sloppy because I have just been experimenting with changing different numbers and variables as I go.

The "planeRelease" variable is a number between 1 and 10, from the scene before, 10 being the best start position, and 1 the worst.

onClipEvent (load) {
angle = _global.planeRelease-10
speed = 10+_global.planeRelease
fall = 12-_global.planeRelease
rotation = 0
gravity = 1
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
rotation += 10;
}
if (Key.isDown(Key.LEFT)) {
rotation -= 10;
}
if (speed <= 0) {
speed = 0.1
}
}
onClipEvent (enterFrame) {
this._x += speed*1.2/10
this._y += rotation+gravity+fall/10
this._rotation = rotation
}
onClipEvent (enterFrame) {
if (rotation > 0) {
speed += .3;
fall += 1
}
if (rotation < 0) {
speed -= .3;
rotation -= .3
}
if (speed <= .5) {
fall += 3
}
}
onClipEvent (enterFrame) {
if (rotation >= 20) {
rotation = 20
}
if (rotation <= -20) {
rotation = -20
}
}


None

VoidSkipper

Reply To Post Reply & Quote

Posted at: 5/11/08 06:43 AM

VoidSkipper LIGHT LEVEL 15

Sign-Up: 12/08/06

Posts: 132

Basic trig. Just google for trig help and figure it out.


None

bugsandinsects

Reply To Post Reply & Quote

Posted at: 5/11/08 07:24 AM

bugsandinsects NEUTRAL LEVEL 07

Sign-Up: 04/08/08

Posts: 5

I'll try that, thanks.


All times are Eastern Standard Time (GMT -5) | Current Time: 04:16 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!