コード例 #1
0
ファイル: game.go プロジェクト: bluepeppers/cotta
func CreateGameEngine(conf *allegro.Config) *GameEngine {
	ge := new(GameEngine)
	ge.stopped = false
	ge.world = CreateWorldMap(conf)
	ge.tickRate = config.GetInt(conf, "game", "tickrate", DEFAULT_TICKRATE)

	tileWidth := config.GetInt(conf, "game", "tileWidth", DEFAULT_TILE_WIDTH)
	tileHeight := config.GetInt(conf, "game", "tileHeight", DEFAULT_TILE_HEIGHT)

	ge.displayConfig = display.DisplayConfig{
		ge.world.width, ge.world.height,
		tileWidth, tileHeight,
		allegro.CreateColorHTML("black")}
	return ge
}
コード例 #2
0
ファイル: worldmap.go プロジェクト: bluepeppers/cotta
func CreateWorldMap(conf *allegro.Config) *WorldMap {
	var wm WorldMap
	wm.width = config.GetInt(conf, "map", "width", 20)
	wm.height = config.GetInt(conf, "map", "height", 20)
	tilesParent := make([]tile.Tile, wm.width*wm.height)
	wm.tiles = make([][]tile.Tile, wm.width)
	for x := 0; x < wm.width; x++ {
		wm.tiles[x] = tilesParent[:wm.height]
		tilesParent = tilesParent[wm.height:]
	}
	for x := 0; x < wm.width; x++ {
		for y := 0; y < wm.height; y++ {
			wm.tiles[x][y] = tile.CreateEmptyTile()
		}
	}

	wm.roadNetwork = roads.CreateRoadNetwork(&wm)

	return &wm
}