Yes, I know I should be coding in AS3. Just going to get that out of the way. I’ll make the jump soon enough, but this project needs to be finished first, then I’ll change to AS3. I might even re-write this project in AS3 as a getting-started test. Anyway, I’ve been coding it for some time, and although it is my first major game I would like to think I’ve got a fair bit better at AS2 now. I’ve written up the entire game, bar the tutorial – nothing that will be technically difficult. I wrote my own car physics, but I’m not sure if they way I’m moving the _x and _y of the car is the way that is optimal – this is the code I’m using currently:

_root.background1.car._x += Math.sin (_rotation * Math.PI / 180) * speed; _root.background1.car._y += Math.cos (_rotation * Math.PI / 180) * -speed;

It was the one part of the car physics that I couldn’t figure out – I hadn’t even thought about converting the _rotation to work it out, so glad that I searched to find it out. My problem now, is that my car is reporting it’s _x and _y locations in correctly. At first I thought it might be because the “car” movieclip is inside the background1 movie clip, as you can see from the code. I hadn’t thought this would cause problems, but I checked it anyway – nothing causing it there. After some more … inventive solutions, nothing was working. I’m not sure why it’s not working, but I’m sure the people here in Game Programming would know. You’re all brilliant :D

If you guys need to, I can post the download link to a .fla with just my car code in it, and a sample building to hitTest. I’m not sure why it’s not working – the strange part is, if I just use the car’s instance name, it works fine. But if I try and enable the shapeFlag function (which as far as I know, requires a _x and a _y value to be submitted), it doesn’t work.

Here is the total code I use for the car:

onClipEvent (load) { var speed:Number = new Number (0); } onClipEvent(enterFrame){ speed = speed * 0.98; if(Key.isDown(Key.UP) && !Key.isDown(Key.CONTROL)){ speed += 1.2 } if(Key.isDown(Key.DOWN)){ speed -= 0.8; } if (Key.isDown(Key.RIGHT)){ if(speed < 5 && speed >= 0){ _rotation += 1 * speed; } if(speed < 0 && speed >= -2.5){ _rotation += 1 * speed; } if(speed < -2.5){ _rotation += 2.5; } else if(speed > 5){ _rotation += 4.5; } speed *= 0.95; } if (Key.isDown(Key.LEFT)){ if(speed < 5 && speed >= 0){ _rotation -= 1 * speed; } if(speed < 0 && speed >= -2.5){ _rotation -= 1 * speed; } if(speed < -2.5){ _rotation -= 2.5; } else if(speed > 5){ _rotation -= 4.5; } speed *= 0.95; } _x += Math.sin (_rotation * Math.PI / 180) * speed; _y += Math.cos (_rotation * Math.PI / 180) * -speed; if (Math.abs(speed) > 12.5){ speed = 12.5; } if(speed < -5){ speed = -5; } if (Key.isDown(Key.CONTROL)){ speed -= speed / 5; if(Key.isDown(Key.RIGHT)){ _rotation += speed / 2; } if(Key.isDown(Key.LEFT)){ _rotation -= speed / 2; } } }