View Full Version : need a wall code plz!
bitterman
June 28th, 2005, 03:52 AM
Im making a game with a tank, and i need a code for the walls. If it is possible, i need a code so that he just doesnt pass through it, not a code that makes him bounce off the wall. Also, if anyone knows a code that will make the baddie movieclip play a death frame when they get hit by a bullet that would be greatly appreciated.
Herez da fla!
dominicaninja
June 28th, 2005, 10:50 AM
Have you looked around the internet at all? You can easily find code for walls and tons of other stuff by just searching google. I would say try looking at the tonyPa tutorials. To avoid that bouncing effect you're gonna need to check the movieClips position BEFORE he touches the wall, so you don't move him into it.
grittmaster69
June 28th, 2005, 09:40 PM
Make a thick border around the level and make it an MC and name it "wall" and then give the the instance name "wall" and then put this inside of your "gun" MC-
onClipEvent (enterFrame) {
with (_root.gun) {
if (_root.wall.hitTest(getBounds(_root).xMax, _y, true)) {
_root.gun._x -= 0;
_x -= 10;
}
if (_root.wall.hitTest(getBounds(_root).xMin, _y, true)) {
_root.gun._x += 0;
_x += 10;
}
if (_root.wall.hitTest(_x, getBounds(_root).yMax, true)) {
_root.gun._y -= 0;
_y -= 10;
}
if (_root.wall.hitTest(_x, getBounds(_root).yMin, true)) {
_root.gun._y += 0;
_y += 10;
}
}
}
bitterman
June 29th, 2005, 04:52 AM
thanks man! Helped heaps!!
bitterman
June 29th, 2005, 04:57 AM
but does anyone no how to play the death clip when the bad guy hits hit by a bullet?
Blackspirit
June 29th, 2005, 08:41 AM
Well, theres a lot of code in there relating to the instance "badGuy" but you've named the object "baddie"....so rename the object to "badGuy"
Then you need to put a frame in the baddies movieclip, somekind of death animation or something.
Then in the main timelines actions, just under where it says somthing like "badGuy.Hittest(this._x,this._y)"
you need to put "badGuy.gotoAndPlay(2)", or where your death animation starts.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.