Example #1
0
        static void Main(string[] args)
        {
            //Set up console
            Console.Clear();
            Console.CursorVisible = false;

            //Initialize game state
            gamePlane = new GamePlane(60, 30);
            //gamePlane = new GamePlane(Console.WindowWidth, Console.WindowHeight);
            bool      running   = true;
            Stopwatch stopwatch = Stopwatch.StartNew();
            long      previousFrameTime;
            long      currentFrameTime = stopwatch.ElapsedMilliseconds;

            //Main game loop
            while (running)
            {
                previousFrameTime = currentFrameTime;
                currentFrameTime  = stopwatch.ElapsedMilliseconds;
                long frameDelay = currentFrameTime - previousFrameTime;
                //Dividing by an arbitrary scaling factor to give deltatime a more desirable size
                double deltatime = frameDelay / 1000.0;

                GetGameInputs();
                UpdateGameState(deltatime);
                RenderGame();

                if (frameDelay < targetFrameDelay)
                {
                    Thread.Sleep((int)(targetFrameDelay - frameDelay));
                }
            }
        }
Example #2
0
 public DestructibleTile(double x, double y, GamePlane gp) : base("D", x, y)
 {
     parentGamePlane      = gp;
     destructionCallback += new TileCallback(gp.DestroyTile);
 }