mirror of
https://github.com/osmarks/website
synced 2024-11-08 12:19:54 +00:00
Fix Emu War bound check bug
This commit is contained in:
parent
ffb7ab02d2
commit
5bb3300cdb
@ -14,12 +14,11 @@ description: Survive as long as possible against emus and other wildlife. Contri
|
||||
|
||||
<div>
|
||||
<button onclick="lastIns='r';mainLoop()">←</button>
|
||||
<div style="display: inline-block"</div>
|
||||
<button onclick="lastIns='u';mainLoop()">↑</button>
|
||||
<button onclick="lastIns='d';mainLoop()">↓</button>
|
||||
</div>
|
||||
<button onclick="lastIns='l';mainLoop()">→</button>
|
||||
</div>
|
||||
<input type="checkbox" id="legacy-mode"><label>Legacy bounds checking mode</label>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
@ -279,6 +278,8 @@ const attack = (enemy_index) => {
|
||||
}
|
||||
}
|
||||
|
||||
const legacyMode = () => document.getElementById("legacy-mode").checked
|
||||
|
||||
const handleInput = (ins) => {
|
||||
let lookX = x
|
||||
let lookY = y
|
||||
@ -293,7 +294,7 @@ const handleInput = (ins) => {
|
||||
}
|
||||
|
||||
lookX = clamp(lookX, WIDTH-1, 0)
|
||||
lookY = clamp(lookY, WIDTH-1, 0)
|
||||
lookY = clamp(lookY, (legacyMode() ? WIDTH : HEIGHT) - 1, 0)
|
||||
|
||||
let id = getEnemy(lookX, lookY)
|
||||
if (id == -1) {
|
||||
|
Loading…
Reference in New Issue
Block a user