How to draw and code a state machine? (pictures!)
Posted: Fri Sep 07, 2018 6:13 am
I don't know how to make a state machine the correct way. But I wanted to write out possible states and try anyway.
Deck - has the states idle, fetching and empty. idle responds to a click which turns its state to fetching. fetching takes 0.2 seconds to transition back to idle while tweening, but instantly sets state to empty if that was the last card.
Notes: The tween from click happens as soon as fetching begins. I wasn't sure how to show that, but you can hopefully see that for .2 seconds the tween will animate from the fetching state to the idle state. The tween animates when going from fetching to empty too, but the state transition is instant.
the card states, I'm not entirely sure on. but i think it's sort of clear? if its idle, it responds to mousepressed. if its selected, it repsonds to moving and released. if its moving, it responds only to released, by going to the played card function (that used the ellipse for state for some reason, but split lines would have been more better. There are some points where it can go back to idle, or to a you win screen
I know I'm missing something, and I don't know how to code this exactly anyway
https://love2d.org/imgmirrur/rSWR2Df.html
some pics of what i was thinking of
Deck - has the states idle, fetching and empty. idle responds to a click which turns its state to fetching. fetching takes 0.2 seconds to transition back to idle while tweening, but instantly sets state to empty if that was the last card.
Notes: The tween from click happens as soon as fetching begins. I wasn't sure how to show that, but you can hopefully see that for .2 seconds the tween will animate from the fetching state to the idle state. The tween animates when going from fetching to empty too, but the state transition is instant.
the card states, I'm not entirely sure on. but i think it's sort of clear? if its idle, it responds to mousepressed. if its selected, it repsonds to moving and released. if its moving, it responds only to released, by going to the played card function (that used the ellipse for state for some reason, but split lines would have been more better. There are some points where it can go back to idle, or to a you win screen
I know I'm missing something, and I don't know how to code this exactly anyway
https://love2d.org/imgmirrur/rSWR2Df.html
some pics of what i was thinking of