This repository has been archived on 2024-02-25. You can view files and clone it, but cannot push or open issues or pull requests.
spaaace/src/Bullet.hx

45 lines
737 B
Haxe
Raw Normal View History

2014-07-05 17:00:35 +02:00
import com.haxepunk.Entity;
import com.haxepunk.graphics.Image;
import com.haxepunk.HXP;
class Bullet extends Entity {
public function new(x:Float, y:Float) {
super(x, y);
laser1 = new Image("graphics/laserGreen09.png");
laser2 = new Image("graphics/laserGreen13.png");
graphic = laser1;
setHitbox(9, 37);
type = "bullet";
}
public override function update() {
super.update();
this.y -= 20;
2014-07-05 17:00:35 +02:00
timer -= HXP.elapsed;
if (collide("asteroid", this.x, this.y) != null) {
this.scene.remove(this);
}
if (timer < 0 || this.y < 200) {
graphic = laser2;
}
if (this.y < 0) {
this.scene.remove(this);
}
}
private var laser1:Image;
private var laser2:Image;
private var timer:Float = .5;
}