Flash Game Projectile Weapons

Tuesday, June 16th, 2009 | Game Engine, Game Examples AS2, Game Weapons

This is version 3 of my Flash game projectile weapons script. It is totally rewritten & optimized to support multiple weapons, multiple enemies & collision detection. All the functions are encapsulated for easy re-use.

Features:

Weapon

  • Number of bullets
  • Bullet speed
  • Bullet age
  • Reload speed

Weapon Management

  • Weapon Database
  • Weapon Database Search
  • Equip Weapon Function
  • Reload Weapon
  • Create Bullet
  • Update Bullet
  • Destroy Bullet

Enemy Management

  • Create enemy
  • Enemy Collision Detection with Bullets
  • Destroy Enemy
Download Fla Sample

Download Fla Sample


Tags: , , , , , , , , , , , , , , , ,

9 Comments to Flash Game Projectile Weapons

Werty2334
June 18, 2009

If you wish to have the bullet deleted when hitting the enemy, find “function checkEnemyHit” and under where it says “destroyEnemy(tempEnemy);” put this:
“destroyBullet(_bullet);”
(Everything without quotes)

mixedtrigeno
August 4, 2009

thanks this is really good stuff you got there
but i need help with something in the rotation part of it. this is the code i got so far
var radians2:Number = 180/Math.PI;
var maxAng:Number = 89;
var rSpeed:Number =10;
var playerX = player_mc._x;
var playerY = player_mc._y
//Rotate Player
function rotatePlayer(){

//calculate player_mc rotation, based on player position & mouse position
player_mc._rotation =Math.round(180 - (Math.atan2(_root._xmouse - playerX, _root._ymouse - playerY)*180/Math.PI));

//player_mc._rotation = rotationDirection;
if (player_mc._rotation > maxAng) {
player_mc._rotation = maxAng;
} else if (player_mc._rotation < -maxAng) {
player_mc._rotation = -maxAng;
updateAfterEvent();
}
}
now i need help with adding a lil more natural feel to it. i want to be able to add a rotation speed to decide how far the hero follows the mouse. hope i make sence

pradvan
August 5, 2009

mixedtrigeno, a script that does just that is in the works and is almost ready to be released.
I will try to clean it up and release as soon as I can.
Thanks

mixedtrigeno
August 5, 2009

oh great thanks ill keep checking out for it. i was trying to figure out why the rotation code in v3 doesnt work if the figure is not a circle…

StapledPuppet
August 7, 2009

I tried adding VERY SIMPLE movement to the script, yet it stops the rotational movement? Any ideas? I am a noob to this sorry. Just trying to learn:

this.onEnterFrame = function()
{
if (Key.isDown(Key.RIGHT))
{
player_mc._x += 10;
}
else if (Key.isDown(Key.LEFT))
{
player_mc._x -= 10;
}

else if (Key.isDown(Key.UP))
{
player_mc._y -= 10;
}

else if (Key.isDown(Key.DOWN))
{
player_mc._y += 10;
}
}

I am thinking it might have something to do with the very first line?

Zorbia
April 22, 2010

I love this site!! Spent absolutely ages looking around for a good site for some cool things for a game I am making and this finally comes along. xD

pradvan
May 1, 2010

Thanks Zorbia! Glad you like it :)
-Phil

Umbjabaya
May 27, 2010

I tried to get the enemies to move (which works), and have them move after they respawn (which doesn’t work). I combined the code from this script with the enemy following code. Please help, my grade in programming depends on it. :D

pradvan
May 27, 2010

Hi Umbjabaya, please post a link to your fla file. Maybe someone will be able to help…
-Phil

Leave a comment

You must be logged in to post a comment.