PDA

View Full Version : Racing game, keeping car in bounderies



dangerskew
July 18th, 2004, 02:56 PM
I'm trying to make a racing game, but I don't know how to keep the car from going off the track. So far I just have it so when you go off the track you're car's alpha goes to 50. Does anyone know how I would keep it from going off?

signifer123
July 18th, 2004, 02:59 PM
Why can't ya just have it so you slow down when you go off the boundry thats what most people do amd then its more realistic

elPooter
July 18th, 2004, 03:12 PM
Boundary? do you mean walls?

dangerskew
July 18th, 2004, 03:25 PM
^I meant keeping the car on the track. As for slowing the car down if it's off the track, how would I do that? I don't know what to do.

EDIT: Also, I'm just curious as to how I would keep it on the track, as if there were walls around it, that's kind of what I was trying to do. Make it so you can't go through the walls.

EDIT: Nevermind, I figured out how to make the car slow down when it's not touching the track. I still want to know how to make it not go through walls though. Thanks.

elPooter
July 18th, 2004, 03:39 PM
you could try:



onClipEvent (enterFrame) {
if (_root.walls.hitTest(getBounds(_root).xMax, _y, true)) {
this._x -= 5;
}
if (_root.walls.hitTest(getBounds(_root).xMin, _y, true)) {
this._x += 5;
}
if (_root.walls.hitTest(_x, getBounds(_root).yMin, true)) {
this._y += 5;
}
if (_root.walls.hitTest(_x, getBounds(_root).yMax, true)) {
this._y -= 5;
}
}

TheOneAndOnly
July 18th, 2004, 03:41 PM
could u save it as MX plz?

dangerskew
July 18th, 2004, 03:49 PM
I don't think that one code would work, seeing as how neither the track nor the car are square.

elPooter
July 18th, 2004, 03:52 PM
Oh. Well, I couldn't view the fla so I wouldn't know.

EDIT: Also, that is the only hitTest code I know.

TheOneAndOnly
July 18th, 2004, 06:31 PM
here ya go

Changes-
Added actions to the car (at the very bottom)
Added a boundarys layer

dangerskew
July 18th, 2004, 07:03 PM
Thanks! That works quite well.

TheOneAndOnly
July 18th, 2004, 07:13 PM
your welcome :)

lastchildz
July 24th, 2004, 01:38 AM
You could check this engine too , it's working pretty good .
http://www.markfennell.com/flash/using.html

dangerskew
July 24th, 2004, 05:05 PM
That one also has a bug. In that game, when you hit an object, if you keep pressing forward and then turn your car, you can get inside things.

average_male
November 4th, 2005, 02:44 PM
here ya go

Changes-
Added actions to the car (at the very bottom)
Added a boundarys layer

Nice work. That was awesome of you to update it and post it.

Thanks for you efforts, helped me out a lot!!!

-Joe

nathan99
November 4th, 2005, 07:00 PM
heres an oldy, but a goody.

nathan99
November 4th, 2005, 07:02 PM
with that, i can tell you how to fix the hitTest

NiñoScript
November 5th, 2005, 01:54 PM
this guy did it using tiles, perhaps that way is easier
http://oos.moxiecode.com/examples/proam/index.html

GPP
November 5th, 2005, 06:59 PM
O man a car based game using tiles.. never thought id see da day..