/// <summary> /// Called after Application.Start has been called. Override and place application specific /// setup code here after calling base method. /// </summary> /// <param name="info"></param> protected virtual void Setup(ApplicationInfo info) { if (!string.IsNullOrEmpty(info.Font)) { TCODConsole.setCustomFont(info.Font, (int)info.FontFlags); } FpsLimit = info.FpsLimit; _fpsFrameLength = FpsLimit == 0 ? 0 : MilliSecondsPerSecond / FpsLimit; _lastDrawMilli = 0; UpdatesPerSecondLimit = info.UpdatesPerSecondLimit; _upsFrameLength = UpdatesPerSecondLimit == 0 ? 0 : MilliSecondsPerSecond / UpdatesPerSecondLimit; _lastUpdateMilli = 0; _delayFps = FpsLimit > UpdatesPerSecondLimit; TCODSystem.setFps(FpsLimit); TCODConsole.initRoot(info.ScreenSize.Width, info.ScreenSize.Height, info.Title, info.Fullscreen, info.RendererType); TCODConsole.setKeyboardRepeat(info.InitialDelay, info.IntervalDelay); TCODMouse.showCursor(true); if (SetupEventHandler != null) { SetupEventHandler(this, EventArgs.Empty); } Pigments = new PigmentMap(DefaultPigments.FrameworkDefaults, info.Pigments); }
static void Main(string[] args) { Console.WriteLine("Rogue Game: By Thomas Edmunds"); #if CUSTOM_FONT Console.WriteLine("- Creating custom libTCOD font..."); TCODConsole.setCustomFont(FONT_SHEET, (int)TCODFontFlags.LayoutAsciiInRow | (int)TCODFontFlags.Greyscale); #endif Console.WriteLine("- Initializing libTCOD console..."); TCODConsole.initRoot(WindowWidth, WindowHeight, GAME_TITLE, false, TCODRendererType.SDL); TCODConsole.setKeyboardRepeat(keyInitialDelay, keyInterval); Console.WriteLine("- libTCOD fullscreen = " + doFullscreen.ToString()); TCODConsole.setFullscreen(doFullscreen); Console.WriteLine("- Game Entry point, launching rogue engine..."); // Init the game engine: game entrypoint Engine engine = new Engine(TCODConsole.root); int endCode = engine.Run(); Console.WriteLine("- Game exit with code " + endCode); return; }
public static void InitDisplay() { TCODConsole.setCustomFont(font2, (int)TCODFontFlags.LayoutAsciiInRow, 16, 16); //Init font TCODSystem.setFps(30); //Set draw speed TCODConsole.initRoot(CONSOLE_WIDTH, CONSOLE_HEIGHT, "Wizard's Peril", false, TCODRendererType.GLSL); //Init the console displayConsole = TCODConsole.root; }
private void createWindow() { int fontflags = (int)TCODFontFlags.Greyscale | (int)TCODFontFlags.LayoutAsciiInRow; TCODConsole.setCustomFont(FONT, fontflags); TCODConsole.setKeyboardRepeat(500, 5000 / TARGET_FPS); TCODConsole.initRoot(WINDOW_WIDTH / FONT_WIDTH, WINDOW_HEIGHT / FONT_HEIGHT, windowName, false, TCODRendererType.SDL); TCODSystem.setFps(CONTROL_FPS); terminalManager = new TerminalManager(WINDOW_WIDTH / FONT_WIDTH, WINDOW_HEIGHT / FONT_HEIGHT); }
// Constructor public Window(string fontBitmap, int numberCharsHorz, int numberCharsVert, string windowTitle) { // Initialise the custom default font int fontNumberCharsHorz = 16; int fontNumberCharsVert = 16; TCODFontFlags flags = TCODFontFlags.LayoutAsciiInRow; TCODConsole.setCustomFont(fontBitmap, (int)flags, fontNumberCharsHorz, fontNumberCharsVert); // Set up the console dimensions TCODConsole.initRoot(numberCharsHorz, numberCharsVert, windowTitle, false, TCODRendererType.SDL); consoleWidth = numberCharsHorz; consoleHeight = numberCharsVert; // Get the console handle rootConsole = TCODConsole.root; // Set the framerate; TCODSystem.setFps(30); // Initialise the Menu Menu[0] = "[S]tart a new Adventure "; Menu[1] = "[C]ontinue an existing Adventure"; Menu[2] = "[Q]uit"; // Initialise the Intro Intro[0] = "A time was when we could live above ground."; Intro[1] = "A time when life flourished on the surface,"; Intro[2] = "and all the races were warmed by the Sun."; Intro[3] = String.Empty; Intro[4] = "That time was no more. Darkness claimed the Earth."; Intro[5] = "The pious extolled that we were punished by wrathful gods."; Intro[6] = "Penance and pilgrimage to atone for our sins our only hope"; Intro[7] = " at redemption."; Intro[8] = String.Empty; Intro[9] = "The sorcerers, the artificers, they sought other solutions."; Intro[10] = "Mystical archaic incantations or mechanical miracles from"; Intro[11] = " the minds of men."; Intro[12] = "That would bring back the Sun."; Intro[13] = "That would restore life to our world."; Intro[14] = String.Empty; Intro[15] = "The Sun is now but a memory, and hope fades along with the"; Intro[16] = " last of the heat."; Intro[17] = "Driving us further into the deep dark places in the Earth."; Intro[18] = "Monsters lurk in these caverns."; Intro[19] = "And men who have turned monster prey on their own kind."; Intro[20] = String.Empty; Intro[21] = "Welcome to the end of our time."; Intro[22] = "Welcome to Stygia..."; }
public void Initialize(BaseScene initialScene = null) { Logger.Initialize(); windowTitle = "Emergence"; Settings = LoadSettings("Assets/config.json"); if (Settings == null) { throw new Exception("Error loading config file."); } TCODConsole.setCustomFont($"Assets/Fonts/{Settings.Font}", (int)TCODFontFlags.LayoutAsciiInRow); TCODSystem.setFps(Settings.Fps); TCODConsole.initRoot(Settings.ScreenWidth, Settings.ScreenHeight, windowTitle, false, Settings.GetRendererType()); previousMouseData = TCODMouse.getStatus(); CurrentScene = initialScene; }
// ///////////////////////////////////////////////////////////////////////////////// #endregion #region Protected Methods // ///////////////////////////////////////////////////////////////////////////////// /// <summary> /// Called after Application.Start has been called. Override and place application specific /// setup code here after calling base method. /// </summary> /// <param name="info"></param> protected virtual void Setup(ApplicationInfo info) { if (!string.IsNullOrEmpty(info.Font)) { TCODConsole.setCustomFont(info.Font, (int)(TCODFontFlags.LayoutTCOD | TCODFontFlags.Grayscale)); } TCODConsole.initRoot(info.ScreenSize.Width, info.ScreenSize.Height, info.Title, info.Fullscreen, TCODRendererType.SDL); TCODMouse.showCursor(true); if (SetupEventHandler != null) { SetupEventHandler(this, EventArgs.Empty); } Pigments = new PigmentMap(DefaultPigments.FrameworkDefaults, info.Pigments); }
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()); }