Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
The firing feature of the game is not working properly, so I fix this issue, now every time the space bar clicked firing feature will work.
Fixes #143
Alien.Invasion.Defense.-.Personal.-.Microsoft_.Edge.2024-10-08.12-13-44.1.1.1.mp4
Everytime we hit the space bar the firing feature is working
Type of change
How should this be tested?
Mandatory Tasks
In this PR, I have enhanced the firing mechanics of the player by implementing a mouse click-based firing system. Below is a breakdown of the improvements made and the rationale behind them:
Changes Implemented:
Improving Firing Feature:
Previously, bullets not fired using the keyboard (spacebar). I have changed a feature which will able to firing the bullet everytime I hit the space bar.
The fireBullet() function now accepts mouse coordinates to determine the trajectory, adding more flexibility to the gameplay.
The Bullet class was updated to accept and change bullet speed.
Game Balance and Speed Adjustments:
To ensure that the new firing system does not overpower the player, bullet speed and other gameplay dynamics were tweaked for balance.
Self-Review:
Functionality: Tested the click-based firing mechanism thoroughly. Bullets are fired accurately on click, and there are no noticeable bugs or glitches.
Code Quality: The event handling is efficient and lightweight, with no performance issues or unnecessary computation.
Readability: The code follows standard practices, is well-commented, and uses meaningful variable names. Functions are modular, which improves readability and maintainability.
Testing: Verified the changes on different screen sizes to ensure the bullet direction calculation is consistent, even when the canvas size changes.
These improvements significantly enhance the player experience by introducing a more dynamic and skill-based firing system.