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

Refactor Player.cpp #3116

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

Refactor Player.cpp #3116

wants to merge 8 commits into from

Conversation

swagtoy
Copy link
Contributor

@swagtoy swagtoy commented Nov 29, 2024

About damn time.

Highlights:

  • Moved Player to MovingSprite, now you can use Squirrel Tux.set_sprite calls and have fun with that. Custom sprites are possible now. This was so easy to do it hurts.
  • Switch to state machine.

Main things on my bucketlist are refactoring the majority of state into either a) their own smaller classes, b) into more functions, and c) maybe bitwise state and/or std::bitset. The input code is kind of disgusting and could be set up some. State machinery stuff related to switching the players sprite likely has room for improvement. Update function is just putrid. Input/shooting/powerup code MIGHT be able to get refactored out of player, i'll see what I can do :)

Swagtoy added 2 commits November 29, 2024 03:51
This exposes some Squirrel methods such as set_sprite. Pretty fun.

Big tux is still jank but this may be somewhere in the file.
@MatusGuy
Copy link
Member

I think this pr is cool .

@weluvgoatz weluvgoatz marked this pull request as draft December 1, 2024 06:10
@swagtoy swagtoy changed the title [Draft] Refactor Player.cpp Refactor Player.cpp Dec 3, 2024
@swagtoy
Copy link
Contributor Author

swagtoy commented Dec 3, 2024

Unrelated note but kind of surprised git doesnt allow for true commit renaming in 2024 because "Oh no" was not a good commit message and force pushing is not a great decision

@swagtoy
Copy link
Contributor Author

swagtoy commented Dec 4, 2024

State machine code is done, though right now, MovingSprite has broken Tux's logic (still looking into why) but its likely due to disgusting jank code... but anyone is welcome to take a look at this right now and note any thoughts (overall code still sucks ass). You can use squirrel get_state() functionality now but I'm not sure if I should keep maintaining our 100 getters when we can just get the state and use an Enum/int now. Internally its std::vector<bool> btw instead of bitset

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