2021-08-24 22:44:18 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"runtime/pprof"
|
|
|
|
|
2023-02-25 23:35:40 -08:00
|
|
|
"git.wisellama.rocks/Wisellama/carpy-breakout/pkg/config"
|
|
|
|
"git.wisellama.rocks/Wisellama/carpy-breakout/pkg/game"
|
|
|
|
"git.wisellama.rocks/Wisellama/gosimpleconf"
|
2021-08-24 22:44:18 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2022-06-18 13:27:50 -07:00
|
|
|
// Initialize the random number generator
|
|
|
|
err := config.InitRNG()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("error initializing RNG: %v", err)
|
|
|
|
}
|
2021-10-06 18:27:09 -07:00
|
|
|
|
2022-06-18 13:27:50 -07:00
|
|
|
// 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 {
|
2023-02-25 23:35:40 -08:00
|
|
|
var f *os.File
|
|
|
|
f, err = os.Create(configMap["cpuprofile.file"])
|
2021-09-01 00:39:33 -07:00
|
|
|
if err != nil {
|
2022-06-18 13:27:50 -07:00
|
|
|
log.Fatalf("error creating file for cpuprofile: %v", err)
|
2021-09-01 00:39:33 -07:00
|
|
|
}
|
2022-04-25 00:22:04 -07:00
|
|
|
err = pprof.StartCPUProfile(f)
|
|
|
|
if err != nil {
|
2022-06-18 13:27:50 -07:00
|
|
|
log.Fatalf("error starting cpuprofile: %v", err)
|
2022-04-25 00:22:04 -07:00
|
|
|
}
|
2021-09-01 00:39:33 -07:00
|
|
|
defer pprof.StopCPUProfile()
|
|
|
|
}
|
|
|
|
|
2022-06-18 13:27:50 -07:00
|
|
|
// Start the game
|
|
|
|
game.Run(configMap)
|
2021-08-24 22:44:18 -07:00
|
|
|
}
|