Author Topic: Additions to Flixel Power Tools, regarding weapons and bullets.  (Read 1975 times)


  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.

Since my game is combat heavy and I'm using great Flixel Power Tools, I usually encounter places and add things here and thee to it. So I thought sharing my additions, even they are not much, maybe it will help someone like me in the future or ideally will help the FPT in any way and if we are lucky, photonstorm will see this topic and show us if there is a better way to do these things, utilizing current stuff in FPT.

In this post I will demonstrate how I added damage and facing to each bullet so each weapon can have it's own damage and in later posts I will talk about magazine/clip.

1) Add
Code: [Select]
public var power:uint = 1; to class properties.
2) add change the constructor to:
Code: [Select]
public function Bullet(weapon:FlxWeapon, id:uint, power:uint = 1 )(since the last parameter is optional, doing so will not cause problem with your existing code)
3) Add 
Code: [Select]
facing = Registry.player.Aim; to fire().
4) Since we don't want to change scope of weapon, add this:
Code: [Select]
public function get Weapon():FlxWeapon
return weapon;
5) Add this to the bullet's constructor:
Code: [Select]
this.power = weapon.FirePower;
In the FlxWeapon:
1) Add this to class properties:
Code: [Select]
public var FirePower:uint = 1;
Now when you inherit from FlxWeapon, set your desired FirePower to whatever you like and most important thing is you have to set it before calling makeImageBullet because makeImageBullet will utilize it.

So whenever you want, for example, "hurt" someone/something, you can use
Code: [Select]
bullet.power to determine the power of that bullet.

Same approach goes to facing.

blog, twitter, Check out my award winning game, Rot Gut: