gameDirector.go 724 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package game
  2. import "fmt"
  3. func (game *Game) gameDirector() {
  4. defer quit(game)
  5. // Gameflow stages
  6. // 1. Place ships
  7. // 2. Fire shots
  8. // 3. Win/Lose
  9. var stage int
  10. for game.gameover == 0 {
  11. fmt.Print("Do things")
  12. stage = 1
  13. // if stage 1: place ships
  14. if stage == 1 {
  15. game.drawScreen()
  16. // Iterate through Shipsets
  17. // Place ships in game.leftShips
  18. for _, ship := range game.shipsets {
  19. valid := false
  20. for !valid {
  21. x, y := 7, 7
  22. orientation := updown
  23. game.shipPlace(ship, x, y, orientation)
  24. game.drawScreen()
  25. game.doAction(<-game.keypresses)
  26. }
  27. }
  28. }
  29. // if stage 2: fire shots
  30. if stage == 2 {
  31. game.drawScreen()
  32. fmt.Println("Fire shots")
  33. }
  34. }
  35. }