My problem is when these two objects intersect i need the game to stop running but i can't seem to get that to happen.
I need help to make a game for my class at school. I am making a ship fly around that you control, and an alien flys around "at random" and you try to avoid it.
this is my aliens script
[//this is triggered when the clip loads
onClipEvent (load)
{
xmove = random(15) - random(15); //comments can also go after statements
ymove = random(15) - random(15); //this sets the ymovement randomly
this._x = random(640); //this sets the x and y position rando
this._y = random(480);
}
//this is triggered everytime a new frame is entered, in this case 30 times a sec
onClipEvent (enterFrame)
{
//lets move the alien around
this._x = this._x + xmove;
this._y = this._y + ymove;
//bounce the alien if it is out of bounds
if(this._x > 650){xmove = Math.abs(xmove) * -1}
if(this._x < 0){xmove = Math.abs(xmove)}
if(this._y > 650){ymove = Math.abs(ymove) * -1}
if(this._y < 0){ymove = Math.abs(ymove)}
} ]
and this is the ships script
[//moves ship when pussing keys
onClipEvent(enterFrame)
{
if(Key.isDown(Key.RIGHT) and this._x < 640) {
this._x = this._x + 15;
} else if (Key.isDown(Key.LEFT) and this._x > 0) {
this._x = this._x - 15;
}
if (Key.isDown(Key.UP) and this._y > 400){
this._y -= 15;
}
if
(Key.isDown(Key.DOWN) and this._y < 600) {
this._y += 15;
}
}]
code at start of program
ideas based on some other scripting i've done
[if (PlayerShip._x - Alien._x = -5 to 5
and PlayerShip._y - Alien._y = -5 to 5) {
stop();
}
}]
please help me
thank you,
Jasonbob
This post has been edited by JasonBob: 15 April 2008 - 06:17 AM

New Topic/Question
Reply



MultiQuote



|