コード例 #1
0
        [STAThread]         /// required to read user input multiple keys at a time
        static void Main(string[] args)
        {
            // Displays a loading message for user
            Console.Write("Loading");
            System.Threading.Thread.Sleep(100);

            // Setup console for a game
            NativeFunctions.InitializeConsole();                /// sets up console for use (no clicks, no arrow keys, etc)
            Console.TreatControlCAsInput = true;                /// prevents keyboard inturrupts, only reads input


            // Initialize engine classes
            ConsoleRenderer.Init();
            Input.Init();
            Time.Init();
            Runesole.Engine.Random.Init();

            // Game Setup
            SpriteManager.GenerateSprites();            /// generates sprites
            WorldBlock.Init();                          /// generates world blocks
            GameManager.Start();                        /// starts the game logic
            GameObject.__CallStartEvent();              /// calls start event on all gameobjects
            Console.Clear();                            /// clears the screen once everything is loaded

            mainLoopStarted = true;                     /// sets main loop started "flag" to true

            // while loop for each frame
            while (true)
            {
                // updates engine classes
                Time.Update();
                Input.Update();
                ConsoleRenderer.Update();

                // core game
                GameObject.__CallUpdateEvent();                                 /// Preforms game logic on gameobjects
                GameManager.Update();                                           /// updates game logic
                CoroutineManager.Update();                                      /// updates coroutine logic
                GameManager.world.Draw(GameManager.camera);                     /// draws the world
                GameObject.__DrawGameObjects(GameManager.camera);               /// draws game objects
                UI.Draw();                                                      ///	draws UI
                ConsoleRenderer.Render();                                       /// renders everything (UI & world) to console

                // updates engine classes end of frame
                GameManager.LateUpdate();
                Input.LateUpdate();
                Time.LateUpdate();

                // Add and destroy any gameobjects at end of frame
                GameObject.__AddGameObjects();
                GameObject.__DestroyGameObjects();
            }
        }
コード例 #2
0
        // Initializes WorldBlocks (generates the block list)
        public static void Init()
        {
            stoneWall = new WorldBlock(
                true,
                new Spit('▒', Color.Foreground.LightGray, Color.Background.DarkGray)
                );

            deepWaterBlock = new WorldBlock(
                true,
                new Spit(' ', Color.Foreground.None, Color.Background.BrightBlue)
                );

            waterBlock = new WorldBlock(
                true,
                new Spit(' ', Color.Foreground.None, Color.Background.Cyan)
                );

            water = new WorldBlock(
                false,
                new Spit(' ', Color.Foreground.None, Color.Background.BrightCyan)
                );

            sand = new WorldBlock(
                false,
                new Spit(' ', Color.Foreground.None, Color.Background.BrightYellow)
                );

            stone = new WorldBlock(
                false,
                new Spit(' ', Color.Background.DarkGray)
                );

            cutGrass = new WorldBlock(
                false,
                new Spit(' ', Color.Background.BrightGreen)
                );

            grass1 = new WorldBlock(
                false,
                new Spit(' ', Color.Background.Green)
                );

            grass2 = new WorldBlock(
                false,
                new Spit('/', Color.Foreground.BrightGreen, Color.Background.Green)
                );

            door = new WorldBlock(
                false,
                new Spit(' ', Color.Background.Black)
                );
        }