-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetinput
More file actions
39 lines (38 loc) · 769 Bytes
/
getinput
File metadata and controls
39 lines (38 loc) · 769 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
36
37
38
39
function collision(u, s) {
//collsion chcks if spite is toching anything
u.collide(rightEdge);
u.collide(leftEdge);
u.collide(bottomEdge);
u.collide(topEdge);
if (u.isTouching(s)) {
u.bounceOff(s);
}
}
function move(u) {
//Keybord controlls take a input and applys/removes velocity
if (keyDown("w")) {
u.velocityY = -5;
}
if (keyWentUp("w")) {
u.velocityY = 0;
}
if (keyDown("s")) {
u.velocityY = 5;
}
if (keyWentUp("s")) {
u.velocityY = 0;
}
if (keyDown("a")) {
u.velocityX = -5;
}
if (keyWentUp("a")) {
u.velocityX = 0;
}
if (keyDown("d")) {
u.velocityX = 5;
}
if (keyWentUp("d")) {
u.velocityX = 0;
}
// collision is called to test if its touching anthing
}