44 lines
968 B
Go
44 lines
968 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"runtime/pprof"
|
|
|
|
"git.wisellama.rocks/Wisellama/carpy-breakout/pkg/config"
|
|
"git.wisellama.rocks/Wisellama/carpy-breakout/pkg/game"
|
|
"git.wisellama.rocks/Wisellama/gosimpleconf"
|
|
)
|
|
|
|
func main() {
|
|
// Initialize the random number generator
|
|
err := config.InitRNG()
|
|
if err != nil {
|
|
log.Fatalf("error initializing RNG: %v", err)
|
|
}
|
|
|
|
// Parse the config and setup logging
|
|
configMap, err := config.Configure()
|
|
if err != nil {
|
|
log.Fatalf("error in Configure: %v", err)
|
|
}
|
|
|
|
// Setup cpu profiling if configured
|
|
cpuProfile := gosimpleconf.Bool(configMap["cpuprofile.enabled"])
|
|
if cpuProfile {
|
|
var f *os.File
|
|
f, err = os.Create(configMap["cpuprofile.file"])
|
|
if err != nil {
|
|
log.Fatalf("error creating file for cpuprofile: %v", err)
|
|
}
|
|
err = pprof.StartCPUProfile(f)
|
|
if err != nil {
|
|
log.Fatalf("error starting cpuprofile: %v", err)
|
|
}
|
|
defer pprof.StopCPUProfile()
|
|
}
|
|
|
|
// Start the game
|
|
game.Run(configMap)
|
|
}
|