/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (Game game = new Game()) { game.Run(); } }
static void Main(string[] args) { Game game = new Game(); // запуск игры Console.ReadKey(); }
static void Main(string[] args) { Game game = new Game(); // run the game Console.ReadKey(); }
public void Initialize(Game game) { if (game == null) throw new ArgumentNullException("game"); m_game = game; m_loopState.Initialize(); }
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; }
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); }
public override void Loop(Game game, LoopState state) { state.Tick(); game.Update(state); game.Render(state); }
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()); }