Esempio n. 1
0
func main() {
	runtime.GOMAXPROCS(10)

	dataDir := data.GetDataDir()
	os.Chdir(dataDir)

	display.InitializeAllegro()
	conf := config.LoadUserConfig(CONFIG_LOCATION)
	if conf == nil {
		log.Panicf("Could not load user config (%q) or create empty", CONFIG_LOCATION)
	}

	defaultResourceDir := "resources"
	resourceDir := config.GetString(conf, "resources", "dir", defaultResourceDir)

	ge := game.CreateGameEngine(conf)
	de := display.CreateDisplayEngine(resourceDir, conf, ge)

	go ge.MainLoop()
	de.Run()
}
Esempio n. 2
0
func createDisp(conf *allegro.Config) *allegro.Display {
	/*	width := config.GetInt(conf, "display", "width", DEFAULT_WIDTH)
		height := config.GetInt(conf, "display", "height", DEFAULT_HEIGHT)*/

	flags := allegro.RESIZABLE
	switch config.GetString(conf, "display", "windowed", "fullscreenwindow") {
	case "fullscreen":
		flags |= allegro.FULLSCREEN
	case "windowed":
		flags |= allegro.WINDOWED
	default:
		log.Printf("display.windowed not one of \"fullscreen\", \"fullscreenwindow\", or \"windowed\"")
		log.Printf("Defaulting to display.windowed=\"fullscreenwindow\"")
		fallthrough
	case "fullscreenwindow":
		flags |= allegro.FULLSCREEN_WINDOW
	}

	disp := allegro.CreateDisplay(1, 1, flags)
	if disp == nil {
		log.Fatalf("Could not create display")
	}
	return disp
}