Skip to content

Commit

Permalink
wip state hungry
Browse files Browse the repository at this point in the history
  • Loading branch information
nhanb committed Sep 17, 2023
1 parent c171648 commit 0671603
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions states.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ type State interface {
EndAnimHook(sm *StateMachine)
}

type StateHungry struct{}
type StateFeed struct{}
type StateWalkL struct{}
type StateWalkR struct{}

Expand Down Expand Up @@ -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{})
}

0 comments on commit 0671603

Please sign in to comment.