mirror of
https://github.com/He4eT/DotDashPit.git
synced 2026-05-04 17:37:23 +00:00
game: draw hints
This commit is contained in:
parent
0f2fba693f
commit
dd0e24288c
1 changed files with 22 additions and 3 deletions
25
game.js
25
game.js
|
|
@ -497,6 +497,25 @@ function drawLetters() {
|
||||||
rect(screenPos.x - 7, screenPos.y - 7, 16, 16, 4)
|
rect(screenPos.x - 7, screenPos.y - 7, 16, 16, 4)
|
||||||
rectb(screenPos.x - 7, screenPos.y - 7, 16, 16, 3)
|
rectb(screenPos.x - 7, screenPos.y - 7, 16, 16, 3)
|
||||||
print(enemy.letter, screenPos.x - 4, screenPos.y - 4, 2, false, 2)
|
print(enemy.letter, screenPos.x - 4, screenPos.y - 4, 2, false, 2)
|
||||||
|
|
||||||
|
drawHint(enemy.letter, screenPos.x - 7, screenPos.y + 9)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawHint(letter, x, y) {
|
||||||
|
const code = letterToMorse[letter].split('')
|
||||||
|
const l = code.reduce((acc, c) => acc + (c === '-' ? 4 : 2), 0)
|
||||||
|
let offset = x + (8 - Math.floor((l - 1) / 2)) - 1
|
||||||
|
|
||||||
|
rect(x, y, 16, 2, 3)
|
||||||
|
code.forEach((c) => {
|
||||||
|
if (c === '-') {
|
||||||
|
rect(offset, y, 3, 1, 2)
|
||||||
|
offset += 4
|
||||||
|
} else {
|
||||||
|
rect(offset, y, 1, 1, 2)
|
||||||
|
offset += 2
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -584,10 +603,10 @@ function getDirection(from, to) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function arenaToScreen ({ x, y }) {
|
function arenaToScreen({ x, y }) {
|
||||||
return {
|
return {
|
||||||
x: x + arena.screenPosition.x,
|
x: Math.floor(x + arena.screenPosition.x),
|
||||||
y: y + arena.screenPosition.y,
|
y: Math.floor(y + arena.screenPosition.y),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue