PDA

View Full Version : Game boundaries



Applekirupa
December 16th, 2005, 07:51 AM
Anyone know how i can make boundries for my game:sigh:

Joppe
December 16th, 2005, 09:46 AM
wtf..? We dont know your code structure or anything..
on(keyPress("LEFT"){
if(this.hitTest(bound){
this._x += 2;
}
}
Or something..

nathan99
December 16th, 2005, 06:56 PM
or


///If you put it on the MC
onClipEvent(load){
maximumBottom = Stage.height;
minimumLeft = 0;
maximumRight = Stage.width;
minimumTop = 0;
}
onClipEvent(enterFrame){
if(this._x < minimumLeft){
this._x = minimumLeft;
} else if(this._x > maximumRight){
this._x = maximumRight;
}
if(this._y < minimumTop){
this._y = minimumTop;
} else if(this._y > maximumBottom){
this._y = maximumBottom;
}
}

///If you put it on the frame::
///myMC is the instance name
myMC.maximumBottom = Stage.height;
myMC.minimumLeft = 0;
myMC.maximumRight = Stage.width;
myMC.minimumTop = 0;
myMC.onEnterFrame= function(){
if(this._x < this.minimumLeft){
this._x = this.minimumLeft;
} else if(this._x > this.maximumRight){
this._x = this.maximumRight;
}
if(this._y < this.minimumTop){
this._y = this.minimumTop;
} else if(this._y > this.maximumBottom){
this._y = this.maximumBottom;
}
}


this code wont let them go off view. Or if u meant like making walls see this post:
http://www.kirupa.com/forum/showthread.php?t=202035

Joppe
December 17th, 2005, 07:12 AM
trying to outsmart me are you Nathan. I seriously recomend Nathans code over mine :lol:

nathan99
December 17th, 2005, 07:27 AM
lol. but i still love you jop. :D

Applekirupa
December 17th, 2005, 11:27 AM
tks nathan;)

skatingmunk
December 25th, 2005, 11:21 PM
can you apply boundries to shapes? such as in a pong out game on that little bar that the ball bounces off?

Ravmaster
December 31st, 2005, 11:44 AM
Yeah Or Just Something Like An Extendd Bookcase That You Cant Walkthru

Robin105
January 1st, 2006, 09:23 PM
Nathan Umm can u help me a bit how cqan u make it so that u cant touch another object like a rock in the middle of the screen (its not going to be in the middle -.-)

NiñoScript
January 2nd, 2006, 10:48 AM
put all the objects in a wall_mc, then use hitTest with shapeFlag ;)