scrolling track, top down racing game
I have a dilemer, im making a top down racing game and ive hit a wall.
Ive got all the coding for moving the car and collision detection, ie the car is working perfectly. My problem is the track, the track i have dosent fit on the screen. I need a way to scroll the track around as the car moves. I dont want the car to stay in exactly the same spot, ie moving the track rather that the car.
onClipEvent (enterFrame) {
carx = getProperty("/car1", _x);
cary = getProperty("/car1", _y);
if (carx < 100) {
trackx = getProperty("/track", _x)
trackx = trackx + w
setProperty ( "/track", _x, trackx )
}
if (cary > 400) {
tracky = getProperty("/track", _y)
tracky = tracky - w
setProperty ( "/track", _y, tracky )
}
if (carx > 400) {
trackx = getProperty("/track", _x)
trackx = trackx - w
setProperty ( "/track", _x, trackx )
}
if (cary < 100) {
tracky = getProperty("/track", _y)
tracky = tracky + w
setProperty ( "/track", _y, tracky )
}
}
this is the code i have so far, it kinda works but i need a way to stop the car going of the screen, the tracks moves but the car keeps going. varible W is the rate at which the car moves.
Any sugetstions would be greatly appreciated.
even a totally diferent approach would be fine.
Thanx Alot
|