示例#1
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Game game = new Game())
     {
         game.Run();
     }
 }
示例#2
0
 static void Main(string[] args)
 {
     
     Game game = new Game(); // запуск игры
     Console.ReadKey();
  
 }
示例#3
0
 static void Main(string[] args)
 {
     
     Game game = new Game(); // run the game
     Console.ReadKey();
  
 }
示例#4
0
文件: GameLoop.cs 项目: kridy/Snaky
        public void Initialize(Game game)
        {
            if (game == null) throw new ArgumentNullException("game");

            m_game = game;

            m_loopState.Initialize();
        }
示例#5
0
        internal int moveSnake(Game myGame, int unitLength)
        {
            bool hitFood = false;
            SnakeBody index = this.head;
            int lastX = index.rectangleLeft;
            int lastY = index.rectangleTop;
            index.rectangleLeft += horizonMove;
            index.rectangleTop += verticalMove;
            if(head.rectangleLeft >= myGame.borderRight || head.rectangleLeft < myGame.borderLeft || head.rectangleTop >= myGame.borderBottom || head.rectangleTop < myGame.borderTop)
            {
                MessageBox.Show("too bad");
                Environment.Exit(1);
                return 1;
            }

            if (head.rectangleLeft == myGame.foodLocX && head.rectangleTop == myGame.foodLocY)
            {
                hitFood = true;
            }
            index = index.next;
            while (index != null)
            {
                int tmpX = index.rectangleLeft;
                int tmpY = index.rectangleTop;
                index.rectangleLeft = lastX;
                index.rectangleTop = lastY;
                lastX = tmpX;
                lastY = tmpY;
                index = index.next;
            }
            if (hitFood)
            {
                SnakeBody newBody = new SnakeBody(lastX, lastY, unitLength);
                newBody.bodyBlock.Fill = myGame.foodRec.Fill;
                tail.next = newBody;
                tail = newBody;
                myGame.generateFoodLoc(unitLength);
            }
            else
            {
                myGame.obstacle.RemoveAt(0);
            }
            Tuple<int, int> newTuple = new Tuple<int, int>(head.rectangleLeft, head.rectangleTop);
            if(myGame.obstacle.Contains(newTuple))
            {
                MessageBox.Show("too bad");
                Environment.Exit(1);
            }
            else
            {
                myGame.obstacle.Add(new Tuple<int, int>(head.rectangleLeft, head.rectangleTop));
            }
            return 0;
        }
示例#6
0
        public override void Loop(Game game, LoopState state)
        {
            state.Tick();
            accumulatedTime += state.NanoSeconds;
            updateCount = 0;

            while (accumulatedTime >= frameRate && updateCount < maxCount)
            {
                game.Update(state);
                updateCount++;
                accumulatedTime -= frameRate;
            }

            state.Interpolation = accumulatedTime/frameRate;

            game.Render(state);

            //var sleepTime = (frameRate - state.MilliSeconds);

            //if(sleepTime > 0)
            //    Thread.Sleep((int)sleepTime);
        }
示例#7
0
文件: BasicLoop.cs 项目: kridy/Snaky
 public override void Loop(Game game, LoopState state)
 {
     state.Tick();
     game.Update(state);
     game.Render(state);
 }
示例#8
0
文件: Program.cs 项目: kridy/Snaky
        public GameEngine(Game game, ConsoleDisplay display)
        {
            if (game == null)
                throw new ArgumentNullException("game");

            m_game = game;

            if (display == null)
                throw new ArgumentNullException("display");

            m_display = display;

            m_gameLoop = new GameLoop(new InterpolatedLoop());
        }