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

Reorganize platformer example for readability #329

Merged
merged 6 commits into from
Aug 12, 2024

Conversation

Koopa1018
Copy link
Contributor

@Koopa1018 Koopa1018 commented Jul 22, 2024

The components and systems in the platformer example are confusingly sorted: components are stored in a separate file from the systems that use them, and within those files the components & systems are jumbled chaotically with little rhyme or reason. In a crate example this complex, this organization scheme makes understanding the code a real challenge (which is a major reason I couldn't update this example in #294).

This PR reorganizes the platformer example into modules sorted roughly by "part of the game" or "game system" (camera system, climbing, inventory, etc.). Each module contains both the components and ECS systems specific to that part, to present a complete picture of what the game system does and how it works.

No game logic has been changed. This PR focuses purely on code quality.

THIS. EXAMPLE. IS. A MESS! How can anyone learn from a haphazard jumble like this? It's like grabbing an armful of notes from a physicist's desk and calling it a textbook....

Anyway. I need to be able to sort through this, so I just decided to go ape. No logic was changed--it's just organized intuitively now.
Copy link
Owner

@Trouv Trouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR, much appreciated.

This really highlights how bloated and unfocused this example has become over the years. It's definitely overdue for some refactoring and this is great start.

I just have one non-NIT about the ladder registration, assuming CI passes

examples/platformer/physics.rs Outdated Show resolved Hide resolved
examples/platformer/inventory.rs Show resolved Hide resolved
examples/platformer/main.rs Outdated Show resolved Hide resolved
examples/platformer/main.rs Outdated Show resolved Hide resolved
@Trouv
Copy link
Owner

Trouv commented Aug 9, 2024

Clippy job should be fixed after #331

If we're consolidating related logic, it really does make sense to put all wall-related logic in a plugin.
Only there's an existing plugin for the climbing system.
Because that's all that's left after "ground_detection" is split off. (Also technically there's no physics calculations being done here.)
@Koopa1018
Copy link
Contributor Author

Alright, changes complete.

@Trouv Trouv merged commit f59e5e5 into Trouv:main Aug 12, 2024
5 checks passed
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