public void PacmansDisplayChangesDependingOnKeyPresses(Direction direction, string display) { var mock = new Mock <IInput>(); var pacman = new Pacman(0, 0, Direction.Right, new ConsoleOutput()); mock.Setup(m => m.TakeInput(pacman.Direction)).Returns(direction); pacman.Update(direction, 1); Assert.Equal(display, pacman.Sprite); }
private void ResetCharacters() { Pacman.X = Level.PacStartX; Pacman.Y = Level.PacStartY; Pacman.Update(Level.PacStartDirection, 1); for (int i = 0; i < Ghosts.Count; i++) { Ghosts[i].X = Level.Ghosts[i].X; Ghosts[i].Y = Level.Ghosts[i].Y; } }
// update game state public void Update() { if (_GameStarting) { if (!_StartTimer.IsStarted) { _GameOver = false; _StartTimer.Start(); } else { if (_StartTimer.Ticks / 1000 >= _StartDelay) { _GameStarting = false; _StartTimer.Stop(); // stop timer _StartTimer.Reset(); // reset timer ResetLevel(); } } } if (!_GameStopped) { if (!SplashKit.MusicPlaying()) // play siren if not already { SplashKit.PlayMusic("siren", -1); } _Pacman.KeepInMaze(); // check collision with pivots, keeps pacman in the maze... _Pacman.HandleInput(); foreach (Ghost g in _Ghosts) { g.KeepInMaze(); // check collision with 'ghost pivots' (reduced set, no cluster), keeps ghost in the maze and determines direction... } PelletCollision(); // check if pacman has eaten/collided with pellet CheckCollision(); // check if pacman and ghosts collide _Pacman.Update(); // update player foreach (Ghost g in _Ghosts) { g.Update(); // update ghost } } if (_GhostsEaten.Count > 0) // clears list of eaten ghosts each time vulnerability ends { if (!Ghost._Vulnerable && !Ghost._VulnerableTransition) { _GhostsEaten.Clear(); } } }
protected override void Update(GameTime gameTime) { Time.Update(gameTime); InputManager.Update(); currentScene.Update(); background = (currentScene == scenes["Play"] ? Color.Black : Color.Black); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } if (gameTime.ElapsedGameTime.TotalSeconds == 60) { Exit(); } //if (InputManager.IsKeyDown(Keys.Up)) camera.Transform.Rotate(Vector3.Right, Time.ElapsedGameTime); //if (InputManager.IsKeyDown(Keys.Down)) camera.Transform.Rotate(Vector3.Left, Time.ElapsedGameTime); if (Inky.CheckCollision(pacman)) { hits++; } if (Blinky.CheckCollision(pacman)) { hits++; } if (Pinky.CheckCollision(pacman)) { hits++; } if (Clyde.CheckCollision(pacman)) { hits++; } if (Blue.CheckCollision(pacman)) { hits++; } pacman.Update(); Inky.Update(); Blinky.Update(); Pinky.Update(); Clyde.Update(); Blue.Update(); powerUp.Update(); Vector3 normal; if (pacman.Get <Collider>().Collides(powerUp.Get <Collider>(), out normal)) { Console.WriteLine("HitBox"); (powerUp.Get <Renderer>().ObjectModel.Meshes[0].Effects[0] as BasicEffect).DiffuseColor = Color.Red.ToVector3(); pacmanHealth--; } else { Console.WriteLine("NotHitBox"); (powerUp.Get <Renderer>().ObjectModel.Meshes[0].Effects[0] as BasicEffect).DiffuseColor = Color.Blue.ToVector3(); pacmanHealth--; } base.Update(gameTime); }