Be a Supporter!

[as2] Bullet Collision With Zombie!

  • 479 Views
  • 12 Replies
New Topic Respond to this Topic
TheeCoffee
TheeCoffee
  • Member since: Aug. 12, 2011
  • Offline.
Forum Stats
Member
Level 07
Musician
[as2] Bullet Collision With Zombie! 2012-08-04 05:02:26 Reply

Sup guys! i need help right now!
I have a Script Here:

onClipEvent (mouseDown) {
if (shootable == true)
{

theX = this._x;
theY = this._y;

_root["bullet" + bulletsFired - 1].removeMovieClip();
_root.attachMovie("bullet","bullet" + bulletsFired,_root.getNextHighestDepth(),{_x:this._x, _y:this._y});

_root["bullet" + bulletsFired].bulletSpeed = 30;
_root["bullet" + bulletsFired].xmov = Math.cos((Math.atan2(_root._ymouse - _y, _root._xmouse - _x)) * (180 / Math.PI) * (Math.PI / 180));
_root["bullet" + bulletsFired].ymov = Math.sin((Math.atan2(_root._ymouse - _y, _root._xmouse - _x)) * (180 / Math.PI) * (Math.PI / 180));
_root["bullet" + bulletsFired].xmov *= _root["bullet" + bulletsFired].bulletSpeed;
_root["bullet" + bulletsFired].ymov *= _root["bullet" + bulletsFired].bulletSpeed;
bulletAngle = ((_root.player._rotation - 90) * Math.PI / 180);
_root["bullet" + bulletsFired]._rotation = bulletAngle;
_root["bullet" + bulletsFired].onEnterFrame = function()
{
this._x += this.xmov;
this._y += this.ymov;
if(_root["bullet" + bulletsFired].hitTest(_root.zombie)){
unloadMovie(_root["bullet" + bulletsFired]);
}
};
bulletsFired++;
shootable == false;
Shootable_Timer = setInterval(shooot, 10000);
}

function shooot()
{
shootable == true;
}

}

How do i make so that bullet removes when it touch the _root.Zombie?


13 Years old. I like Programming and making musics!

TheeCoffee
TheeCoffee
  • Member since: Aug. 12, 2011
  • Offline.
Forum Stats
Member
Level 07
Musician
Response to [as2] Bullet Collision With Zombie! 2012-08-04 05:13:14 Reply

Anyone? :(?


13 Years old. I like Programming and making musics!

TheeCoffee
TheeCoffee
  • Member since: Aug. 12, 2011
  • Offline.
Forum Stats
Member
Level 07
Musician
Response to [as2] Bullet Collision With Zombie! 2012-08-04 05:53:42 Reply

i think no one wants to help me :P


13 Years old. I like Programming and making musics!

doodle-bread14
doodle-bread14
  • Member since: Jul. 25, 2012
  • Offline.
Forum Stats
Member
Level 04
Programmer
Response to [as2] Bullet Collision With Zombie! 2012-08-04 06:02:28 Reply

Be patient. It's not a rush.


At least not a muffin.

BBS Signature
TheeCoffee
TheeCoffee
  • Member since: Aug. 12, 2011
  • Offline.
Forum Stats
Member
Level 07
Musician
Response to [as2] Bullet Collision With Zombie! 2012-08-04 06:10:03 Reply

At 8/4/12 06:02 AM, doodle-bread14 wrote: Be patient. It's not a rush.

I think you are the only one that replied ;)


13 Years old. I like Programming and making musics!

TheeCoffee
TheeCoffee
  • Member since: Aug. 12, 2011
  • Offline.
Forum Stats
Member
Level 07
Musician
Response to [as2] Bullet Collision With Zombie! 2012-08-04 07:03:15 Reply

At 8/4/12 06:10 AM, TheeCoffee wrote:
At 8/4/12 06:02 AM, doodle-bread14 wrote: Be patient. It's not a rush.
I think you are the only one that replied ;)

