ForumsProgramming ForumHow can I Program a wall?

6 3224
mobin
offline
mobin
12 posts
Nomad

How can I Program a wall?

  • 6 Replies
tehQED
offline
tehQED
33 posts
Nomad

Be more specific.

Axel
offline
Axel
475 posts
Nomad

You mean if someone runs into a wall, he will stop or something?

mobin
offline
mobin
12 posts
Nomad

yep!

mobin
offline
mobin
12 posts
Nomad

I have swish max , I make 1 circle that move with keypress , but I want to keep circle and player in one place , so I need wall to block moving out of there. how can I program a wall?

IIAOPSW
offline
IIAOPSW
4 posts
Nomad

i would make a wall class. the job of this class is to simply exist. onEnterFrame, the circle should run a collision test with a list of walls. if it hits, have the circle bounce back a few pixels.

AS2 (idk AS3)

class wall extends MovieClip
{
function onLoad()
{
_root.circle.walls.conact(this)
}
}


class circleThing extends MovieClip
var walls //list of walls
var xvel //x axis velocity
var yvel //y axis velocity
function onLoad()
{
walls=[]
xvel=0
yvel=0
}
function onEnterFrame()
{
if(key.isDown(key.UP))
{
this.yvel=15
}
if(key.isDown(key.down))
{
this.yvel=-15
}
if(key.isDown(key.LEFT))
{
this.xvel=-15
}
if(key.isDown(key.RIGHT))
{
this.xvel=15
}
for(var i in walls)
{
if(this.hitTest(walls))
{
//some commands that bounce you back. to lazy to do it [i]all
for you
}
}
this._x=+xvel
this._y=+yvel
}

Axel
offline
Axel
475 posts
Nomad

Woah woah woah woah.

You don't have flash? What?

Showing 1-6 of 6