public void ShouldChangeDirection_WhenDirectionIsGiven() { var pacman = new Pacman.Pacman(Direction.North, 12, 15); pacman.Move(Direction.South, 12, 15); Assert.Equal(Direction.South, pacman.FacingDirection); }
public void ShouldUpdateLocation_WhenRowAndColumnAreGiven() { var pacman = new Pacman.Pacman(Direction.North, 12, 15); pacman.Move(Direction.North, 10, 20); Assert.Equal(new int[] { 10, 20 }, pacman.Location); }
public void ShouldChangeOpenOrClosedMouthState_WhenMove() { var pacman = new Pacman.Pacman(Direction.North, 12, 15); pacman.Move(Direction.North, 14, 18); Assert.Equal(Mouth.Closed, pacman.MouthStatus); }
public Boolean ghostCollision(Pacman pacman, Ghost ghost) { if ((pacman.element.Position.X < ghost.element.Position.X +20 && pacman.element.Position.X > ghost.element.Position.X - 20) && (pacman.element.Position.Y < ghost.element.Position.Y + 20 && pacman.element.Position.Y > ghost.element.Position.Y - 20)) return true; return false; }
public void ShouldPrintMapWithPacman_WithCorrectFacingDirection(Direction direction, int row, int column, string expected) { var pacman = new Pacman.Pacman(direction, row, column); var characters = new List <ICharacter> { pacman }; presenter.PrintMap(map, characters); mockio.Verify(x => x.Output(expected), Times.Exactly(1)); }
public void ShouldPrintMapWithPacman_WhenSquareHasPacman() { var pacman = new Pacman.Pacman(Direction.North, 0, 0); var characters = new List <ICharacter> { pacman }; presenter.PrintMap(map, characters); mockio.Verify(x => x.Output("V🍬🍬\n🍬🍬🍬\n🍬🍬🍬"), Times.Exactly(1)); }
public void PacmanGoRightFromX23_StarPlus_StarClearInField() { Field field = new Field(); Pacman.Pacman pacman = new Pacman.Pacman(field); pacman.RealtimeCoordinate = new Coordinate(7, 23); field.NewField[7, 23] = "C"; Assert.IsTrue(pacman.GoRight()); Assert.AreEqual(" ", field.NewField[7, 23]); Assert.AreEqual(1, pacman.stars); }
public void PacmanNotGoLeft_NotStarPlus_NotStarClearInField() { Field field = new Field(); Pacman.Pacman pacman = new Pacman.Pacman(field); pacman.RealtimeCoordinate = new Coordinate(3, 1); field.NewField[3, 1] = "C"; Assert.IsFalse(pacman.GoLeft()); Assert.AreEqual("C", field.NewField[3, 1]); Assert.AreEqual(0, pacman.stars); }
public void TestConstructeur01() { // Mise en place des données // Appel de la méthode à tester Pacman.Pacman pacman = new Pacman.Pacman(20, 10); // Validation des résultats Assert.AreEqual(10, pacman.iPos); Assert.AreEqual(20, pacman.jPos); // Clean-up }
public void ShouldReturnFalse_WhenPacmanIsNotOnSameBlockAsMonster() { var pacman = new Pacman.Pacman(Direction.North, 0, 0); var monster1 = new Monster(1, 1); var monster2 = new Monster(3, 2); var characters = new List <ICharacter> { pacman, monster1, monster2 }; var result = _gameLogic.IsCollisionBetweenPacmanAndMonster(); Assert.False(result); }
public void ShouldPrintPacmanWithMouthClosed_WhenPacmanMouthStatusClosed() { var pacman = new Pacman.Pacman(Direction.North, 0, 0); pacman.Move(Direction.South, 1, 0); var characters = new List <ICharacter> { pacman }; presenter.PrintMap(map, characters); mockio.Verify(x => x.Output("🍬🍬🍬\n|🍬🍬\n🍬🍬🍬"), Times.Exactly(1)); }
public void TestMoveInvalid04() { // Mise en place des données Grid grid = new Grid(); //Bottom right of the map Pacman.Pacman pacman = new Pacman.Pacman(29, 26); // Appel de la méthode à tester Assert.AreEqual(false, pacman.ChangeDirection(Direction.Right, grid)); // Clean-up }
public Main() { InitializeComponent(); paper = pctPlayField.CreateGraphics(); muren = new Muren(); rndAngle = new Random(); splash = new Splash(); #region initialize pacman & ghosts //pacman pacman = new Pacman(); pacman.X = 10; pacman.Y = 12; pacman.Angle = 0; pacman.Wall = 0; pacman.PrevX = 10; pacman.PrevY = 12; pacman.Sprites = pacman.pacmanUp; //red ghost redGhost = new Monster(); redGhost.X = 10; redGhost.Y = 10; redGhost.Angle = 3; redGhost.Wall = 0; redGhost.PrevX = 10; redGhost.PrevY = 10; redGhost.PrevAngle = 0; redGhost.Sprites = Image.FromFile("../../images/ghostRed.png"); //green ghost greenGhost = new Monster(); greenGhost.X = 11; greenGhost.Y = 10; greenGhost.Angle = 3; greenGhost.Wall = 0; greenGhost.PrevX = 11; greenGhost.PrevY = 10; greenGhost.PrevAngle = 0; greenGhost.Sprites = Image.FromFile("../../images/ghostGreen.png"); //yellow ghost yellowGhost = new Monster(); yellowGhost.X = 9; yellowGhost.Y = 10; yellowGhost.Angle = 3; yellowGhost.Wall = 0; yellowGhost.PrevX = 9; yellowGhost.PrevY = 10; yellowGhost.PrevAngle = 0; yellowGhost.Sprites = Image.FromFile("../../images/ghostYellow.png"); #endregion }
public void TestMoveValid01() { // Mise en place des données Grid grid = new Grid(); Pacman.Pacman pacman = new Pacman.Pacman(29, 26); // Validation des résultats Assert.AreEqual(true, pacman.ChangeDirection(Direction.Left, grid)); // Clean-up }
public void PacmanCanNextStep() { Field field = new Field(); Pacman.Pacman pacman = new Pacman.Pacman(field); field.NewField[1, 1] = "C"; field.NewField[1, 2] = "-"; field.NewField[1, 3] = "|"; field.NewField[1, 4] = "_"; Assert.IsFalse(pacman.CanNextStep(new Coordinate(1, 1))); Assert.IsFalse(pacman.CanNextStep(new Coordinate(1, 2))); Assert.IsFalse(pacman.CanNextStep(new Coordinate(1, 3))); Assert.IsFalse(pacman.CanNextStep(new Coordinate(1, 4))); }
public void ShouldPrintMapWithEmptySpace_WhenSquareHasNoDot() { var mapToBeAltered = Map.CreateASampleMap(); mapToBeAltered[0, 0].RemoveDot(); mapToBeAltered[0, 1].RemoveDot(); mapToBeAltered[0, 2].RemoveDot(); var pacman = new Pacman.Pacman(Direction.North, 10, 10); var characters = new List <ICharacter> { pacman }; presenter.PrintMap(mapToBeAltered, characters); mockio.Verify(x => x.Output(" \n🍬🍬🍬\n🍬🍬🍬"), Times.Exactly(1)); }
public bool eatBean(Pacman pacman) { int x = (int)(pacman.element.Position.X / 20); int y = (int)(pacman.element.Position.Y / 20); if (y < 0) y = 0; if (x < 0) x = 0; if (map[y, x] == 1) { map[y, x] = 2; return true; } return false; }
public bool eatBooster(Pacman pacman) { int x = (int)(pacman.element.Position.X / 20); int y = (int)(pacman.element.Position.Y / 20); if (y < 0) y = 0; if (x < 0) x = 0; if (map[y, x] == 3) { map[y, x] = 2; pacman.startInvincible(); return true; } return false; }
public void TestMoveValid02() { // Mise en place des données Grid grid = new Grid(); Pacman.Pacman pacman = new Pacman.Pacman(11, 14); Ghost ghost = new Ghost(GhostNames.blinky); // Appel de la méthode à tester ghost.Update(0, grid, pacman, GhostNames.blinky); // Validation des résultats Assert.AreEqual(true, pacman.ChangeDirection(Direction.Left, grid)); // Clean-up }
public void CheckPoint(Pacman pacman) { foreach (Punkt p in points) { if (p.CAUGHT == false) { //if (new Point(p.X + 2, p.Y + 2) == new Point(pacman.X + 15, pacman.Y + 15)) if(new Rectangle(p.X,p.Y,4,4).IntersectsWith(new Rectangle(pacman.X,pacman.Y,25,25))) { p.CAUGHT = true; HitPoint(p); if (points.Count == 0) { Won(); } } } } }
private void death(Pacman pacman) { pacman.points += 100; alive = false; respawn_time = 10; }
public void move(Labyrinthe laby, Pacman pacman) { int num_dir; int indexRandom = 0; bool forwardPossible = false; bool turnsrightPossible = false; bool turnsleftPossible = false; if (alive) { foreach (string dirtocheck in dirToCheck()) { if (allowedDir(laby, dirtocheck)) { if (0 == dirtocheck.CompareTo(convertDir("forward"))) { indexRandom += 2; forwardPossible = true; } else if (0 == dirtocheck.CompareTo(convertDir("turnsright"))) { indexRandom += 1; turnsrightPossible = true; } else if (0 == dirtocheck.CompareTo(convertDir("turnsleft"))) { indexRandom += 1; turnsleftPossible = true; } } } num_dir = randomNumber(indexRandom); if (forwardPossible && num_dir <= 1) { takeDirection(laby, convertDir("forward")); } else if (forwardPossible && turnsleftPossible && turnsrightPossible) { if (num_dir == 2) { takeDirection(laby, convertDir("turnsright")); } if (num_dir == 3) { takeDirection(laby, convertDir("turnsleft")); } } else if (!forwardPossible && turnsrightPossible && turnsleftPossible) { if (num_dir == 0) { takeDirection(laby, convertDir("turnsright")); } if (num_dir == 1) { takeDirection(laby, convertDir("turnsleft")); } } else if (!forwardPossible && !turnsleftPossible) { takeDirection(laby, convertDir("turnsright")); } else if (!forwardPossible && !turnsrightPossible) { takeDirection(laby, convertDir("turnsleft")); } if (x == pacman.x && y == pacman.y) { if (pacman.super) { death(pacman); } else { pacman.death(laby); } } setPlace(laby); } else { respawn_time--; if (respawn_time == 0) { alive = true; x = 10; y = 9; } } }
private void BaseInitialize(int spookPrototypeIndex, GameLevel level) { GameManager.I.OnObjectForSaveInstantiated(this); pathFinder = new PathFinder(); target = FindObjectOfType<Pacman>(); targetingRatio = GameConst.AI_TARGETING_RATIO[(int)level]; nextActionRefreshTime = GameConst.AI_NEXT_ACTION_REFRESH_RATE[(int)level]; timeForNextAction = nextActionRefreshTime; avatar = ((GameObject)GameObject.Instantiate(MapBuilder.I.spookPrototype[spookPrototypeIndex], GameMap.I.NPCRespawns[UnityEngine.Random.Range(0, GameMap.I.NPCRespawns.Count)], new Quaternion())).GetComponent<Pawn>(); }
public void Update(float time, Grid grid, Pacman pacman, GhostNames name) { totalTime += time; //Frightened if (grid.IsPelletActive) { if (iPos == pacman.iPos && jPos == pacman.jPos) { switch (name) { case GhostNames.blinky: iPos = 11; jPos = 13; Score.EatGhost(); break; case GhostNames.clyde: iPos = 13; jPos = 11; Score.EatGhost(); break; case GhostNames.inky: iPos = 13; jPos = 13; Score.EatGhost(); break; case GhostNames.pinky: iPos = 15; jPos = 13; Score.EatGhost(); break; } } ChangeToFrightenedMode(); distances = PathFinding.InitMoves(distances, iPos, jPos); PathFinding.CalculateMoves(grid, iPos, jPos, pacman.iPos, pacman.jPos, ref distances); nextMove = PathFinding.FindFirstMove(distances, pacman.iPos, pacman.jPos, pacman.iPos, pacman.jPos, nextMove); } //chase else { Score.ResetMultipler(); switch (name) { case GhostNames.blinky: body.FillColor = Color.Red; break; case GhostNames.clyde: body.FillColor = Color.Green; break; case GhostNames.inky: body.FillColor = Color.Cyan; break; case GhostNames.pinky: body.FillColor = Color.Magenta; break; } distances = PathFinding.InitMoves(distances, iPos, jPos); PathFinding.CalculateMoves(grid, iPos, jPos, pacman.iPos, pacman.jPos, ref distances); nextMove = PathFinding.FindFirstMove(distances, pacman.iPos, pacman.jPos, pacman.iPos, pacman.jPos, nextMove); if (iPos == pacman.iPos && jPos == pacman.jPos && !GotPacman) { GotPacman = true; pacman.Caught(); } } if (totalTime > 0.2f) { totalTime = 0; switch (nextMove) { case Direction.Down: jPos++; break; case Direction.Left: iPos--; break; case Direction.Right: iPos++; break; case Direction.Up: jPos--; break; } } }
private void CreateLevel() { StreamReader file = new StreamReader("level.txt"); while (!file.EndOfStream) level_data.Add(file.ReadLine()); file.Close(); for (int i = 0; i < level_data.Count; i++) tile_Y += 1; for (int j = 0; j < level_data[1].Length; j++) tile_X += 1; level = new Tile[tile_Y, tile_X]; for (int i = 0; i < level_data.Count; i++) { for (int j = 0; j < level_data[i].Length; j++) { if (level_data[i][j] == 'x') { level[i, j] = new Tile(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(0, 0, 16, 16)); } else if (level_data[i][j] == 'f') { level[i, j] = new Tile(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(16, 0, 16, 16)); Food f = new Food(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(0, 16, 16, 16)); food.Add(f); } else if (level_data[i][j] == 'r' || level_data[i][j] == 'm' || level_data[i][j] == 'b' || level_data[i][j] == 'o') { level[i, j] = new Tile(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(16, 0, 16, 16)); Food f = new Food(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(0, 16, 16, 16)); food.Add(f); Character g = new Ghost(character_sheet, new Vector2(j * 16, i * 16), level_data); ghosts.Add(g); } else if (level_data[i][j] == 'p') { level[i, j] = new Tile(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(16, 0, 16, 16)); Food f = new Food(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(0, 16, 16, 16)); food.Add(f); pacman_startpos = new Vector2(j * 16, i * 16); pacman = new Pacman(character_sheet, new Vector2(j * 16, i * 16), level_data, pacman_startpos); } else if (level_data[i][j] == 'e') { level[i, j] = new Tile(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(16, 16, 16, 16)); } } } }
private void Form1_Load(object sender, EventArgs e) { _signalR.RegisterPlayer(); // Create Board Matrix Tuple <int, int> PacmanStartCoordinates = gameboard.InitialiseBoardMatrix(1); SetupGame(1); playerData.RegisterObserver(player); playerData.RegisterObserver(highscore); _hubConnection.On("ReceiveRegisterCompletedMessage", () => { facade.Log.AppendText($"\nWait until your friend opens this game then press F1 to join the game!\n" + $"Player1 plays with blue pacman, Player2 plays with red.\n"); facade.Log.AppendText($"\nPlayer lives: {player.Lives}"); }); _hubConnection.On <string>("ReceiveConnectedMessage", (connnectionId) => { this.Invoke((Action)(() => { Player newPlayer = new Player(connnectionId, "Player" + (players.Count + 1)); _api.CreatePlayer(newPlayer); players.Add(newPlayer); if (players.Count == 2) { // Decrator pacman = blueFactory.CreatePacman(_signalR, players.First().Id); //pacman = new PinkBorderDecorator(pacman); pacman.AddPacmanImages(); opponent = redFactory.CreatePacman(_signalR, players.Last().Id); opponent.AddPacmanImages(); pacmans.Add(pacman); pacmans.Add(opponent); moveUp = new MoveUpCommand(opponent); moveDown = new MoveDownCommand(opponent); moveRight = new MoveRightCommand(opponent); moveLeft = new MoveLeftCommand(opponent); ghost.EnableTimer(); foreach (var p in pacmans) { p.CreatePacmanImage(this, PacmanStartCoordinates.Item1, PacmanStartCoordinates.Item2); p.EnableTImer(); } // For Observer testing playerData.EditLives(5); facade.Log.AppendText($"\nPlayer lives: {player.Lives}"); } facade.Log.AppendText($"\n{newPlayer.Name} with id {connnectionId} joined the game!" + $"\nTotal players: {players.Count}"); })); }); _hubConnection.On <int, int, int, string>("ReceivePacmanCoordinates", (xCoordinate, yCoordinate, direction, id) => { this.Invoke((Action)(() => { // Logging movement Pacman currentPacman = pacmans.Single(p => p.Id == id); Player currentPlayer = players.Single(p => p.Id == id); _pacmanLogAdapter = new PacmanLogAdapter(currentPacman); _playerLogAdapter = new PlayerLogAdapter(currentPlayer); _fileLogger.LogData(string.Format("pacman ID: {0} | xCoordinate:{1} | yCordinate:{2} | date:{3}", currentPacman.Id, currentPacman.xCoordinate, currentPacman.yCoordinate, DateTime.UtcNow)); _pacmanLogAdapter.LogData(null); _playerLogAdapter.LogData(null); facade.Log.ScrollToCaret(); pacmans.Single(p => p.Id == id).nextDirection = direction; })); }); }
public Main() { InitializeComponent(); paper = pctPlayField.CreateGraphics(); muren = new Muren(); rndAngle = new Random(); splash = new Splash(); #region initialize pacman & ghosts //pacman pacman = new Pacman(); pacman.X = 10; pacman.Y = 12; pacman.Angle = 0; pacman.Wall = 0; pacman.PrevX = 10; pacman.PrevY = 12; pacman.Sprites = pacman.pacmanUp; //red ghost redGhost = new Monster(); redGhost.X = 10; redGhost.Y = 10; redGhost.Angle = 3; redGhost.Wall = 0; redGhost.PrevX = 10; redGhost.PrevY = 10; redGhost.PrevAngle = 0; redGhost.Sprites = Image.FromFile("../../images/ghostRed.png"); //green ghost greenGhost = new Monster(); greenGhost.X = 11; greenGhost.Y = 10; greenGhost.Angle = 3; greenGhost.Wall = 0; greenGhost.PrevX = 11; greenGhost.PrevY = 10; greenGhost.PrevAngle = 0; greenGhost.Sprites = Image.FromFile("../../images/ghostGreen.png"); //yellow ghost yellowGhost = new Monster(); yellowGhost.X = 9; yellowGhost.Y = 10; yellowGhost.Angle = 3; yellowGhost.Wall = 0; yellowGhost.PrevX = 9; yellowGhost.PrevY = 10; yellowGhost.PrevAngle = 0; yellowGhost.Sprites = Image.FromFile("../../images/ghostYellow.png"); //Add black ghost to board //black ghost blackGhost = new Monster(); blackGhost.X = 8; blackGhost.Y = 10; blackGhost.Angle = 3; blackGhost.Wall = 0; blackGhost.PrevX = 8; blackGhost.PrevY = 10; blackGhost.PrevAngle = 0; blackGhost.Sprites = Image.FromFile("../../images/ghostBlack.png"); #endregion }
public Mappa(Image sfondo, List <int[]> zonaNavigabileOrizzontale, List <int[]> zonaNavigabileVerticale, Pacman pacman, int coordinataXPacman, int coordinataYPacman, int direzioneInizialePacman, Timer pacmanSpeed, List <int[]> pilloleOrizzontale, List <int[]> pilloleVerticale, List <int[]> pilloleSpeciali) { circonferenzaPath = new GraphicsPath(); circonferenzaPath.AddEllipse(0, 0, 12, 12); this.zonaNavigabileOrizzontale = zonaNavigabileOrizzontale; this.zonaNavigabileVerticale = zonaNavigabileVerticale; this.coordinataXPacman = coordinataXPacman; this.coordinataYPacman = coordinataYPacman; this.pacman = pacman; this.Controls.Add(pacman); this.Image = sfondo; this.BackColor = Color.Black; this.Size = sfondo.Size; this.pilloleOrizzontale = pilloleOrizzontale; this.pilloleVerticale = pilloleVerticale; this.pilloleSpeciali = pilloleSpeciali; this.ritardoRipristina.Intervallo = 2000; this.ritardoRipristina.Tick += Ripristina; this.pacmanSpeed_ = pacmanSpeed; this.pacmanSpeed = pacmanSpeed.Intervallo; this.direzioneInizialePacman = direzioneAttuale = direzioneInizialePacman; pacmanSpeed_.Tick += spostaPacman; posizionaPacman(); posizionaPillole(); }
public void PlayerMoveSpeed(Pacman pacman) { moveAlgorithm.PlayerMoveSpeed(pacman); }
void CreatePacman(int x_pacman, int y_pacman) { pacman = new Pacman(x_pacman, y_pacman, sizeObjects); ChangeTempMatrix(x_pacman, y_pacman, 3); // Внесение пакмена на временную матрицу ( 3 - обозначение пакмена) }
public PacmanGame() { map = new byte[VY, VX]{ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 0}, {0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}, {0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0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0, 0, 0, 0, 0, 1, 0}, {0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0}, {0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, }; pacman = new Pacman(this); ghosts = new List<Ghost>(); ghosts.Add(new Ghost(this, "red")); System.Threading.Thread.Sleep(50); ghosts.Add(new Ghost(this, "blue")); System.Threading.Thread.Sleep(50); ghosts.Add(new Ghost(this, "pink")); System.Threading.Thread.Sleep(50); ghosts.Add(new Ghost(this, "green")); joueur = new Joueur(); graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; engine = new GameEngine(map, VX, VY); messages = new List<Message>(); }
public Enemy(Pacman pacman) : this() { _pacman = pacman; Enemy_Movement += new Enemy_Movement(Enemy_Enemy_Movement); }
public PacmanDriver(Pacman pacman) { this.Pacman = pacman; }
public Mappa(Image sfondo, List <int[]> zonaNavigabileOrizzontale, List <int[]> zonaNavigabileVerticale, Pacman pacman, int coordinataXPacman, int coordinataYPacman, int direzioneInizialePacman, Timer pacmanSpeed, List <int[]> pilloleOrizzontale, List <int[]> pilloleVerticale, List <int[]> pilloleSpeciali, Ghost[] ghosts, ref datiGhost[] datiGhosts, int[,] zoneSpeciali) : this(sfondo, zonaNavigabileOrizzontale, zonaNavigabileVerticale, pacman, coordinataXPacman, coordinataYPacman, direzioneInizialePacman, pacmanSpeed, pilloleOrizzontale, pilloleVerticale, pilloleSpeciali) { this.zoneSpeciali = zoneSpeciali; this.ghosts = ghosts; this.datiGhosts = datiGhosts; for (int i = 0; i < ghosts.Length; i++) { this.Controls.Add(this.ghosts[i]); this.ghosts[i].Location = datiGhosts[i].puntoPartenza; this.ghosts[i].BringToFront(); this.ghosts[i].Tag = i; this.ghosts[i].fineAfraid += velocitaNormaleGhost; datiGhosts[i].speed.Tick += spostaGhost; datiGhosts[i].durataMorte.Tick += rinascitaGhost; datiGhosts[i].vivoMorto = true; } pacman.BringToFront(); }
public void Move(Pacman pacman, Random randy) { if (onhorizontalline == true && onvertikalline == true) { int s = randy.Next(1, 5); int r = randy.Next(1, 4); RandomDir(pacman,r,s); } switch (direction) { case Direction_G.RIGHT: if (this.pb.Left < 645) { this.pb.Left = this.pb.Left + schrittweite; } if ((this.pb.Left - 5) % 40 == 0) { onvertikalline = true; onhorizontalline = true; } else { onvertikalline = false; onhorizontalline = true; } break; case Direction_G.LEFT: if (this.pb.Left > 5) { this.pb.Left = this.pb.Left - schrittweite; } if ((this.pb.Left - 5) % 40 == 0) { onvertikalline = true; onhorizontalline = true; } else { onvertikalline = false; onhorizontalline = true; } break; case Direction_G.UP: if (this.pb.Top > 5) { this.pb.Top = this.pb.Top - schrittweite; } if ((this.pb.Top - 5) % 40 == 0) { onhorizontalline = true; onvertikalline = true; } else { onvertikalline = true; onhorizontalline = false; } break; case Direction_G.DOWN: if (this.pb.Top < 365) { this.pb.Top = this.pb.Top + schrittweite; } if ((this.pb.Top - 5) % 40 == 0) { ONHORIZONTALLINE = true; onvertikalline = true; } else { onvertikalline = true; onhorizontalline = false; } break; } }
public GameBoardFacade() { enemies = new List <Enemy>(); player = new Pacman(); guiAdapter = new GuiAdapter(); }
// case 1 u. 2 = KI , case 3 = Random private void RandomDir(Pacman pacman, int randy, int randy2) { switch (randy) { case 1: if (pacman.Y < this.pb.Top) { direction = Direction_G.UP; } if (pacman.Y > this.pb.Top) { direction = Direction_G.DOWN; } if (pacman.Y == this.pb.Top) { if (pacman.X < this.pb.Left) { direction = Direction_G.LEFT; } if (pacman.X > this.pb.Left) { direction = Direction_G.RIGHT; } } break; case 2: if (pacman.X < this.pb.Left) { direction = Direction_G.LEFT; } if (pacman.X > this.pb.Left) { direction = Direction_G.RIGHT; } if (pacman.X == this.pb.Left) { if (pacman.Y < this.pb.Top) { direction = Direction_G.UP; } if (pacman.Y > this.pb.Top) { direction = Direction_G.DOWN; } } break; case 3: switch (randy2) { case 1: direction = Direction_G.DOWN; break; case 2: direction = Direction_G.UP; break; case 3: direction = Direction_G.RIGHT; break; case 4: direction = Direction_G.LEFT; break; } break; } }
public bool CheckPoint(Pacman pacman) { //if (new Point(this.pb.Left + 15, this.pb.Top + 15) == new Point(pacman.X + 15, pacman.Y + 15)) if(new Rectangle(this.pb.Left, this.pb.Top,25,25).IntersectsWith(new Rectangle(pacman.X,pacman.Y,25,25))) { pacman.X = 5; pacman.Y = 5; return true; } return false; }
static void Main() { //İmleci Görünmez yapmak için Console.CursorVisible = false; // //Sound Effects // SoundPlayer Walk = new SoundPlayer(); Walk.SoundLocation = Environment.CurrentDirectory + "\\SFX/Walk.wav"; SoundPlayer Gover = new SoundPlayer(); Gover.SoundLocation = Environment.CurrentDirectory + "\\SFX/GameOver.wav"; SoundPlayer Victory = new SoundPlayer(); Victory.SoundLocation = Environment.CurrentDirectory + "\\SFX/Victory.wav"; // //LOADING // Loading(); // //Mega Yem // Yem[] Yemlik = new Yem[6]; int[,] Konum = new int[6, 2] { { 9, 5 }, { 9, 16 }, { 32, 5 }, { 32, 16 }, { 19, 2 }, { 22, 19 } }; for (int i = 0; i < 6; i++) { Yem k1 = new Yem(); k1.X = Konum[i, 0]; k1.Y = Konum[i, 1]; Yemlik[i] = k1; } // //Mini Yem // MiniYem[] Puan = new MiniYem[22]; int[,] Local = new int[22, 2] { { 11, 4 }, { 11, 6 }, { 30, 4 }, { 30, 6 }, { 19, 8 }, { 22, 8 }, { 11, 15 }, { 11, 17 }, { 30, 15 }, { 30, 17 }, { 19, 13 }, { 22, 13 }, { 3, 8 }, { 38, 8 }, { 3, 13 }, { 38, 13 }, { 18, 3 }, { 23, 18 }, { 4, 5 }, { 4, 16 }, { 37, 5 }, { 37, 16 } }; //{18,3},{23,18},{4,5},{4,16},{37,5},{37,16} Pacman CLU = new Pacman(); for (int i = 0; i < 22; i++) { MiniYem k2 = new MiniYem(); k2.X = Local[i, 0]; k2.Y = Local[i, 1]; Puan[i] = k2; } // //Green Ghost Object // Ghost Enemy = new Ghost(); Enemy.X = 15; Enemy.Y = 18; Enemy.BColor = ConsoleColor.Green; Enemy.FColor = ConsoleColor.DarkMagenta; int AdımX = 15; int AdımY = 18; byte flag = 0; // //Red Ghost Object // Ghost Jelly = new Ghost(); Jelly.X = 15; Jelly.Y = 18; Jelly.BColor = ConsoleColor.Red; Jelly.FColor = ConsoleColor.Gray; int StepX = 26; int StepY = 3; byte Bayrak = 0; bool Game = true; ConsoleKeyInfo Key = Console.ReadKey(); bool isKeyPressed = false; Console.Clear(); //Menu.Stop(); DrawFrame(); PacMap.Map(); //bool Game = false; Walk.PlayLooping(); while (Game) { //PacMap.Map(); //Key = Console.ReadKey(); CLU.PacMove(Key); if (Console.KeyAvailable) { Key = Console.ReadKey(); isKeyPressed = true; } else { isKeyPressed = false; } CLU.PacMove(Key, isKeyPressed); CLU.PacManCiz(); // //Green Ghost // Enemy.tX = Enemy.X; Enemy.tY = Enemy.Y; Enemy.X = AdımX; Enemy.Y = AdımY; if (((Enemy.X == CLU.X) && (Enemy.Y == CLU.Y)) || ((Enemy.tX == CLU.X) && (Enemy.tY == CLU.X)) || ((Enemy.X == CLU.tX) && (Enemy.X == CLU.tY)) || ((Enemy.tX == CLU.tX) && (Enemy.tY == CLU.tY))) { Gover.Play(); Game = false; } Enemy.Ciz(); Enemy.Move(Enemy.tX, Enemy.tY); if (flag == 0) { AdımY--; AdımX = 15; if (AdımY <= 3) { flag = 1; } } else if (flag == 1) { AdımY = 3; AdımX--; if (AdımX <= 7) { flag = 2; } } else if (flag == 2) { AdımY = 3; AdımX++; if (AdımX >= 15) { flag = 3; } } else if (flag == 3) { AdımY++; AdımX = 15; if (AdımY >= 18) { flag = 0; } } // // //Red Ghost // Jelly.tX = Jelly.X; Jelly.tY = Jelly.Y; Jelly.X = StepX; Jelly.Y = StepY; if ((Jelly.X == CLU.X) && (Jelly.Y == CLU.Y)) { Gover.Play(); Game = false; } Jelly.Ciz(); Jelly.Move(Jelly.tX, Jelly.tY); if (Bayrak == 0) { StepY++; StepX = 26; if (StepY >= 18) { Bayrak = 1; } } else if (Bayrak == 1) { StepY = 18; StepX++; if (StepX >= 34) { Bayrak = 2; } } else if (Bayrak == 2) { StepY = 18; StepX--; if (StepX <= 26) { Bayrak = 3; } } else if (Bayrak == 3) { StepY--; StepX = 26; if (StepY <= 3) { Bayrak = 0; } } // //PacMap PacMap.Map(); for (int i = 0; i < 6; i++) { Yemlik[i].YemCiz(); if (((Yemlik[i].X == CLU.X) && (Yemlik[i].Y == CLU.Y)) && (Yemlik[i].Exist == true)) { Yemlik[i].Exist = false; CLU.PacManCiz(); CLU.Score += 20; //Walk.Play(); } } // for (int i = 0; i < 22; i++) { Puan[i].YemCiz(); if (((Puan[i].X == CLU.X) && (Puan[i].Y == CLU.Y)) && (Puan[i].Exist == true)) { Puan[i].Exist = false; CLU.PacManCiz(); CLU.Score += 5; //Walk.Play(); } } // //DrawFrame DrawFrame(); //Thread.Sleep(20); CLU.PrintScore(); // //Score Limit // if (CLU.Score >= 230) { Walk.Stop(); Victory.Play(); Game = false; } Thread.Sleep(100); } if (CLU.Score < 230) { GameOver(CLU.Score); } else { GameWon(CLU.Score); } bool ReGame = Replay(); if (ReGame == true) { Main(); } else { Environment.Exit(0); } }
public GamePacman(int _lives, int _ghosts) //кол-во жизней pacman, кол-во привидений в игре { Console.WindowHeight = 40; Console.WindowWidth = 148; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(); Console.WriteLine(); Thread.Sleep(50); Console.WriteLine(); Thread.Sleep(50); Console.WriteLine(); Thread.Sleep(50); Console.WriteLine(); Thread.Sleep(50); Console.WriteLine(); Thread.Sleep(50); Console.WriteLine(); Thread.Sleep(50); Console.WriteLine(); Thread.Sleep(50); Console.WriteLine(); Console.WriteLine("PPPPPPPPPPPPPPPPP AAA CCCCCCCCCCCCCMMMMMMMM MMMMMMMM AAA NNNNNNNN NNNNNNNN"); Thread.Sleep(200); Console.WriteLine("P::::::::::::::::P A:::A CCC::::::::::::CM:::::::M M:::::::M A:::A N:::::::N N::::::N"); Thread.Sleep(200); Console.WriteLine("P::::::PPPPPP:::::P A:::::A CC:::::::::::::::CM::::::::M M::::::::M A:::::A N::::::::N N::::::N"); Thread.Sleep(200); Console.WriteLine("PP:::::P P:::::P A:::::::A C:::::CCCCCCCC::::CM:::::::::M M:::::::::M A:::::::A N:::::::::N N::::::N"); Thread.Sleep(200); Console.WriteLine(" P::::P P:::::P A:::::::::A C:::::C CCCCCCM::::::::::M M::::::::::M A:::::::::A N::::::::::N N::::::N"); Thread.Sleep(200); Console.WriteLine(" P::::P P:::::PA:::::A:::::A C:::::C M:::::::::::M M:::::::::::M A:::::A:::::A N:::::::::::N N::::::N"); Thread.Sleep(200); Console.WriteLine(" P::::PPPPPP:::::PA:::::A A:::::A C:::::C M:::::::M::::M M::::M:::::::M A:::::A A:::::A N:::::::N::::N N::::::N"); Thread.Sleep(200); Console.WriteLine(" P:::::::::::::PPA:::::A A:::::A C:::::C M::::::M M::::M M::::M M::::::M A:::::A A:::::A N::::::N N::::N N::::::N"); Thread.Sleep(200); Console.WriteLine(" P::::PPPPPPPPP A:::::A A:::::A C:::::C M::::::M M::::M::::M M::::::M A:::::A A:::::A N::::::N N::::N:::::::N"); Thread.Sleep(200); Console.WriteLine(" P::::P A:::::AAAAAAAAA:::::A C:::::C M::::::M M:::::::M M::::::M A:::::AAAAAAAAA:::::A N::::::N N:::::::::::N"); Thread.Sleep(200); Console.WriteLine(" P::::P A:::::::::::::::::::::AC:::::C M::::::M M:::::M M::::::M A:::::::::::::::::::::A N::::::N N::::::::::N"); Thread.Sleep(200); Console.WriteLine(" P::::P A:::::AAAAAAAAAAAAA:::::AC:::::C CCCCCCM::::::M MMMMM M::::::M A:::::AAAAAAAAAAAAA:::::A N::::::N N:::::::::N"); Thread.Sleep(200); Console.WriteLine("PP::::::PP A:::::A A:::::AC:::::CCCCCCCC::::CM::::::M M::::::M A:::::A A:::::A N::::::N N::::::::N"); Thread.Sleep(200); Console.WriteLine("P::::::::P A:::::A A:::::ACC:::::::::::::::CM::::::M M::::::M A:::::A A:::::A N::::::N N:::::::N"); Thread.Sleep(200); Console.WriteLine("P::::::::P A:::::A A:::::A CCC::::::::::::CM::::::M M::::::M A:::::A A:::::A N::::::N N::::::N"); Thread.Sleep(200); Console.WriteLine("PPPPPPPPPPAAAAAAA AAAAAAA CCCCCCCCCCCCCMMMMMMMM MMMMMMMMAAAAAAA AAAAAAANNNNNNNN NNNNNNN"); Console.WriteLine(); Console.WriteLine("Use the arrow keys to play!"); Console.WriteLine(); Console.WriteLine("Press ANY key to continue"); Console.WriteLine("Esc - exit"); ConsoleKeyInfo keyInfo2; keyInfo2 = Console.ReadKey(); switch (keyInfo2.Key) { case ConsoleKey.Escape: System.Environment.Exit(0); break; default: Console.WriteLine("\t\t\t|"); gameField = new Field(); pacman = new Pacman(gameField); score = 0; if (_lives > 0 && _lives < 5) { lives = _lives; } else { lives = 2; } if (_ghosts > 0 && _ghosts < 5) { ghosts = new List <GHost>(); for (int i = 0; i < _ghosts; i++) { ghosts.Add(new GHost(gameField)); } } else { ghosts = new List <GHost>() { new GHost(gameField), new GHost(gameField) }; } SetGhosts(); break; } }
protected virtual void PacmanInteraction(Pacman pacman) { // sorry :( }
static void Main() { using (var game = new Pacman()) game.Run(); }