-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkey.js
More file actions
36 lines (27 loc) · 783 Bytes
/
key.js
File metadata and controls
36 lines (27 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
const { check } = require('./main');
const { skin } = require('./constants');
const { angry, happy } = require('./person');
const { fi } = require('./fi');
function mainsecond(deltaX, deltaY, per) {
fi[per.y][per.x] = skin.empty;
per.x += deltaX;
per.y += deltaY;
console.log(per.x,per.y)
check(per);
fi[per.y][per.x] = per.skin;
}
const moves = {
s: () => mainsecond(0, 1, angry), //по у вниз
a: () => mainsecond(-1, 0, angry),
d: () => mainsecond(1, 0, angry),
w: () => mainsecond(0, -1, angry),
down: () => mainsecond(0, 1, happy),
left: () => mainsecond(-1, 0, happy),
right: () => mainsecond(1, 0, happy),
up: () => mainsecond(0, -1, happy),
};
function main(k) {
moves[k]();
}
module.exports = { main };