-
Notifications
You must be signed in to change notification settings - Fork 186
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
Added Dodge the Blocks game #771
base: main
Are you sure you want to change the base?
Conversation
👋 Thank you for opening this pull request! We're excited to review your contribution. Please give us a moment, and we'll get back to you shortly! Feel free to join our community on Discord to discuss more! |
|
||
|
||
# Player movement | ||
handle_player_movement(event, player) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function handle_player_movement(event, player)
is called outside the event loop. Due to this only last event is repeating (i.e. Start of the game) and it crashes afterwards. Please update this and will merge once updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That won't work. When the handle_player_movement(event, player)
function is called inside the event loop, it only processes discrete events. Pygame doesn’t continuously repeat key events while a key is held down, but rather treats it as individual key presses that need to be handled explicitly.
So, what would happen if the function is called inside the event loop?
Continuing to press on an arrow key only moves it by one unit and then it stops. For example if i hold down the down arrow key then the player block moves one unit down and then stops. If i want to move further down, i have to lift up my finger and then press the down key again. This is annoying and not the desired functionality.
Why keep the function outside the event loop?
It keeps checking for the event in every frame, meaning it continually processes movement as long as the key is pressed, which is what you want for smooth movement. This is the desired functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do the requested changes
6a1fc16
to
331cbb0
Compare
Pull Request for PyVerse 💡
Requesting to submit a pull request to the PyVerse repository.
Issue Title
Please enter the title of the issue related to your pull request.
[Code Addition Request]: Add Game Development Project : Dodge the Blocks
Info about the Related Issue
What's the goal of the project?
To add a Dodge the Blocks game created in Python using Pygame.
Name
Please mention your name.
Rudra Jyotirmay
GitHub ID
Please mention your GitHub ID.
RudraJy
Email ID
Please mention your email ID for further communication.
[email protected]
Identify Yourself
Mention in which program you are contributing (e.g., WoB, GSSOC, SSOC, SWOC).
Contributor - Hacktoberfest 2024
Contributor - GSSOC 24 : Extended Edition
Closes
Enter the issue number that will be closed through this PR.
*Closes: #714
Describe the Add-ons or Changes You've Made
Give a clear description of what you have added or modified.
Added a game in the Game_Development folder.
Type of Change
Select the type of change:
How Has This Been Tested?
Describe how your changes have been tested.
Tested on my local system.
Checklist
Please confirm the following: