Skip to content

Commit 1f3f96f

Browse files
committed
revert back to IsKeyDown for web
1 parent c8eca6c commit 1f3f96f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pufferlib/ocean/g2048/g2048.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ int main() {
2929

3030
if (IsKeyDown(KEY_LEFT_SHIFT)) {
3131
action = -1;
32-
if (IsKeyPressed(KEY_W) || IsKeyPressed(KEY_UP)) action = UP;
33-
else if (IsKeyPressed(KEY_S) || IsKeyPressed(KEY_DOWN)) action = DOWN;
34-
else if (IsKeyPressed(KEY_A) || IsKeyPressed(KEY_LEFT)) action = LEFT;
35-
else if (IsKeyPressed(KEY_D) || IsKeyPressed(KEY_RIGHT)) action = RIGHT;
32+
if (IsKeyDown(KEY_W) || IsKeyDown(KEY_UP)) action = UP;
33+
else if (IsKeyDown(KEY_S) || IsKeyDown(KEY_DOWN)) action = DOWN;
34+
else if (IsKeyDown(KEY_A) || IsKeyDown(KEY_LEFT)) action = LEFT;
35+
else if (IsKeyDown(KEY_D) || IsKeyDown(KEY_RIGHT)) action = RIGHT;
3636
env.actions[0] = action - 1;
3737
} else if (frame % 1 != 0) {
3838
continue;
@@ -47,7 +47,11 @@ int main() {
4747
if (action > 0) {
4848
c_step(&env);
4949
}
50-
50+
51+
if (IsKeyDown(KEY_LEFT_SHIFT) && action > 0) {
52+
// Don't need to be super reactive
53+
WaitTime(0.1);
54+
}
5155
}
5256

5357
free_linearlstm(net);

0 commit comments

Comments
 (0)