update
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user