public Form1() { InitializeComponent(); BallDoc = new BallDoc(); this.DoubleBuffered = true; timer1.Start(); }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { timer1.Stop(); if (MessageBox.Show("Are you sure you want to start a new game?", "Start a new game", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { BallDoc = new BallDoc(); Filename = string.Empty; Invalidate(true); } timer1.Start(); }
private void Form1_MouseClick(object sender, MouseEventArgs e) { var ball = new Ball(e.Location); if (ball.Center.X > _left + ball.Radius && ball.Center.X < (_left + _width) - ball.Radius && ball.Center.Y > _top + ball.Radius && ball.Center.Y < (_top + _height) - ball.Radius) { BallDoc.AddBall(ball); Invalidate(true); } }
private void Form1_Paint(object sender, PaintEventArgs e) { e.Graphics.Clear(Color.White); BallDoc.DrawBalls(e.Graphics, new Font("Times New Roman", 20)); var pen = new Pen(Color.Black, 3); e.Graphics.DrawRectangle(pen, _left, _top, _width, _height); pen.Dispose(); if (Filename != string.Empty) { this.Text = $"Monster Ball | {Filename.Substring(Filename.LastIndexOf(@"\") + 1)}"; } else { this.Text = "Monster Ball"; } }
private void timer1_Tick(object sender, EventArgs e) { BallDoc.MoveBalls(_left, _top, _width, _height); BallDoc.CanSwallow(); Invalidate(true); }