Be a Supporter!

How to make walls?

  • 344 Views
  • 2 Replies
New Topic Respond to this Topic
BushidoBacon
BushidoBacon
  • Member since: Sep. 14, 2007
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
How to make walls? 2008-06-01 00:34:09 Reply

I am currently in the process of making my first game, and I have very little knowledge of Action Script. The game I'm designing is an overhead (top-down) shoot-em-up. I was doing fine for a while, until I encountered a problem; I couldn't figure out how to make the character stop when he runs into a wall. I pored over numerous tutorials on NG for at least a couple of hours, but most tutorials didn't have anything to do with what I needed, and the most relevant tuts had broken scripts that I had no idea how to fix. Could somebody please help me figure out how to do this, or tell me where to find a tutorial that does work?
Thanks for your help, and be on the lookout for my game on teh portal when I finish it!


When Buddha held up a piece of bacon, Kasyapa smiled.

BBS Signature
ChilliDog
ChilliDog
  • Member since: Feb. 16, 2007
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to How to make walls? 2008-06-01 00:37:16 Reply

Check out AS: Main in my sig, I know I've seen tuts in there.


AS: Main

Don't read this sentence.

Treerung
Treerung
  • Member since: Apr. 18, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to How to make walls? 2008-06-01 01:04:48 Reply

ok here goes...this should help but check AS:Main too.

Setting Variables

walkspeed=10;

So I'm assuming you wrote the code for the character to move?

This code is for the character hitting a wall to the left

 while(this.hitTest(_root.wall._x, _root.wall._y, true))
{_x+=walkspeed+5;
walkspeed=walkspeed+0;
gotoAndStop(2);
}

So while your character is hitting the wall it will go in the other direction by more then its normal speed(so when its hits the wall..it gets knock back a little). Then the walkspeed gets set back to normal. And it goes to the frame of the character looking right(optional).

Hopes this helps!


:'(

BBS Signature