Exemplo n.º 1
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;
        }
Exemplo n.º 2
0
Arquivo: Game.cs Projeto: rezich/zday
        public void Update()
        {
            if (Player.TurnTimeout == 0)
            {
                var   key  = TCODConsole.waitForKeypress(true);
                Point dest = new Point(Player.Position.X, Player.Position.Y);
                switch (key.KeyCode)
                {
                case TCODKeyCode.Escape:
                    Over = true;
                    return;

                case TCODKeyCode.KeypadFour:
                case TCODKeyCode.Left:
                    dest.X--;
                    break;

                case TCODKeyCode.KeypadEight:
                case TCODKeyCode.Up:
                    dest.Y--;
                    break;

                case TCODKeyCode.KeypadSix:
                case TCODKeyCode.Right:
                    dest.X++;
                    break;

                case TCODKeyCode.KeypadTwo:
                case TCODKeyCode.Down:
                    dest.Y++;
                    break;

                case TCODKeyCode.KeypadSeven:
                    dest.X--;
                    dest.Y--;
                    break;

                case TCODKeyCode.KeypadNine:
                    dest.X++;
                    dest.Y--;
                    break;

                case TCODKeyCode.KeypadOne:
                    dest.X--;
                    dest.Y++;
                    break;

                case TCODKeyCode.KeypadThree:
                    dest.X++;
                    dest.Y++;
                    break;

                case TCODKeyCode.KeypadDecimal:
                case TCODKeyCode.KeypadFive:
                    if (Player.Stamina < Player.MaxStamina)
                    {
                        Player.Stamina = Math.Min(Player.Stamina + 10, Player.MaxStamina);
                    }
                    if (Player.HP < Player.MaxHP && Game.Current.RNG.Next(8) == 0)
                    {
                        Player.HP = Math.Min(Player.HP + 1, Player.MaxHP);
                    }
                    break;

                case TCODKeyCode.Enter:
                    if (TCODConsole.isKeyPressed(TCODKeyCode.Alt))
                    {
                        TCODConsole.setFullscreen(!TCODConsole.isFullscreen());
                    }
                    break;
                }
                if ((dest.X != Player.Position.X || dest.Y != Player.Position.Y) && Player.Stamina > 0)
                {
                    Player.MoveToPosition(dest);
                    Player.Stamina--;
                    Player.TurnTimeout += 5 - Player.Speed;
                }
            }
            foreach (Character c in Area.Current.Characters)
            {
                c.Update();
            }
            foreach (Decal d in Area.Current.Decals)
            {
                d.Update();
            }
            if (Player.HP < 1)
            {
                Console.WriteLine("GAME OVER");
                Draw();
                while (true)
                {
                    if (TCODConsole.waitForKeypress(true).KeyCode == TCODKeyCode.Escape)
                    {
                        Over = true;
                        break;
                    }
                }
            }
        }