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

Changes in Control #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

techSaswata
Copy link

Problems Identified:
Inefficient Variable Management for keyPressedFlag:
keyPressedFlag is being set multiple times across different conditions, which can lead to inconsistent results.
Redundant Checks in the Rotation Logic:
The check for (dx === 0 && dy === 0) is redundant since it doesn't execute any code.
Handling keysPressed When Paused:
Clearing the keysPressed object in the game loop when paused can cause issues if keys are pressed before unpausing.
Inconsistent Use of needsRedraw Flag:
The flag needsRedraw is being set without checking whether the canvas needs a redraw for some operations.
Player Angle Handling is Cluttered:
The rotation update logic and player angle adjustment can be structured better for clarity.
Hardcoded Constants and Magic Numbers:
Using hardcoded values like 30 or 1.6 can make the code harder to maintain.
Redundant Update in moveRotateAndDash():
The function checks for dashing but doesn't properly separate logic for dashing vs. non-dashing states.

Changes Made with Explanations:
Consistent Use of Flags and State Management:
Added separate functions for toggling flight and handling direction updates to reduce redundancy.
Refactored the Dash Logic:
Separated dash state management for better readability.
Used dashTimeRemaining and dashCooldown variables to manage the timing.
Improved Key Handling:
Moved the key handling logic for toggleForward and rotation checks into their respective functions.
Updated Direction Calculation:
Simplified direction updates to avoid repeated code.
Consolidated the Game Loop Logic:
Grouped related operations together for a more organized flow.
Replaced Magic Numbers with Named Constants:
Created descriptive variables for hardcoded values to improve code readability and maintainability.

@Glowstick0017
Copy link
Owner

I'm not sure if you've tested this; when I try running this change, the plane does not move.

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

Successfully merging this pull request may close these issues.

2 participants