update
This commit is contained in:
@@ -31,6 +31,7 @@ class NekoConnection extends BaseConnection {
|
||||
socket.output.write(bytes);
|
||||
socket.output.flush();
|
||||
} catch (e:Dynamic) {
|
||||
trace("Error send packet: " + packet);
|
||||
trace(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ typedef TankzConfig = {
|
||||
class DEFAULT {
|
||||
public static var CONFIG:TankzConfig = {
|
||||
map: {
|
||||
cellWidth: 20,
|
||||
cellHeight: 20,
|
||||
cellWidth: 22,
|
||||
cellHeight: 22,
|
||||
gridWidth: 26,
|
||||
gridHeight: 26
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ class Bullet extends MobileEntity {
|
||||
public function new(personId:Int, id:Int, x:Float, y:Float, speed:Float, direction:Direction) {
|
||||
super(id, x, y, speed, direction);
|
||||
this.personId = personId;
|
||||
this.width = 10;
|
||||
this.height = 10;
|
||||
this.width = 12;
|
||||
this.height = 12;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class Direction {
|
||||
public var x(default, null):Int;
|
||||
public var y(default, null):Int;
|
||||
|
||||
public function new(x, y) {
|
||||
private function new(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
directions.set(x + y * 10, this);
|
||||
@@ -22,4 +22,8 @@ class Direction {
|
||||
public function reverse():Direction {
|
||||
return directions.get(-x + (-y) * 10);
|
||||
}
|
||||
|
||||
public static function from(x:Int, y:Int):Direction {
|
||||
return directions.get(x + y * 10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ class Tank extends MobileEntity {
|
||||
public function new(personId:Int, id:Int, x:Float, y:Float, direction:Direction) {
|
||||
super(id, x, y, 4, direction);
|
||||
this.personId = personId;
|
||||
width = 34;
|
||||
height = 34;
|
||||
width = 36;
|
||||
height = 36;
|
||||
}
|
||||
|
||||
public function shot():Null<Bullet> {
|
||||
|
||||
@@ -71,18 +71,18 @@ class Engine implements IEngine {
|
||||
case GameChangeType.APPEND:
|
||||
switch (change.objectType) {
|
||||
case GameObjectType.TANK:
|
||||
var tank:Tank = buildTank(change.personId, change.objectId, change.x, change.y, new Direction(change.directionY, change.directionY));
|
||||
var tank:Tank = buildTank(change.personId, change.objectId, change.x, change.y, Direction.from(change.directionY, change.directionY));
|
||||
mobileEntities.set(tank.id, tank);
|
||||
tanks.set(tank.personId, tank);
|
||||
case GameObjectType.BULLET:
|
||||
var bullet:Bullet = new Bullet(change.personId, change.objectId, change.x, change.y, 0, new Direction(change.directionY, change.directionY));
|
||||
var bullet:Bullet = new Bullet(change.personId, change.objectId, change.x, change.y, 0, Direction.from(change.directionY, change.directionY));
|
||||
mobileEntities.set(bullet.id, bullet);
|
||||
}
|
||||
case GameChangeType.DESTROED:
|
||||
mobileEntities.remove(change.objectId);
|
||||
case GameChangeType.DIRECTION:
|
||||
var target = mobileEntities.get(change.objectId);
|
||||
target.direction = new Direction(change.directionX, change.directionY);
|
||||
target.direction = Direction.from(change.directionX, change.directionY);
|
||||
case GameChangeType.MOVED:
|
||||
var target = mobileEntities.get(change.objectId);
|
||||
target.x = change.x;
|
||||
|
||||
Reference in New Issue
Block a user