Exemple #1
0
        //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);
            //}
        }
Exemple #2
0
 public Pinky(PacForm frm) : base(frm)
 {
     ghostNumber            = 1;
     color                  = Color.Pink;
     SpriteRight            = 512;
     SpriteRight2           = 514;
     SpriteDown             = 516;
     SpriteDown2            = 518;
     SpriteLeft             = 520;
     SpriteLeft2            = 522;
     SpriteUp               = 524;
     SpriteUp2              = 526;
     home                   = PacForm.coordToPixelCenter(new Point(14, 17));
     scatterTarget          = new Point(2, 0);
     stayAtHomeWayPointUp   = PacForm.coordToPixelCorner(new Point(14, 17));
     stayAtHomeWayPointDown = PacForm.coordToPixelCorner(new Point(14, 18));
     MakeWaypoints();
     MakeSprites();
     ResetPosition();
 }
Exemple #3
0
 public Inky(PacForm frm) : base(frm)
 {
     ghostNumber            = 2;
     color                  = Color.Aqua;
     SpriteRight            = 528;
     SpriteRight2           = 530;
     SpriteDown             = 532;
     SpriteDown2            = 534;
     SpriteLeft             = 536;
     SpriteLeft2            = 538;
     SpriteUp               = 540;
     SpriteUp2              = 542;
     home                   = PacForm.coordToPixelCenter(new Point(12, 17));
     scatterTarget          = new Point(27, 35);
     stayAtHomeWayPointUp   = PacForm.coordToPixelCorner(new Point(12, 17));
     stayAtHomeWayPointDown = PacForm.coordToPixelCorner(new Point(12, 18));
     MakeWaypoints();
     MakeSprites();
     ResetPosition();
 }
Exemple #4
0
 public Clyde(PacForm frm) : base(frm)
 {
     ghostNumber            = 3;
     color                  = Color.Orange;
     SpriteRight            = 576;
     SpriteRight2           = 578;
     SpriteDown             = 580;
     SpriteDown2            = 582;
     SpriteLeft             = 584;
     SpriteLeft2            = 586;
     SpriteUp               = 588;
     SpriteUp2              = 590;
     home                   = PacForm.coordToPixelCenter(new Point(15, 17));
     scatterTarget          = new Point(0, 35);
     stayAtHomeWayPointUp   = PacForm.coordToPixelCorner(new Point(16, 17));
     stayAtHomeWayPointDown = PacForm.coordToPixelCorner(new Point(16, 18));
     MakeWaypoints();
     MakeSprites();
     ResetPosition();
 }
Exemple #5
0
        public Items(PacForm frm)
        {
            //0 wall
            //1 free
            //2 dot
            //3 superdot
            //4 bonus fruit
            //5 slow terrain
            random = new Random();
            form   = frm;
            //itemsMap = new int[form.board.size.Width, form.board.size.Height];
            itemsMap = new int[, ] {
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0 },
                { 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0 },
                { 0, 3, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0 },
                { 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0 },
                { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0 },
                { 0, 2, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 2, 0 },
                { 0, 2, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 2, 0 },
                { 0, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 0 },
                { 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0 },
                { 5, 5, 5, 5, 5, 5, 2, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 2, 5, 5, 5, 5, 5, 5 },
                { 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 1, 1, 1, 4, 4, 1, 1, 1, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0 },
                { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0 },
                { 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0 },
                { 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0 },
                { 0, 3, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 3, 0 },
                { 0, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 0 },
                { 0, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 0 },
                { 0, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 0 },
                { 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0 },
                { 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0 },
                { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            };
            powerPelletVisible  = true;
            blinkTimer          = new Timer();
            blinkTimer.Interval = 150;
            blinkTimer.Enabled  = true;
            blinkTimer.Tick    += new EventHandler(tmr_Blink);
            fruitTimer          = new Timer();
            //NextDouble() * (max - min) + min
            fruitTimer.Interval     = random.Next(9000, 10001);
            fruitTimer.Tick        += new EventHandler(HideFruit);
            hideScoreTimer          = new Timer();
            hideScoreTimer.Tick    += new EventHandler(HideScore);
            hideScoreTimer.Interval = 3000;
            Sprites               = new List <Bitmap>();
            bonusFruitLocation    = PacForm.coordToPixelCorner(new Point(13, 19));
            bonusFruitLocation.Y += PacForm.unitCenter;
            score1coord           = PacForm.coordToPixelCorner(new Point(12, 20));
            score2coord           = PacForm.coordToPixelCorner(new Point(13, 20));
            score3coord           = PacForm.coordToPixelCorner(new Point(14, 20));
            score4coord           = PacForm.coordToPixelCorner(new Point(15, 20));

            ghostDotCounter = new int[4];
            dotStopwatch    = new Stopwatch();

            InitializeSound();

            MakeSprites();
        }
