13 lines
386 B
Fennel
13 lines
386 B
Fennel
(fn dir-from-key [keymap]
|
|
(var (dx dy) (values 0 0))
|
|
(when (love.keyboard.isDown keymap.up) (set dy -1))
|
|
(when (love.keyboard.isDown keymap.down) (set dy 1))
|
|
(when (love.keyboard.isDown keymap.left) (set dx -1))
|
|
(when (love.keyboard.isDown keymap.right) (set dx 1))
|
|
[dx dy])
|
|
|
|
(fn vec* [vec scalar]
|
|
(icollect [_ v (ipairs vec)] (* v scalar)))
|
|
|
|
{: dir-from-key : vec*}
|