Hey all,
I've been playing with states and overlays (not sure if that's the right term). I finally hammered out a decent state machine with less-elegant overlays (mini-states that can be stacked up arbitrarily). It was mostly a learning process for me, and it qualifies as a creation, so I'm positing it here. Everything is CC0, so use it however you like.
It features Fail, Load, Menu, Play, and Quit states with some fun effects tossed in. Try to spot which bits are overlays!
Post your questions, tweaks, etc.
Enjoy!
State Machine demo!
State Machine demo!
- Attachments
-
- state.love
- State machine demo
- (14.05 KiB) Downloaded 389 times
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
- Gunroar:Cannon()
- Party member
- Posts: 1141
- Joined: Thu Dec 10, 2020 1:57 am
Re: State Machine demo!
Nice, this reminds me of the state machine I used in this project, though mine was more behavior based and also had stateless AI, and was less flexible(?).
Re: State Machine demo!
I really need to get into the whole state machine thing. I think it is "next level" for my coding development. I've always been hesitant because it's not essential to use a state machine but, of course, there are many ways to do things and this might be better so I'll jump into it and learn it.
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Turn-based PBEM horse stable (racing) management sim: https://togfox.itch.io/horse-stable-manager
https://discord.gg/HeHgwE5nsZ
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Turn-based PBEM horse stable (racing) management sim: https://togfox.itch.io/horse-stable-manager
https://discord.gg/HeHgwE5nsZ
Re: State Machine demo!
Awesome! I felt like that too, originally. It's only made me a better (and more organized!) coder!
The simple way to look at it is we're just using some well-organized tables in a very specific way. The current state is the key value used to look up other values, and those happen to be functions particular to a given state. It's also a very elegant way to avoid massive IF..ESLEIF.. blocks.
The simple way to look at it is we're just using some well-organized tables in a very specific way. The current state is the key value used to look up other values, and those happen to be functions particular to a given state. It's also a very elegant way to avoid massive IF..ESLEIF.. blocks.
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
- Gunroar:Cannon()
- Party member
- Posts: 1141
- Joined: Thu Dec 10, 2020 1:57 am
Re: State Machine demo!
Wait, which kind of state machine is this? The AI kind or the screen manager kind?
Re: State Machine demo!
Screen manager - sorry that was unclear!
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
Who is online
Users browsing this forum: No registered users and 2 guests