Example #1
0
        public void Move(int speed, int width, int height, bool left, bool right, Shelf shelf)
        {
            if (x + 10 >= shelf.x && x <= (shelf.x + shelf.width - 10) && (shelf.y - (y + 25)) <= 5 && (shelf.y - (y + 25)) >= -5)
            {
                y -= 3;
            }
            else if (y + 25 + speed <= height)
            {
                y += speed;
            }
            if (y + 25 != height)
            {
                if (left == true && x - 15 > 0 && !leftShelf(shelf))
                {

                    for (int i = 0; i < 11; i += 1)
                        x -= 1;

                }
                if (right == true && x + 15 + 25 < width && !rightShelf(shelf))
                {
                    for (int i = 0; i < 11; i += 1)
                        x += 1;
                }

            }
        }
Example #2
0
 public bool naPolica(Shelf shelf)
 {
     if (x >= shelf.x && x <= (shelf.x + shelf.width) && (shelf.y - (y + 25)) <= 4 && (shelf.y - (y + 25)) >= -4)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Example #3
0
 public bool leftShelf(Shelf shelf)
 {
     if (x > shelf.x + shelf.width-2 && x<shelf.x+shelf.width+8  && y + 26 > shelf.y && y < shelf.y + 15)
         return true;
     return false;
 }
Example #4
0
 public bool rightShelf(Shelf shelf)
 {
     if (x + 25 < shelf.x+2 && x + 25 > shelf.x - 8 && y + 26 > shelf.y && y < shelf.y + 15)
     {
         return true;
     }
     return false;
 }
Example #5
0
 public bool poklopuvanje(Shelf shelf)
 {
     if (x > shelf.x && x + 25 < shelf.x + shelf.width && y > shelf.y && y + 25 < shelf.y + 25)
         return true;
     return false;
 }
Example #6
0
        public void runGame()
        {
            pause = false;
            exitGameBtn = true;
            playersScore = new List<Player>();
            timer1.Start();
            mainSound.PlayLooping();
            right = false;
            left = false;
            this.DoubleBuffered = true;
            panel1.DoubleBuffered = true;
            doubleBuffer = new Bitmap(width, heigh);
            graphics = this.CreateGraphics();
            shelfList = new List<Shelf>();
            ball = new Ball(width / 2 - 13, width - 25);
            shelf = new Shelf(0, heigh - 25, 230);
            shelfList.Add(shelf);
            shelf = new Shelf(270, heigh - 25, width - 270);
            shelfList.Add(shelf);

            shelf = new Shelf(0, heigh - 80, 100);
            shelfList.Add(shelf);
            shelf = new Shelf(140, heigh - 80, width - 140);
            shelfList.Add(shelf);

            shelf = new Shelf(0, heigh - 135, 160);
            shelfList.Add(shelf);
            shelf = new Shelf(200, heigh - 135, width - 200);
            shelfList.Add(shelf);

            shelf = new Shelf(0, heigh - 190, 120);
            shelfList.Add(shelf);
            shelf = new Shelf(160, heigh - 190, width - 160);
            shelfList.Add(shelf);

            shelf = new Shelf(0, heigh - 245, 220);
            shelfList.Add(shelf);
            shelf = new Shelf(260, heigh - 245, width - 260);
            shelfList.Add(shelf);

            shelf = new Shelf(0, heigh - 300, 160);
            shelfList.Add(shelf);
            shelf = new Shelf(200, heigh - 300, width - 200);
            shelfList.Add(shelf);

            shelf = new Shelf(0, heigh - 355, 200);
            shelfList.Add(shelf);
            shelf = new Shelf(240, heigh - 355, width - 240);
            shelfList.Add(shelf);

            shelf = new Shelf(0, heigh - 410, 80);
            shelfList.Add(shelf);
            shelf = new Shelf(120, heigh - 410, width - 120);
            shelfList.Add(shelf);

            shelf = new Shelf(0, heigh - 465, 80);
            shelfList.Add(shelf);
            shelf = new Shelf(120, heigh - 465, width - 120);
            shelfList.Add(shelf);
        }