PDA

View Full Version : Code help


Mark Aged
08-24-2006, 12:52 PM
Making a game where a guy can go and out of a car, it works, but the car can't drive. Here is the code:

onClipEvent (enterFrame) {
if (_root.ride == 1) {
if (Key.isDown(Key.ENTER)) {
_root.character._visible = true;
_root.character._x += 15;
_root.ride = 0;
}
_root.character._x = _x;
_root.character._y = _y;
if (Key.isDown(Key.RIGHT)) {
_rotation = _rotation+move;
}
if (Key.isDown(Key.LEFT)) {
_rotation = _rotation-move;
}
if (Key.isDown(Key.UP)) {
if (move<8) {
move++;
move++;
}
} else if (move>0) {
move--;
move--;
}
if (Key.isDown(Key.DOWN)) {
if (move>-10) {
move--;
move--;
}
} else if (move<0) {
move++;
move++;
}
if (_rotation>180) {
_y = _y+(move*Math.cos(Math.PI/180*_rotation));
_x = _x-(move*Math.sin(Math.PI/180*_rotation));
}
if (_rotation<180) {
_y = _y-(move*Math.cos(Math.PI/180*_rotation));
_x = _x+(move*Math.sin(Math.PI/180*_rotation));
}
}
}
onClipEvent (enterFrame) {
if (_root.ride == 1) {
if (Key.isDown(Key.SPACE)) {
_root.character._visible = true;
_root.character._x += 100;
_root.ride = 0;
_root.ride._visible = false;
_root.character1 = 1;
}
_root.character._x = _x;
_root.character._y = _y;
if (Key.isDown(Key.UP)) {
speed += .75;
d += 4;
moving = true;
}
if (Key.isDown(Key.DOWN)) {
speed -= .75;
}
if (Math.abs(speed)>7) {
speed *= .9;
moving = true;
}
if (Key.isDown(Key.LEFT)) {
_rotation -= 9;
moving = true;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += 9;
moving = true;
}
speed *= .88;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.land.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
_root._x -= x;
_root._y -= y;
} else {
speed *= -.6;
}
}
}
onClipEvent (enterFrame) {
if (_root.ride == 0 && this.hitTest(_root.character) && Key.isDown(Key.ENTER)) {
_root.character._visible = false;
_root.ride = 1;
_root.character1 = 0;
}
}
onClipEvent (load) {
speed = 0;
_root.ride = 0;
}


And the car don't move normally. Help?

XGEN-CRaZeD
08-24-2006, 12:55 PM
Shouldn't it be _root.character._visible = false;?

Mark Aged
08-24-2006, 02:27 PM
Look at all of the code. Plus that's not my problem.

Logic
08-24-2006, 08:25 PM
I looked at your code and it doesn't look like you ever even move the car...

Mark Aged
08-25-2006, 05:59 AM
You do. You just spin around. When you try to go up and down, it just moves, like......pixel by pixel. Slowly. So, help?

Matt
08-25-2006, 06:18 AM
Just speed up your movement.

Mark Aged
08-25-2006, 06:31 AM
Just speed up your movement.

The god Matt come and fixes everything. In 5 words or less. Wait, where may that be? I tried messing with some numbers, but it didn't do anything.

Matt
08-25-2006, 07:38 AM
move++
This is makin yo pick up speed 1 pixle at a time.
if (move>0) {
That checks if your moving faster than in other words your moving by 1 pixle before this:
move--;
Meaning you never get a speed of over 1...
So change
if (move>0) {
To
if (move>19)
See if that well help. Fool around with that idea.

Mark Aged
08-25-2006, 07:48 AM
This is makin yo pick up speed 1 pixle at a time.

That checks if your moving faster than in other words your moving by 1 pixle before this:

Meaning you never get a speed of over 1...
So change

To
if (move>19)
See if that well help. Fool around with that idea.

Will you look at that. We solved a flash problem, and no one got flamed, and nobody flamed anybody else. Its a christmas miracle. I thought the "move>0" looked odd....Thanks Matt.

EDIT: Oh, ****, it still don't work. Here's the Flash file, I can't get it to work.