feat(js): m09 input, app, runtime, browser, main, index.html and smoke test
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
584f1d4825
commit
8028bb2fc0
@@ -0,0 +1,12 @@
|
||||
import { Action } from './model.js'
|
||||
|
||||
// Key name (as in KeyboardEvent.key) -> direction. A lookup table keeps keyToAction a one-liner.
|
||||
const directions = {
|
||||
ArrowUp: 'Up', w: 'Up', W: 'Up',
|
||||
ArrowDown: 'Down', s: 'Down', S: 'Down',
|
||||
ArrowLeft: 'Left', a: 'Left', A: 'Left',
|
||||
ArrowRight: 'Right', d: 'Right', D: 'Right',
|
||||
}
|
||||
|
||||
export const keyToAction = (key) =>
|
||||
Object.hasOwn(directions, key) ? Action.Turn(directions[key]) : null
|
||||
Reference in New Issue
Block a user