Waiting for an Answer :(...


13 Years old. I like Programming and making musics!

Barzona
Barzona
  • Member since: Jan. 4, 2009
  • Offline.
Forum Stats
Member
Level 13
Game Developer
Response to [as2] Bullet Collision With Zombie! 2012-08-04 09:32:34 Reply

At 8/4/12 07:03 AM, TheeCoffee wrote:
At 8/4/12 06:10 AM, TheeCoffee wrote:
At 8/4/12 06:02 AM, doodle-bread14 wrote: Be patient. It's not a rush.
I think you are the only one that replied ;)
Waiting for an Answer :(...

I don't think most people want to mess around with AS2 stuff. They prefer to deal with AS3 issues.

Truimagz
Truimagz
  • Member since: Feb. 3, 2007
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to [as2] Bullet Collision With Zombie! 2012-08-04 10:52:12 Reply

This is AS1, notice the onClipEvent

Just an FYI.

I'll look at it for a second though and see what's up

egg82
egg82
  • Member since: Jun. 24, 2006
  • Online!
Forum Stats
Supporter
Level 05
Game Developer
Response to [as2] Bullet Collision With Zombie! 2012-08-04 10:54:21 Reply

At 8/4/12 10:52 AM, Truimagz wrote: This is AS1, notice the onClipEvent

oh, dear god. Somebody get this man FD.

and thanks for helping, I already helped solve his last issue.


Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P

BBS Signature
TheeCoffee
TheeCoffee
  • Member since: Aug. 12, 2011
  • Offline.
Forum Stats
Member
Level 07
Musician
Response to [as2] Bullet Collision With Zombie! 2012-08-04 11:04:49 Reply

At 8/4/12 10:54 AM, egg82 wrote:
At 8/4/12 10:52 AM, Truimagz wrote: This is AS1, notice the onClipEvent
oh, dear god. Somebody get this man FD.

and thanks for helping, I already helped solve his last issue.

Thanks guys. i use AS1 & AS2. Both :P


13 Years old. I like Programming and making musics!

Truimagz
Truimagz
  • Member since: Feb. 3, 2007
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to [as2] Bullet Collision With Zombie! 2012-08-04 11:22:40 Reply

Here you, but please never paste code on clips again.

Add this to the frame where the clip is, but not on the actual clip.

var bulletsFired = 0;
var bulletSpeed = 30;


this.onMouseDown = function ( ) {
	
	
	_root.attachMovie("bullet", "bullet" + bulletsFired, _root.getNextHighestDepth(), {_x:_root.player._x, _y:_root.player._x});
	
	
	_root["bullet" + bulletsFired].xmov = Math.cos((Math.atan2(_root._ymouse - _y, _root._xmouse - _x)) * (180 / Math.PI) * (Math.PI / 180));
	_root["bullet" + bulletsFired].ymov = Math.sin((Math.atan2(_root._ymouse - _y, _root._xmouse - _x)) * (180 / Math.PI) * (Math.PI / 180));
	
	_root["bullet" + bulletsFired].xmov *= bulletSpeed;
	_root["bullet" + bulletsFired].ymov *= bulletSpeed;
	
	_root["bullet" + bulletsFired]._rotation = ((_root.player._rotation - 90) * Math.PI / 180);
		
	
	_root["bullet" + bulletsFired].onEnterFrame = function ( ) {
		
		
		this._x += this.xmov;
		this._y += this.ymov;
		
		this.hitTest(_root.zombie) ? this.removeMovieClip() : null;
		
		this._x > Stage.width ? this.removeMovieClip() : null;
		this._y > Stage.height ? this.removeMovieClip() : null;
		
		this._x < 0 ? this.removeMovieClip() : null;
		this._y < 0 ? this.removeMovieClip() : null;
		
		
	}
	
	
	bulletsFired++;
	

}
Truimagz
Truimagz
  • Member since: Feb. 3, 2007
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to [as2] Bullet Collision With Zombie! 2012-08-04 11:28:28 Reply

You'll have to fiddle with the rotation, I was rushed and it prolly wont work, not itme ot open flash and I havent written as1 in years

egg82
egg82
  • Member since: Jun. 24, 2006
  • Online!
Forum Stats
Supporter
Level 05
Game Developer
Response to [as2] Bullet Collision With Zombie! 2012-08-04 12:34:20 Reply

At 8/4/12 11:22 AM, Truimagz wrote: Here you, but please never paste code on clips again.

Add this to the frame where the clip is, but not on the actual clip.

well done, sir.

Though I might suggest that instead of using a hitTest, you should check to see if an enemy is along the path the bullet is taking. This will eliminate false negatives when dealing with hitting enemies with the bullet.

the reason for this is because when the bullet moves at 30 pixels per frame, there's an entire 30 pixel gap between the bullet's movement that an enemy can easily hide in.


Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P

BBS Signature