Skip to content

Commit

Permalink
Updates examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Schutz committed Mar 9, 2024
1 parent 3a0d847 commit 7eb5b21
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
12 changes: 6 additions & 6 deletions examples/aware/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ func (s *BaseScene) Layout(w, h int) (int, int) {
return w, h
}

func (s *BaseScene) Load(st State, sm *stagehand.SceneManager[State]) {
func (s *BaseScene) Load(st State, sm stagehand.SceneController[State]) {
s.count = st
s.sm = sm
s.sm = sm.(*stagehand.SceneManager[State])
}

func (s *BaseScene) Unload() State {
return s.count
}

func (s *BaseScene) PreTransition(toScene stagehand.Scene[State, *stagehand.SceneManager[State]]) State {
func (s *BaseScene) PreTransition(toScene stagehand.Scene[State]) State {
s.count.OnTransition = true
return s.count
}

func (s *BaseScene) PostTransition(state State, fromScene stagehand.Scene[State, *stagehand.SceneManager[State]]) {
func (s *BaseScene) PostTransition(state State, fromScene stagehand.Scene[State]) {
s.count.OnTransition = false
}

Expand All @@ -60,7 +60,7 @@ func (s *FirstScene) Update() error {
s.count.Count++
}
if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonRight) {
s.sm.SwitchWithTransition(&SecondScene{}, stagehand.NewSlideTransition[State, *stagehand.SceneManager[State]](stagehand.TopToBottom, .05))
s.sm.SwitchWithTransition(&SecondScene{}, stagehand.NewSlideTransition[State](stagehand.TopToBottom, .05))
}
return nil
}
Expand All @@ -83,7 +83,7 @@ func (s *SecondScene) Update() error {
s.count.Count--
}
if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonRight) {
s.sm.SwitchWithTransition(&FirstScene{}, stagehand.NewSlideTransition[State, *stagehand.SceneManager[State]](stagehand.BottomToTop, .05))
s.sm.SwitchWithTransition(&FirstScene{}, stagehand.NewSlideTransition[State](stagehand.BottomToTop, .05))
}
return nil
}
Expand Down
13 changes: 9 additions & 4 deletions examples/director/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ func (s *BaseScene) Layout(w, h int) (int, int) {
return w, h
}

func (s *BaseScene) Load(st State, sm *stagehand.SceneDirector[State]) {
func (s *BaseScene) Load(st State, sm stagehand.SceneController[State]) {
s.count = st
s.sm = sm
s.sm = sm.(*stagehand.SceneDirector[State])
}

func (s *BaseScene) Unload() State {
Expand Down Expand Up @@ -90,12 +90,17 @@ func main() {

s1 := &FirstScene{}
s2 := &SecondScene{}
rs := map[stagehand.Scene[State, *stagehand.SceneDirector[State]]][]stagehand.Directive[State]{
trans := stagehand.NewSlideTransition[State](stagehand.BottomToTop, 0.05)
rs := map[stagehand.Scene[State]][]stagehand.Directive[State]{
s1: []stagehand.Directive[State]{
stagehand.Directive[State]{Dest: s2, Trigger: Trigger},
},
s2: []stagehand.Directive[State]{
stagehand.Directive[State]{Dest: s1, Trigger: Trigger},
stagehand.Directive[State]{
Dest: s1,
Trigger: Trigger,
Transition: trans,
},
},
}
sm := stagehand.NewSceneDirector[State](s1, state, rs)
Expand Down
8 changes: 4 additions & 4 deletions examples/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ func (s *BaseScene) Layout(w, h int) (int, int) {
return w, h
}

func (s *BaseScene) Load(st State, sm *stagehand.SceneManager[State]) {
func (s *BaseScene) Load(st State, sm stagehand.SceneController[State]) {
s.count = st
s.sm = sm
s.sm = sm.(*stagehand.SceneManager[State])
}

func (s *BaseScene) Unload() State {
Expand Down Expand Up @@ -67,7 +67,7 @@ func (s *SecondScene) Update() error {
s.count--
}
if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonRight) {
s.sm.SwitchWithTransition(&ThirdScene{}, stagehand.NewFadeTransition[State, *stagehand.SceneManager[State]](.05))
s.sm.SwitchWithTransition(&ThirdScene{}, stagehand.NewFadeTransition[State](.05))
}
return nil
}
Expand All @@ -86,7 +86,7 @@ func (s *ThirdScene) Update() error {
s.count *= 2
}
if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonRight) {
s.sm.SwitchWithTransition(&FirstScene{}, stagehand.NewSlideTransition[State, *stagehand.SceneManager[State]](stagehand.RightToLeft, .05))
s.sm.SwitchWithTransition(&FirstScene{}, stagehand.NewSlideTransition[State](stagehand.RightToLeft, .05))
}
return nil
}
Expand Down
8 changes: 4 additions & 4 deletions examples/timed/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ func (s *BaseScene) Layout(w, h int) (int, int) {
return w, h
}

func (s *BaseScene) Load(st State, sm *stagehand.SceneManager[State]) {
func (s *BaseScene) Load(st State, sm stagehand.SceneController[State]) {
s.count = st
s.sm = sm
s.sm = sm.(*stagehand.SceneManager[State])
}

func (s *BaseScene) Unload() State {
Expand All @@ -49,7 +49,7 @@ func (s *FirstScene) Update() error {
s.count++
}
if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonRight) {
s.sm.SwitchWithTransition(&SecondScene{}, stagehand.NewTicksTimedSlideTransition[State, *stagehand.SceneManager[State]](stagehand.LeftToRight, time.Second*time.Duration(s.count)))
s.sm.SwitchWithTransition(&SecondScene{}, stagehand.NewTicksTimedSlideTransition[State](stagehand.LeftToRight, time.Second*time.Duration(s.count)))
}
return nil
}
Expand All @@ -68,7 +68,7 @@ func (s *SecondScene) Update() error {
s.count--
}
if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonRight) {
s.sm.SwitchWithTransition(&FirstScene{}, stagehand.NewDurationTimedSlideTransition[State, *stagehand.SceneManager[State]](stagehand.RightToLeft, time.Second*time.Duration(s.count)))
s.sm.SwitchWithTransition(&FirstScene{}, stagehand.NewDurationTimedSlideTransition[State](stagehand.RightToLeft, time.Second*time.Duration(s.count)))
}
return nil
}
Expand Down

0 comments on commit 7eb5b21

Please sign in to comment.