From 2eb606aa21d846edbe5974da20e096952b0d226a Mon Sep 17 00:00:00 2001 From: shmyga Date: Thu, 28 Mar 2019 12:18:40 +0300 Subject: [PATCH] [engine] fix tank position --- src/common/haxe/ru/m/tankz/engine/Engine.hx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/common/haxe/ru/m/tankz/engine/Engine.hx b/src/common/haxe/ru/m/tankz/engine/Engine.hx index a7d4df2..6aca60d 100755 --- a/src/common/haxe/ru/m/tankz/engine/Engine.hx +++ b/src/common/haxe/ru/m/tankz/engine/Engine.hx @@ -231,6 +231,16 @@ class Engine extends EngineDispatcher implements ControlHandler { var with = EntityTypeResolver.of(cell); collisionSignal.emit(entityType, with); isStop = true; + // fix position + if (cells.length == 1) { + if (entity.mx != 0) { + var d = entity.rect.center.y - cell.rect.center.y; + entity.rect.y += d / Math.abs(d); + } else if (entity.my != 0) { + var d = entity.rect.center.x - cell.rect.center.x; + entity.rect.x += d / Math.abs(d); + } + } break; } }