Skip to content

Commit 49de297

Browse files
committed
another small fix so you can't spam that easily by holding the button
1 parent 5d62659 commit 49de297

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pufferlib/ocean/g2048/g2048.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ int main() {
2222

2323
// Main game loop
2424
int frame = 0;
25+
int action = -1;
2526
while (!WindowShouldClose()) {
2627
c_render(&env);
2728
frame++;
28-
29-
int action = -1;
29+
3030
if (IsKeyDown(KEY_LEFT_SHIFT)) {
31+
action = -1;
3132
if (IsKeyDown(KEY_W) || IsKeyDown(KEY_UP)) action = UP;
3233
else if (IsKeyDown(KEY_S) || IsKeyDown(KEY_DOWN)) action = DOWN;
3334
else if (IsKeyDown(KEY_A) || IsKeyDown(KEY_LEFT)) action = LEFT;
@@ -43,14 +44,15 @@ int main() {
4344
forward_linearlstm(net, net->obs, env.actions);
4445
}
4546

46-
if (action >= 0) {
47+
if (action > 0) {
4748
c_step(&env);
4849
}
4950

50-
if (IsKeyDown(KEY_LEFT_SHIFT) && action >= 0) {
51-
WaitTime(0.01);
51+
if (IsKeyDown(KEY_LEFT_SHIFT) && action > 0) {
52+
WaitTime(0.05);
5253
}
5354

55+
5456
}
5557

5658
free_linearlstm(net);

0 commit comments

Comments
 (0)