Stop Car

Hi,

I made,following one of the tutorials, a car that moves using keys like Up,Down,Left,Right.

Now i wonder how to do it that you draw a layer “wall” and if the car drives, it cannot pass it, it has to go around.(Like a maze)
I think this has maybe something to do with collision detection.

Please reply!!!

on my game i just used hitTest() function… i guess you could’ve also limited that but getting the x and y coordinates and comparing them to the wall’s coordinates… for a maze, i dont think the latter method would work efficiently, i guess you’d have to use hitTest()

cheers
:A+:

you will have to create a movie clip with an instance name like “wall” and use a script similar to that:

if (wall.hitTest(getBounds(_root).xMax, _y, true)) {
	speed = 0;
}
if (wall.hitTest(getBounds(_root).xMin, _y, true)) {
	speed = 0;
}
if (wall.hitTest(_x, getBounds(_root).yMax, true)) {
	speed = 0;
}
if (wall.hitTest(_x, getBounds(_root).yMin, true)) {
	speed = 0;
}

=)

Interesting line of code guigo… With the getbounds…

Will that test every x pixel for the bounds of the car with that… or just the maxX pixel?

UGHH… Nevemrind… I’m stupid I’m editting this after previewing it again…

hits himself with a giant salami

[SIZE=1]::I feel some code-explaining needed::[/SIZE]

Not to hard to explain.

Its saying if the wall got hi by anything moving trace the bounds witch is tghe lines out side the object and make it stop.

I tried the code for a time ,but it doesn’t work.
When i move the car, the wall moves with it!

Thanks, but please help

Luster do you have AIM.MSN If you do what is it.

Well i made a car game example a while ago and here is the link to the post.
http://www.kirupaforum.com/showthread.php?s=&threadid=11576&highlight=Car+example

my computer is on repair.

That piece of code must be placed on an enterframe handler, and, yes BullDog, it does exactly what you said.

I´m fixing some fla for you guys, jus give me a min or two:)