Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

key press event listeners are not cleared after running code, will trigger multiple times if you run code multiple times #38

Open
nvarughese opened this issue May 31, 2024 · 0 comments

Comments

@nvarughese
Copy link

When you run the code a second or third time key press events will trigger a second or third time.

To see the bug go to the example https://petlja.github.io/pygame4skulpt/

Run the snake printing to show a keypress, the second time you run snake, you will see multiple prints for each key press

if e.type == pg.KEYDOWN:
if game_running == 0:
game_runnig = 1
if e.key == pg.K_SPACE:
game_running = 0
snake = [(7, 3), (7, 4)]
direction = 0
apple = place_apple()
for i in range(4):
if e.key == dirs[i] and direction != (i + 2) % 4:
direction = i
print direction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant