add quit channel to clean up after self
This commit is contained in:
@ -17,6 +17,7 @@ type Game struct {
|
||||
Music rl.Music
|
||||
Chat *Chat
|
||||
MenuOpen bool
|
||||
QuitChan chan struct{} // Channel to signal shutdown
|
||||
}
|
||||
|
||||
func New() *Game {
|
||||
@ -37,7 +38,8 @@ func New() *Game {
|
||||
Fovy: 45.0,
|
||||
Projection: rl.CameraPerspective,
|
||||
},
|
||||
Chat: NewChat(),
|
||||
Chat: NewChat(),
|
||||
QuitChan: make(chan struct{}),
|
||||
}
|
||||
game.Player.UserData = game
|
||||
game.Chat.userData = game
|
||||
@ -259,6 +261,7 @@ func (g *Game) DrawMenu() {
|
||||
case "Settings":
|
||||
// TODO: Implement settings
|
||||
case "Exit Game":
|
||||
close(g.QuitChan) // Signal all goroutines to shut down
|
||||
rl.CloseWindow()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user