public void addBall(Ball ball) { balls.Add(ball); }
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); }
public void newGame() { exitGameBtn = true; timeStart = 3; timer1.Start(); lblTimeStart.Visible = true; lblgameStartin.Visible = true; Score = 0; upWalls = new List<Wall>(); downWalls = new List<Wall>(); playersScore = new List<Player>(); ball = new Ball(250, 200); wall = new Wall(600, 0, 200); upWalls.Add(wall); wall = new Wall(600, 325, this.Height - 65 - 200); downWalls.Add(wall); wall = new Wall(750, 0, 100); upWalls.Add(wall); wall = new Wall(750, 225, this.Height - 65 - 100); downWalls.Add(wall); wall = new Wall(900, 0, 220); upWalls.Add(wall); wall = new Wall(900, 345, this.Height - 65 - 220); downWalls.Add(wall); wall = new Wall(1050, 0, 80); upWalls.Add(wall); wall = new Wall(1050, 205, this.Height - 65 - 80); downWalls.Add(wall); }
private void timer1_Tick(object sender, EventArgs e) { if (ballCollection.LostBalls < 5) { if (ballCollection.Score % 15 == 0 && ballCollection.Score > 0 && prvPat) { speed++; prvPat = false; if(newBallInterval>=35) newBallInterval-=5; } newBall++; if (newBall >= newBallInterval) { newBall = 0; ball = new Ball(random.Next(10, this.Width - 55), -25); ballCollection.addBall(ball); } ballCollection.moveBalls(this.Height,speed); basket.Move(x); prvPat=ballCollection.ScoreUp(basket); lblScore.Text = ballCollection.Score.ToString(); lblLostBalls.Text = ballCollection.LostBalls.ToString(); } else { GameOver(); } Invalidate(); }