Skip to content
Browse files

Issue #14 one more issue from the stupid rebase

  • Loading branch information...
1 parent 58cf6a3 commit 8ba9e065183e3cdd6b8879ea050107f10c2f94cf @codeimpossible codeimpossible committed
Showing with 19 additions and 1 deletion.
  1. +19 −1 src/scripts/modules/engine.util.js
View
20 src/scripts/modules/engine.util.js
@@ -30,6 +30,24 @@ define(function() {
propability: function (factor) {
var randomNumber = Math.floor(Math.random() * 100);
return (randomNumber < factor * 100);
- }
+ },
+ translatePosition: function(canvas, tileSize, row, col, entity) {
+ var pos = {
+ x: ((row - col) * tileSize.height) + Math.floor((canvas.width / 2) - (tileSize.width / 2)),
+ y: Math.floor( (row + col) * (tileSize.height / 2) )
+ };
+
+ if (entity) {
+ if (entity.width != tileSize.width) {
+ pos.x += tileSize.width / 2 - entity.width / 2;
+ }
+
+ if (entity.height != tileSize.height) {
+ pos.y -= entity.height - tileSize.height / 2;
+ }
+ }
+
+ return pos;
+ },
}
});

0 comments on commit 8ba9e06

Please sign in to comment.
Something went wrong with that request. Please try again.