Example #1
0
        /// <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);
        }
Example #2
0
 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;
 }
Example #3
0
        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;
        }
Example #4
0
        public static void Main(string[] args)
        {
            TCODConsole.initRoot(80, 60, "ULR", false);
            Control con = new Control();

            con.run();
        }
Example #5
0
 static void Main(string[] args)
 {
     TCODConsole.initRoot(80, 50, "Z-Day", false);
     TCODSystem.setFps(30);
     TCODMouse.showCursor(false);
     Game.Current = new Game();
     Game.Current.Initialize();
     Game.Current.Play();
 }
Example #6
0
        public void initialize(bool restarting)
        {
            Console.WriteLine("Initializing...");
            gameStatus = GameStatus.LOADING;
            TCODConsole.initRoot(screenWidth, screenHeight, "Janus Roguelike", false);

            TCODMouse.showCursor(true);

            menuGui = new GUI.MenuGui(screenWidth, screenHeight);

            levels = new Dictionary <int, Level>();

            gui        = new GUI.Gui();
            loadingGui = new GUI.LoadingGui();
            messageGui = new GUI.MessageGui();
            defeatGui  = new GUI.DefeatGui();
            debugCommands.initialize(this);

            levels.Add(FIRST_LEVEL, new Level());

            levelnr = FIRST_LEVEL;
            //currentLevel = new Level();
            if (FIRST_LEVEL == int.MaxValue)
            {
                currentLevel.initialize(restarting, FIRST_LEVEL, typeof(Generators.TestLevelGenerator));
            }
            else
            {
                currentLevel.initialize(restarting, FIRST_LEVEL);
            }

            changeLevel(FIRST_LEVEL);

            player = new Player();
            player.getDestructible().ressurect();

            player.x = map.startx; //assign player position
            player.y = map.starty;

            player.fov.update();
            if (actorHandler.getActor(0) != null)
            {
                actorHandler.actors.Remove(actorHandler.getActor(0));
            }
            actorHandler.addActor(player);

            Saver.load();

            Console.WriteLine("Initializing Complete");


            render();

            lastKey    = new TCODKey();
            gameStatus = GameStatus.STARTUP;
        }
Example #7
0
        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);
        }
Example #8
0
        static void Main()
        {
            TCODConsole.initRoot(80, 61, "Lights Out");
            TCODSystem.setFps(100);
            TCODConsole.setKeyboardRepeat(250, 100);
            Game game = new Game();

            game.Draw();
            while (!TCODConsole.isWindowClosed() && !game.Exit)
            {
                game.Update();
            }
        }
Example #9
0
        // 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...";
        }
Example #10
0
        static void Main()
        {
            TCODConsole.initRoot(80, 50, "my game", false);
            TCODSystem.setFps(25);
            bool endGame = false;

            while (!endGame && !TCODConsole.isWindowClosed())
            {
                TCODConsole.root.print(0, 0, "Hello, world");
                TCODConsole.flush();
                var key = TCODConsole.checkForKeypress();

                if (key.KeyCode == TCODKeyCode.Escape)
                {
                    endGame = true;
                }
            }
        }
Example #11
0
        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;
        }
Example #12
0
        // /////////////////////////////////////////////////////////////////////////////////
        #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);
        }
Example #13
0
        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());
        }
Example #14
0
 public static void InitializeRootConsole(int width, int height)
 {
     TCODConsole.initRoot(width, height, "ProjectR", false, TCODRendererType.GLSL);
     RootConsole = new RConsole(TCODConsole.root);
 }