fiddle main conditional flow

This commit is contained in:
Luke Meyers 2020-02-08 21:27:50 -08:00
parent f06400d905
commit ea9f41e581
1 changed files with 18 additions and 16 deletions

10
main.go
View File

@ -48,14 +48,15 @@ func run() error {
go func() { cmdC <- game.PollCommands(s) }() go func() { cmdC <- game.PollCommands(s) }()
for !w.Closed() && !s.GameOver { for !w.Closed() && !s.GameOver {
switch { if rs.Animating {
case w.Pressed(pixelgl.KeyQ):
return nil
case rs.Animating:
rs = gfx.Render(rs, sOld, s, w, *sb) rs = gfx.Render(rs, sOld, s, w, *sb)
if !rs.Animating { if !rs.Animating {
sOld = s sOld = s
} }
} else {
switch {
case w.Pressed(pixelgl.KeyQ):
return nil
case w.Pressed(pixelgl.KeySpace) || true: case w.Pressed(pixelgl.KeySpace) || true:
log.Printf("TURN %d", turn) log.Printf("TURN %d", turn)
rs.Animating = true rs.Animating = true
@ -71,6 +72,7 @@ func run() error {
} }
go func() { cmdC <- game.PollCommands(s) }() go func() { cmdC <- game.PollCommands(s) }()
} }
}
w.Update() w.Update()
frames++ frames++