/// <summary> /// Get the size, in pixels, of a single character, as per TCODSystem.getCharSize(). /// </summary> /// <returns></returns> static public Size GetCharSize() { int w, h; TCODSystem.getCharSize(out w, out h); return(new Size(w, h)); }
private static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += (CurrentDomain_UnhandledException); TCODColor fogOfWarColour = new TCODColor(80, 80, 80); int horizontalPixels, verticalPixels; TCODSystem.getCurrentResolution(out horizontalPixels, out verticalPixels); //string font = "celtic_garamond_10x10_gs_tc.png"; string font = "arial12x12.png"; TCODConsole.setCustomFont( font, (int)(TCODFontFlags.Grayscale | TCODFontFlags.LayoutTCOD), 32, 8); int fontWidth, fontHeight; TCODSystem.getCharSize(out fontWidth, out fontHeight); int screenWidth = horizontalPixels / fontWidth; int screenHeight = verticalPixels / fontHeight; var screenBounds = new Rectangle(0, 0, screenWidth, screenHeight); int infoPanelWidth = 42; var playBounds = new Rectangle(0, 0, screenBounds.Width - infoPanelWidth, screenBounds.Height); var playerBounds = new Rectangle(playBounds.Right, 0, infoPanelWidth, 6); //var threatBounds = new Rectangle(playBounds.Right, playerBounds.Bottom, infoPanelWidth, 10); var competitorBounds = new Rectangle(playBounds.Right, playerBounds.Bottom, infoPanelWidth, 27); var eventBounds = new Rectangle(playBounds.Right, competitorBounds.Bottom, infoPanelWidth, screenBounds.Height - (playerBounds.Height + competitorBounds.Height)); Game game = CreateGame(); Logger.Info("Initializing RootConsole..."); TCODConsole.initRoot(screenBounds.Width, screenBounds.Height, "Last Man Standing v1.0", true, TCODRendererType.SDL); TCODSystem.setFps(30); var rootConsole = TCODConsole.root; rootConsole.setForegroundColor(ColorPresets.White); rootConsole.setAlignment(TCODAlignment.LeftAlignment); rootConsole.setBackgroundFlag(TCODBackgroundFlag.Set); Logger.Info("Initializing playConsole..."); TCODConsole playConsole = new TCODConsole(playBounds.Width, playBounds.Height); //Logger.Info("Initializing threatConsole..."); //Console threatConsole = RootConsole.GetNewConsole(threatBounds.Width, threatBounds.Height); Logger.Info("Initializing playerConsole..."); TCODConsole playerConsole = new TCODConsole(playerBounds.Width, playerBounds.Height); Logger.Info("Initializing competitorConsole..."); TCODConsole competitorConsole = new TCODConsole(competitorBounds.Width, competitorBounds.Height); Logger.Info("Initializing eventsConsole..."); TCODConsole eventsConsole = new TCODConsole(eventBounds.Width, eventBounds.Height); Logger.Info("Starting Game Loop..."); do { TCODKey keyStroke = TCODConsole.checkForKeypress((int)TCODKeyStatus.KeyPressed); if (game.IsActive) { game.ProcessTurn(); if (keyStroke.KeyCode != TCODKeyCode.NoKey) { ((PlayerAI)game.Player.Intellect).EvaluateKeyPress(keyStroke); } } RenderAllConsoles(game, rootConsole, playConsole, fogOfWarColour, playerConsole, competitorConsole, eventsConsole, playBounds, playerBounds, competitorBounds, eventBounds); if (!game.IsActive) { rootConsole.printEx((screenBounds.Width - 30) / 2, (screenBounds.Height - 10) / 2, TCODBackgroundFlag.Set, TCODAlignment.LeftAlignment, "Press SPACE to start a new game. Press ESC to quit."); if (keyStroke.KeyCode == TCODKeyCode.Space) { rootConsole.print(1, 1, "Creating new game..."); TCODConsole.flush(); game = CreateGame(); } } TCODConsole.flush(); if (keyStroke.KeyCode == TCODKeyCode.Escape) { return; } } while (!TCODConsole.isWindowClosed()); }