two objects intersecting

need to get my game to stop running when alien hits ship

Page 1 of 1

2 Replies - 1424 Views - Last Post: 14 April 2008 - 12:10 PM

#1 JasonBob  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 14-April 08

two objects intersecting

Post icon  Posted 14 April 2008 - 06:48 AM

PLEASE HELP

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


Is This A Good Question/Topic? 0
  • +

Replies To: two objects intersecting

#2 girasquid  Icon User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

Re: two objects intersecting

Posted 14 April 2008 - 09:41 AM

Okay - what's the problem?
Was This Post Helpful? 0
  • +
  • -

#3 JasonBob  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 14-April 08

Re: two objects intersecting

Posted 14 April 2008 - 12:10 PM

My problem is that when these two objects intersect i need it to stop running the game
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1