-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
82 lines (74 loc) · 2.3 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package main
import (
rl "github.com/gen2brain/raylib-go/raylib"
"github.com/pawelktk/TuxMan/audio"
"github.com/pawelktk/TuxMan/game"
"github.com/pawelktk/TuxMan/gfx"
"github.com/pawelktk/TuxMan/globals"
"github.com/pawelktk/TuxMan/screens"
)
func main() {
//rl.SetConfigFlags(rl.FlagWindowResizable)
currentGame := game.NewGame()
gameWindow := gfx.NewGfx(int32(1920*0.7), int32(1080*0.7))
audio.InitAudio()
gameWindow.InitGameTextureBox(¤tGame)
screen := "main_menu"
//currentGame.GameBoard.AddObstacle(4, 1, Wall)
//currentGame.GameBoard.AddObstacle(2, 2, Breakable)
for !rl.WindowShouldClose() {
audio.MainAudio()
if screen == "main_menu" {
screens.MenuHandleInput(&gameWindow, screens.OptionsCount_MainMenu)
} else if screen == "game_init" {
screens.MenuHandleInput(&gameWindow, screens.SelectedPlayerCount)
if screens.EnteredKey != -1 {
screens.UpdatePlayerName(¤tGame)
}
} else {
gameWindow.HandleInput(¤tGame, rl.GetFrameTime())
}
currentGame.Update()
gameWindow.GenerateGameTexture(¤tGame)
gameOver, winner := currentGame.GameShouldEnd()
rl.BeginDrawing()
//rl.BeginShaderMode(gfx.Shader)
if gameOver {
screens.GameOverScreen(&gameWindow, ¤tGame, winner)
} else if screen == "main_menu" {
switch screens.SelectedMenuOption {
case 0:
if screens.SelectedPlayerCount > 0 {
currentGame.AddPlayer("PLAYER1", 0, 1)
}
if screens.SelectedPlayerCount > 1 {
currentGame.AddPlayer("PLAYER2", globals.GLOBAL_TILE_SIZE*float32(currentGame.GameBoard.Size_x-1), 1)
}
if screens.SelectedPlayerCount > 2 {
currentGame.AddPlayer("PLAYER3", 1, globals.GLOBAL_TILE_SIZE*float32(currentGame.GameBoard.Size_y-1))
}
screen = "game_init"
case 1:
screens.SelectedPlayerCount = screens.SelectedPlayerCount + 1
if screens.SelectedPlayerCount > globals.MAX_PLAYERS {
screens.SelectedPlayerCount = 2
}
case 2:
rl.CloseWindow()
return
default:
screens.MainMenuScreen(&gameWindow)
}
} else if screen == "game" {
screens.GameScreen(&gameWindow, ¤tGame)
} else if screen == "game_init" {
if screens.SelectedMenuOption == -1 {
screens.GameInitMenuScreen(&gameWindow, ¤tGame)
} else {
screen = "game"
}
}
//rl.EndShaderMode()
rl.EndDrawing()
}
}