From 70cf1b0f1d10b97e2ce7859a383688dbbb5b6a37 Mon Sep 17 00:00:00 2001 From: shmyga Date: Sun, 7 Jan 2018 21:16:15 +0300 Subject: [PATCH] [common] engine fix --- src/common/haxe/ru/m/connect/js/JsConnection.hx | 2 +- src/common/haxe/ru/m/tankz/engine/Engine.hx | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/common/haxe/ru/m/connect/js/JsConnection.hx b/src/common/haxe/ru/m/connect/js/JsConnection.hx index 4cb165e..82e357a 100644 --- a/src/common/haxe/ru/m/connect/js/JsConnection.hx +++ b/src/common/haxe/ru/m/connect/js/JsConnection.hx @@ -1,6 +1,6 @@ package ru.m.connect.js; -import ru.m.core.Base64; +import ru.m.Base64; import ru.m.connect.IConnection.IConnectionHandler; import protohx.Message; import haxe.io.Bytes; diff --git a/src/common/haxe/ru/m/tankz/engine/Engine.hx b/src/common/haxe/ru/m/tankz/engine/Engine.hx index 13535a8..10b72f8 100755 --- a/src/common/haxe/ru/m/tankz/engine/Engine.hx +++ b/src/common/haxe/ru/m/tankz/engine/Engine.hx @@ -36,6 +36,7 @@ class Engine implements IEngine { private var y_limit:Float; private var playerTanks(default, null):Map; + private var time:Float; public function new() {} @@ -55,6 +56,7 @@ class Engine implements IEngine { removedEntities = new Array(); x_limit = map.gridWidth * map.cellWidth; y_limit = map.gridHeight * map.cellHeight; + time = Date.now().getTime(); } public function initTanks(players:Array):Array { @@ -145,6 +147,10 @@ class Engine implements IEngine { } public function update():Array { + var newTime:Float = Date.now().getTime(); + var d:Float = newTime - time; + time = newTime; + var changes = new Array(); for (ent in entities) if (Std.is(ent, IMobileEntity)) { @@ -164,8 +170,8 @@ class Engine implements IEngine { } if (entity.mx != 0 || entity.my != 0) { - entity.rect.x += entity.mx; - entity.rect.y += entity.my; + entity.rect.x += entity.mx * (d / 30); + entity.rect.y += entity.my * (d / 30); var bricks = getBricks(entity); if (objectType == GameObjectType.TANK) {