Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- document.addEventListener('keydown', (ev) => {
- const dung = Game.Dungeons[3];
- const move = (x, y) => {
- dung.hero.Move(x, y)
- event.preventDefault();
- dung.timer = Game.fps * 10;
- dung.timerWarmup = 5;
- }
- const keyList = {
- "w": () => move(0, -1),
- "s": () => move(0, 1),
- "a": () => move(-1, 0),
- "d": () => move(1, 0),
- " ": () => move(0, 0),
- "q": () => {
- dung.auto = !dung.auto
- if (dung.auto) {
- dung.timerWarmup = -1;
- } else {
- dung.timer = 0;
- dung.timerWarmup = 0;
- }
- }
- }
- if (ev.key in keyList)
- keyList[ev.key]()
- })
Advertisement
Add Comment
Please, Sign In to add comment