sugarlabs / flappy

A python-pygame Flappy Bird clone
GNU General Public License v3.0
2 stars 12 forks source link

Keys are missed #21

Closed quozl closed 1 year ago

quozl commented 4 years ago

Some key press events are not handled.

Reproduce by setting clock.tick(10) near line 180 of main.py and taking careful note of when the key press events cause vertical acceleration.

ayushnawal commented 4 years ago

What I understood from this issue is due to high fps(frames per second) rate, key press events are not handled properly, so reducing the fps rate can fix this. But are there any other key press events or anything else which needs to be taken care of.

Sorry but actually I got this doubt because I was not able to completely understand this line taking careful note of when the key press events cause vertical acceleration.

quozl commented 4 years ago

What I understood from this issue is due to high fps(frames per second) rate,

No, the issue is most easily reproduced if the FPS is reduced from 60 to 10, because to reproduce it depends on observation.

key press events are not handled properly, so reducing the fps rate can fix this.

I don't see how that follows.

But are there any other key press events or anything else which needs to be taken care of.

I don't understand the question.

Sorry but actually I got this doubt because I was not able to completely understand this line taking careful note of when the key press events cause vertical acceleration.

Some key press events did not cause vertical acceleration.

I've not checked, but this may be an instance of one of the projects we have at Sugar Labs;

https://github.com/orgs/sugarlabs/projects/6 On some recent versions of SDL, double-clicks are rendered as extra MOUSEBUTTONDOWN events with a clicks value greater than one. PyGame does not receive or handle the value. Some activities use MOUSEBUTTONDOWN alone to implement user interface buttons in PyGame. To maximise the supported configurations of PyGame and SDL, buttons should arm on MOUSEBUTTONDOWN, and activate on MOUSEBUTTONUP provided the mouse coordinates remain within the button.

Not enough coffee error. It's not a mouse event.

quozl commented 4 years ago

I am filled with regret. I reported the issue so I wouldn't have to find and fix the problem. But I have looked at the source code and figured out what is happeningl

In the main game loop, main.py, while not crashed;

chimosky commented 1 year ago

Closing as issue has been transferred.

Dimi20cen commented 1 year ago

The two things that quozl found to be the cause of the issue, are not present in flappy's code.

In the main game loop, main.py, while not crashed;

there are two places that events are dequeued from PyGame, but there should only be one (because if a key press event is dequeued by the second call to pygame.event.get, it will be lost), there for loop structure in the first dequeue checks each event against QUIT, and then exits the loop; and the check for KEYDOWN and KEYUP events is only applied to the last event processed by the for loop; instead all events should be processed instead of being ignored.