//Drawing Pac-Man. Малювання пакмена public void Draw(Graphics gr) { PointF drawLocation = PacForm.drawCoord(location); gr.DrawImage(currentSprite, drawLocation.X, drawLocation.Y); //Draw Lives. Малювання кількості спроб for (int i = 2; i < lives * 2 + 2; i += 2) { PointF livesLocation = PacForm.coordToPixelCorner(new Point(i, 34)); gr.DrawImage(pacmanSprites[4], livesLocation.X, livesLocation.Y); } //coordinates debug //using (Font myFont = new Font("Arial", 14)) //{ // gr.DrawString(location.X.ToString() + "x" + location.Y.ToString(), myFont, Brushes.Red, new PointF(location.X, location.Y)); //} //coords as squares debug //using (Font myFont = new Font("Arial", 14)) //{ // Point coord = PacForm.pixelToCoord(location); // gr.DrawString(coord.X.ToString() + "x" + coord.Y.ToString(), myFont, Brushes.Red, new PointF(location.X, location.Y)); //} //chase-scatter debug //using (Font myFont = new Font("Arial", 14)) //{ // if (Ghost.scatter) gr.DrawString("SCATTER", myFont, Brushes.Red, new PointF(location.X, location.Y)); // else gr.DrawString("CHASE", myFont, Brushes.Red, new PointF(location.X, location.Y)); //} //using (Brush brush = new SolidBrush(Color.Green)) //{ // int size = PacForm.BoardTileSize * PacForm.SpriteScale; // gr.FillRectangle(brush, location.X, location.Y, size, size); //} //using (Font myFont = new Font("Arial", 14)) //{ // gr.DrawString(String.Format("\n{0:F4}",speed), myFont, Brushes.Red, new PointF(location.X, location.Y)); // gr.DrawString(location.X.ToString() + "x" + location.Y.ToString(), myFont, Brushes.Red, new PointF(location.X, location.Y)); //} //using (Pen pen = new Pen(Color.Red, 2)) //{ // gr.DrawRectangle(pen, 0, 0, size, size); //} }
//Draw sprite on screen //Малювання персонажу на екрані public void Draw(Graphics gr) { PointF drawLocation = PacForm.drawCoord(location); gr.DrawImage(currentSprite, drawLocation.X, drawLocation.Y); //debug text //using (Font myFont = new Font("Arial", 14)) //{ // gr.DrawString(eatenAll.ToString(), myFont, System.Drawing.Brushes.Red, new PointF(location.X, location.Y)); //} //debug targeting //using (Brush brush = new SolidBrush(color)) //{ // int size = PacForm.BoardTileSize * PacForm.SpriteScale; // gr.FillRectangle(brush, PacForm.coordToPixelCorner(GetTarget()).X, PacForm.coordToPixelCorner(GetTarget()).Y, size, size); //} }