-
Notifications
You must be signed in to change notification settings - Fork 4
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
add a skeleton for the FSM, the basic architecture. #89
base: main
Are you sure you want to change the base?
Conversation
Also, i think the codebase is somewhat messy, maybe we could remove CLI and rename GUI to game or something generic like that. There is so much stuff everywhere for such a few lines of codes (1000 line of python out of 3500 lines of random markdown and stuff). A general structure clean up could be usefull. For exemple font and images could be inside data. I am sorry if that looks... picky ? annoying ? I'm trying to be constructive but it's not easy lol. And that's just my opinion, i might be totally wrong. |
What would be your suggestion to rename it? First it was py_version and pygame so that's why I'm confused. A better structure is a good idea. Data classes look to me more readable, but I think it's more a preference, I think we can refactor it to a normal class, because pygame doesn't support data classes out of the box and could give us more problems later on.
I value your opinion! This is good constructive feedback! |
Hmm, yes, I was first thinking of a simple enum state machine class, and later work on other iterations. Perhaps it's best to see what works best, and try out different results! Perhaps a combination of enums or what you proposed is a good idea. This is what I just found just now how we could integrate a more game dev approach to it, with this library: https://github.com/benmoran56/esper |
a combination of the two seem good, as we might encapsulate the game logic (like player turns and all) inside the gamerunning state, and use something like that. |
Do you want to work on this or do you suggest we work together on different solutions? |
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.
Will this class handle just the game states or run the whole game?
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 one is just the state of the game during gameplay, so not the whole game, the whole game would be ran by the currently named GUI class.
I would like to work on that yes, but if you wanna try something else let me know. |
You have my permission to work on that, you have permissions to assign yourself to that task in github projects! @PurpleProg |
that way of handling states is pretty much working rn. It should make it easier to add a state, as you can make your own file, the only time you have to change other's work is when you want to add a way of switching to your new state. And as it use a stack, it's cool because it remember the last ones, when you exit a states it's nice and easy to go back to the last one. What do you think about it ? |
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.
I think deleting CLI code just to make the codebase more clear is not the best approach, we could use some code of it perhaps in the pygame code to a certain degree or perhaps work later on the CLI game if it's needed.
Overall your PR looks good, I would still add enums to the code to make it more clear which state you are adding as (new) contributor.
i don't understand how enums would help here. Could you explain that a bit more pls ? |
For example: from enum import Enum
class GameState(Enum):
MENU = 1
PLAYING = 2
PAUSED = 3
GAME_OVER = 4 Do you think this could help? Or do you think this could make it harder? |
enums are a fixed set of constants. But the current game states are not constants. So what we could do is to set them as integer and just check which state is currently selected, but, we would lose the advantages of using a stack. And i think that would not add anything more that classes, as we can use the |
Hmm, I think your approach sounds better, do what you think works best. I don't have much experience with using it, need to see it in action I suppose. |
you can try do write your own state, for example a simple "paused" state with just a simple transparent overlay. And bind buttons to enter and exit your "pause" (the pause state name is already taken but you get the idea) |
Do you need a review on this PR again? |
Yes, sure ! I think most of the work is done, the only thing left are the MainMenu state (but that can be done in another PR). So #85 and #84 are pretty much done, and #86 and #87 are almost done. There isn't really debug features, but I think it should be lightweight and modular so yeah. And merging this will allow others to work on their owns states. |
in fact i just didn't add any debug features, I will add a few tomorow. |
Finite State Machine
Summary
This PR add the base of the Finite State Machine
It's just a draft, so we can discuss how to implement that essential feature, which need to be scalable and clear (i mean understandable, readable). This is an exemple of how we could use classes as states.
Related Issues
related to #83, the state manager
✅ Checklist: