Merge pull request #5 from Tsa6/fix-enemy-alignment
Fix enemy alignment
This commit is contained in:
commit
b6736c4da0
8
index.js
8
index.js
@ -1027,11 +1027,13 @@ window.onload = function () {
|
|||||||
|
|
||||||
// Draw enemies
|
// Draw enemies
|
||||||
for (let i in Game.enemies) {
|
for (let i in Game.enemies) {
|
||||||
|
let margin = .25 //A ratio of the width of a tile. .25 margins with 32 px tiles leave a 8 px margin on all sides, with the body being 16px x 16px
|
||||||
let enemy = Game.enemies[i]
|
let enemy = Game.enemies[i]
|
||||||
let rx = (enemy.x * mt) + mt / 8
|
let rx = (enemy.x + margin) * mt
|
||||||
let ry = (enemy.y * mt) + mt / 8
|
let ry = (enemy.y + margin) * mt
|
||||||
|
let w = mt * (1 - margin * 2)
|
||||||
ctx.fillStyle = enemy.icon
|
ctx.fillStyle = enemy.icon
|
||||||
ctx.fillRect(rx, ry, 16, 16)
|
ctx.fillRect(rx, ry, w, w)
|
||||||
|
|
||||||
// health bars
|
// health bars
|
||||||
let hx = rx - 6
|
let hx = rx - 6
|
||||||
|
Loading…
Reference in New Issue
Block a user