mirror of
https://github.com/He4eT/DotDashPit.git
synced 2026-05-05 01:47:22 +00:00
game: update hints
This commit is contained in:
parent
135fdb60b4
commit
eb67c7729e
1 changed files with 12 additions and 11 deletions
25
game.js
25
game.js
|
|
@ -11,6 +11,7 @@
|
||||||
/* Config */
|
/* Config */
|
||||||
|
|
||||||
const HISTORY_LENGTH = 14
|
const HISTORY_LENGTH = 14
|
||||||
|
const HINT_DISTANCE = 30
|
||||||
|
|
||||||
const morseCode = [
|
const morseCode = [
|
||||||
['A', ' .- '],
|
['A', ' .- '],
|
||||||
|
|
@ -581,21 +582,22 @@ function drawEnemyLetters() {
|
||||||
|
|
||||||
const screenPos = worldToScreen(letterPos)
|
const screenPos = worldToScreen(letterPos)
|
||||||
|
|
||||||
rectb(screenPos.x - 4, screenPos.y - 5, 10, 11, 4)
|
|
||||||
rect(screenPos.x - 4, screenPos.y - 5, 10, 11, 2)
|
rect(screenPos.x - 4, screenPos.y - 5, 10, 11, 2)
|
||||||
font(enemy.letter, screenPos.x - 3, screenPos.y - 3, 0, 8, 8, true)
|
font(enemy.letter, screenPos.x - 3, screenPos.y - 3, 0, 8, 8, true)
|
||||||
|
rectb(screenPos.x - 4, screenPos.y - 5, 10, 11, 4)
|
||||||
|
|
||||||
if (
|
if (getDistance(player.position, enemy.positions[0]) < HINT_DISTANCE) {
|
||||||
getDistance(player.position, enemy.positions[0]) <
|
|
||||||
enemy.dangerZone * 3
|
|
||||||
) {
|
|
||||||
const hintWidth = 16
|
|
||||||
const hintPosition = {
|
|
||||||
x: screenPos.x - 7,
|
|
||||||
y: screenPos.y + 9,
|
|
||||||
}
|
|
||||||
rect(hintPosition.x, hintPosition.y, hintWidth, 2, 3)
|
|
||||||
const code = letterToMorse[enemy.letter]
|
const code = letterToMorse[enemy.letter]
|
||||||
|
|
||||||
|
const hintWidth =
|
||||||
|
1 + code.split('').reduce((acc, x) => acc + { '.': 2, '-': 4 }[x], 0)
|
||||||
|
|
||||||
|
const hintPosition = {
|
||||||
|
x: screenPos.x - 4,
|
||||||
|
y: screenPos.y + 8,
|
||||||
|
}
|
||||||
|
|
||||||
|
rect(hintPosition.x, hintPosition.y - 1, Math.max(10, hintWidth), 3, 4)
|
||||||
drawMorse(code, hintPosition.x, hintPosition.y, 2, hintWidth)
|
drawMorse(code, hintPosition.x, hintPosition.y, 2, hintWidth)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -983,4 +985,3 @@ const BTN_Y = 7
|
||||||
// <PALETTE>
|
// <PALETTE>
|
||||||
// 000:000000002b3607364221292c586e75657b83839496ffffffb58900cb4b16dc322fd336826c71c4268bd22aa198859900
|
// 000:000000002b3607364221292c586e75657b83839496ffffffb58900cb4b16dc322fd336826c71c4268bd22aa198859900
|
||||||
// </PALETTE>
|
// </PALETTE>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue