[common] engine fix
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
package ru.m.connect.js;
|
package ru.m.connect.js;
|
||||||
|
|
||||||
import ru.m.core.Base64;
|
import ru.m.Base64;
|
||||||
import ru.m.connect.IConnection.IConnectionHandler;
|
import ru.m.connect.IConnection.IConnectionHandler;
|
||||||
import protohx.Message;
|
import protohx.Message;
|
||||||
import haxe.io.Bytes;
|
import haxe.io.Bytes;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class Engine implements IEngine {
|
|||||||
private var y_limit:Float;
|
private var y_limit:Float;
|
||||||
|
|
||||||
private var playerTanks(default, null):Map<Int, Tank>;
|
private var playerTanks(default, null):Map<Int, Tank>;
|
||||||
|
private var time:Float;
|
||||||
|
|
||||||
public function new() {}
|
public function new() {}
|
||||||
|
|
||||||
@@ -55,6 +56,7 @@ class Engine implements IEngine {
|
|||||||
removedEntities = new Array<String>();
|
removedEntities = new Array<String>();
|
||||||
x_limit = map.gridWidth * map.cellWidth;
|
x_limit = map.gridWidth * map.cellWidth;
|
||||||
y_limit = map.gridHeight * map.cellHeight;
|
y_limit = map.gridHeight * map.cellHeight;
|
||||||
|
time = Date.now().getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initTanks(players:Array<Player>):Array<GameChange> {
|
public function initTanks(players:Array<Player>):Array<GameChange> {
|
||||||
@@ -145,6 +147,10 @@ class Engine implements IEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function update():Array<GameChange> {
|
public function update():Array<GameChange> {
|
||||||
|
var newTime:Float = Date.now().getTime();
|
||||||
|
var d:Float = newTime - time;
|
||||||
|
time = newTime;
|
||||||
|
|
||||||
var changes = new Array<GameChange>();
|
var changes = new Array<GameChange>();
|
||||||
|
|
||||||
for (ent in entities) if (Std.is(ent, IMobileEntity)) {
|
for (ent in entities) if (Std.is(ent, IMobileEntity)) {
|
||||||
@@ -164,8 +170,8 @@ class Engine implements IEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (entity.mx != 0 || entity.my != 0) {
|
if (entity.mx != 0 || entity.my != 0) {
|
||||||
entity.rect.x += entity.mx;
|
entity.rect.x += entity.mx * (d / 30);
|
||||||
entity.rect.y += entity.my;
|
entity.rect.y += entity.my * (d / 30);
|
||||||
var bricks = getBricks(entity);
|
var bricks = getBricks(entity);
|
||||||
|
|
||||||
if (objectType == GameObjectType.TANK) {
|
if (objectType == GameObjectType.TANK) {
|
||||||
|
|||||||
Reference in New Issue
Block a user