/// <summary> /// Prompts creatures to be painted on grid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void dataGrid_Paint(object sender, PaintEventArgs e) { pacman.Draw(e.Graphics); for (int i = 0; i < ghost.Length; i++) { ghost[i].Draw(e.Graphics); } }
//Drawing event. Малювання об'єктів private void boardPB_Paint(object sender, PaintEventArgs e) { //e.Graphics.InterpolationMode = InterpolationMode.High; items.Draw(e.Graphics); pacman.Draw(e.Graphics); blinky.Draw(e.Graphics); pinky.Draw(e.Graphics); inky.Draw(e.Graphics); clyde.Draw(e.Graphics); }
private void Draw(Graphics g) { //draw layers backLayer.Draw(g); foodLayer.Draw(g); //draw pacman pacMan.Draw(g); //draw ghosts for (int i = 0; i < GameObjects.Count; i++) { GameObjects[i].Draw(g); } //draw score g.DrawString("Score: " + totalScore, new Font("Arial", 12f, FontStyle.Bold), new SolidBrush(Color.Yellow), new Point(0, 0)); //draw StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; //is game over if (this.isGameOver && this.isGameWon == false) { g.DrawString("GAME OVER", new Font("Arial", 32f, FontStyle.Bold), new SolidBrush(Color.Yellow), GameEngine.GameFieldSize().Width / 2, GameEngine.GameFieldSize().Height / 3, stringFormat); g.DrawString("Press ENTER for new game", new Font("Arial", 18f, FontStyle.Bold), new SolidBrush(Color.Yellow), GameEngine.GameFieldSize().Width / 2, GameEngine.GameFieldSize().Height / 2, stringFormat); } //is game won if (this.isGameOver && this.isGameWon) { g.DrawString("WINNER!", new Font("Arial", 32f, FontStyle.Bold), new SolidBrush(Color.Yellow), GameEngine.GameFieldSize().Width / 2, GameEngine.GameFieldSize().Height / 3, stringFormat); g.DrawString("Press ENTER for new game", new Font("Arial", 18f, FontStyle.Bold), new SolidBrush(Color.Yellow), GameEngine.GameFieldSize().Width / 2, GameEngine.GameFieldSize().Height / 2, stringFormat); } //is power up active if (this.isGameOver == false && pacMan.HasPower) { g.DrawString("POWER UP ACTIVATED!", new Font("Arial", 24f, FontStyle.Bold), new SolidBrush(Color.Yellow), GameEngine.GameFieldSize().Width / 2, GameEngine.GameFieldSize().Height / 4, stringFormat); } //if game is paused if (this.isPaused) { g.DrawString("GAME PAUSED", new Font("Arial", 24f, FontStyle.Bold), new SolidBrush(Color.Yellow), GameEngine.GameFieldSize().Width / 2, GameEngine.GameFieldSize().Height / 2, stringFormat); } }
private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; g.Clear(Color.White); for (int i = 0; i < WORLD_HEIGHT; i++) { for (int j = 0; j < WORLD_WIDTH; j++) { if (foodWorld[i, j]) { g.DrawImageUnscaled(foodImage, -10 + j * PacMan.Radius * 2 + (PacMan.Radius * 2 - foodImage.Height) / 2, -5 + i * PacMan.Radius * 2 + (PacMan.Radius * 2 - foodImage.Width) / 2); } } } pacman.Draw(g); }