[common] player tank levels
This commit is contained in:
@@ -6,12 +6,14 @@ class Rectangle {
|
||||
public var width(default, default):Float;
|
||||
public var height(default, default):Float;
|
||||
public var center(get, set):Point;
|
||||
public var direction(default, set):Direction;
|
||||
|
||||
public function new(x:Float, y:Float, width:Float, height:Float) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.direction = Direction.RIGHT;
|
||||
}
|
||||
|
||||
private function get_center():Point {
|
||||
@@ -28,4 +30,17 @@ class Rectangle {
|
||||
return center.add(new Point(direction.x * width / 2, direction.y * height / 2));
|
||||
}
|
||||
|
||||
public function set_direction(value:Direction):Direction {
|
||||
if (direction != value) {
|
||||
if (direction != null && direction.x * value.x == 0 && direction.y * value.y == 0) {
|
||||
var w = width;
|
||||
var h = height;
|
||||
width = h;
|
||||
height = w;
|
||||
}
|
||||
direction = value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user