This commit is contained in:
2015-08-12 17:54:00 +03:00
parent 3eee4db51b
commit a37712136e
5 changed files with 96 additions and 28 deletions

View File

@@ -7,6 +7,8 @@ enum TankAction {
class Tank extends MobileEntity implements ITank {
private static var bulletIdCounter:Int = -1;
public var bullets:Array<IMobileEntity>;
public function new(id:Int, x:Float, y:Float) {
@@ -19,7 +21,7 @@ class Tank extends MobileEntity implements ITank {
public function shot():Void {
if (bullets.length >= 5) return;
var bullet = new MobileEntity(0, x + width / 2 - 5, y + height / 2 - 5, 6, direction);
var bullet = new MobileEntity(bulletIdCounter--, x + width / 2 - 5, y + height / 2 - 5, 6, direction);
bullet.width = 10;
bullet.height = 10;
bullet.move(direction);