Exemple #6
0
        //Display items on the board. Малювання предметів на ігровому полі
        public void Draw(Graphics gr)
        {
            dots = 0;
            using (Bitmap result = new Bitmap(form.board.boardPBSize.Width, form.board.boardPBSize.Height))
            {
                using (Graphics tempGr = Graphics.FromImage(result))
                {
                    for (int i = 0; i < form.board.size.Height; i++)
                    {
                        for (int j = 0; j < form.board.size.Width; j++)
                        {
                            if (itemsMap[i, j] == 2)
                            {
                                tempGr.DrawImage(Sprites[0], PacForm.coordToPixelCorner(new Point(j, i)));
                                dots++;
                            }
                            if (powerPelletVisible)
                            {
                                if (itemsMap[i, j] == 3)
                                {
                                    tempGr.DrawImage(Sprites[1], PacForm.coordToPixelCorner(new Point(j, i)));
                                }
                            }
                        }
                    }
                    //Draw bonus fruit. Малювання фрукту, який можна з'їсти
                    if (fruitTime)
                    {
                        tempGr.DrawImage(Sprites[form.levels.get_bonusSymbol()], bonusFruitLocation);
                    }


                    //Draw level fruits. Малювання фруктів на позначення рівня
                    int startingLevelToDraw = 0;
                    if (form.levels.get_level() > 5)
                    {
                        startingLevelToDraw = form.levels.get_level() - 5;
                    }
                    int numberOfFruitsToDraw = 0;
                    if (form.levels.get_level() < 5)
                    {
                        numberOfFruitsToDraw = form.levels.get_level() + 1;
                    }
                    else
                    {
                        numberOfFruitsToDraw = 6;
                    }
                    for (int pos = 24, lvl = startingLevelToDraw; pos >= 26 - numberOfFruitsToDraw * 2; pos -= 2, lvl++)
                    {
                        PointF fruitLocation = PacForm.coordToPixelCorner(new Point(pos, 34));
                        tempGr.DrawImage(form.items.Sprites[form.levels.get_bonusSymbol(lvl)], fruitLocation.X, fruitLocation.Y);
                    }

                    //Draw score after eating fruit. Малювання балів за з'їдені фрукти
                    if (showScore)
                    {
                        switch (form.levels.get_level())
                        {
                        case 0:
                            tempGr.DrawImage(Sprites[10], score2coord);
                            tempGr.DrawImage(Sprites[14], score3coord);
                            break;

                        case 1:
                            tempGr.DrawImage(Sprites[11], score2coord);
                            tempGr.DrawImage(Sprites[14], score3coord);
                            break;

                        case 2:
                        case 3:
                            tempGr.DrawImage(Sprites[12], score2coord);
                            tempGr.DrawImage(Sprites[14], score3coord);
                            break;

                        case 4:
                        case 5:
                            tempGr.DrawImage(Sprites[13], score2coord);
                            tempGr.DrawImage(Sprites[14], score3coord);
                            break;

                        case 6:
                        case 7:
                            tempGr.DrawImage(Sprites[15], score2coord);
                            tempGr.DrawImage(Sprites[14], score3coord);
                            break;

                        case 8:
                        case 9:
                            tempGr.DrawImage(Sprites[16], score1coord);
                            tempGr.DrawImage(Sprites[17], score2coord);
                            tempGr.DrawImage(Sprites[22], score3coord);
                            tempGr.DrawImage(Sprites[23], score4coord);
                            break;

                        case 10:
                        case 11:
                            tempGr.DrawImage(Sprites[18], score1coord);
                            tempGr.DrawImage(Sprites[19], score2coord);
                            tempGr.DrawImage(Sprites[22], score3coord);
                            tempGr.DrawImage(Sprites[23], score4coord);
                            break;

                        case 12:
                        case 13:
                        case 14:
                        case 15:
                        case 16:
                        case 17:
                        case 18:
                        case 19:
                        case 20:
                            tempGr.DrawImage(Sprites[20], score1coord);
                            tempGr.DrawImage(Sprites[21], score2coord);
                            tempGr.DrawImage(Sprites[22], score3coord);
                            tempGr.DrawImage(Sprites[23], score4coord);
                            break;
                        }
                    }
                    //Final drawing of everything. Перенесення намальованого на екран
                    gr.DrawImage(result, PointF.Empty);
                }
            }
        }