this repo has no description
1package;
2
3import flixel.FlxG;
4import flixel.FlxObject;
5import flixel.FlxSprite;
6import flixel.math.FlxPoint;
7import flixel.system.FlxAssets.FlxGraphicAsset;
8import flixel.util.FlxColor;
9
10/**
11 * ...
12 * @author ninjaMuffin
13 */
14class Bullet extends FlxSprite
15{
16 private var life:Float = 3;
17
18 public var speed:Float;
19 public var dir:Int;
20 public var damage:Float;
21
22 public function new(?X:Float = 0, ?Y:Float = 0, Speed:Float, Direction:Int, Damage:Float)
23 {
24 super(X, Y);
25
26 makeGraphic(32, 20);
27
28 speed = Speed;
29 dir = Direction;
30 damage = Damage;
31
32 velocity.y = FlxG.random.float(-25, 25);
33 }
34
35 override public function update(elapsed:Float):Void
36 {
37 super.update(elapsed);
38
39 if (dir == FlxObject.LEFT)
40 {
41 velocity.x = -speed;
42 }
43 if (dir == FlxObject.RIGHT)
44 {
45 velocity.x = speed;
46 }
47
48 life -= FlxG.elapsed;
49 if (life < 0)
50 {
51 kill();
52 }
53 }
54}