diff --git a/states.go b/states.go index fa690e8..fe44f58 100644 --- a/states.go +++ b/states.go @@ -66,8 +66,6 @@ type State interface { EndAnimHook(sm *StateMachine) } -type StateHungry struct{} -type StateFeed struct{} type StateWalkL struct{} type StateWalkR struct{} @@ -121,3 +119,22 @@ func (s *StateRClick) Update(sm *StateMachine) {} func (s *StateRClick) EndAnimHook(sm *StateMachine) { sm.SetState(&StateIdle{}) } + +type StateHungry struct{} + +func (s *StateHungry) Enter(sm *StateMachine) { sm.SetAnim(Hungry) } +func (s *StateHungry) Update(sm *StateMachine) { + if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonRight) { + sm.SetState(&StateFeed{}) + return + } +} +func (s *StateHungry) EndAnimHook(sm *StateMachine) {} + +type StateFeed struct{} + +func (s *StateFeed) Enter(sm *StateMachine) { sm.SetAnim(Feeding) } +func (s *StateFeed) Update(sm *StateMachine) {} +func (s *StateFeed) EndAnimHook(sm *StateMachine) { + sm.SetState(&StateIdle{}) +}