private void Salir_Click(object sender, EventArgs e) { timer1.Enabled = false; timer2.Enabled = false; Salir salir = new Salir(); this.Hide(); salir.Show(); }
private void timer1_Tick_1(object sender, EventArgs e) { label1.Text = "Puntaje: " + puntaje.ToString();; switch (direccion) { #region MoverPacman case Direccion.arriba: pictureBox1.Image = Image.FromFile("pacman-up.png"); if (pictureBox1.Location.Y > pictureBox1.Height - 15) { pictureBox1.Location = new Point(pictureBox1.Location.X, pictureBox1.Location.Y - 2); } else { direccion = Direccion.quieto; pictureBox1.Location = new Point(pictureBox1.Location.X, 25); } break; case Direccion.abajo: pictureBox1.Image = Image.FromFile("pacman-down.png"); if (pictureBox1.Location.Y < this.Height - 3 * 43) { pictureBox1.Location = new Point(pictureBox1.Location.X, pictureBox1.Location.Y + 2); } else { direccion = Direccion.quieto; pictureBox1.Location = new Point(pictureBox1.Location.X, 360 - 43); } break; case Direccion.derecha: pictureBox1.Image = Image.FromFile("pacman-right.png"); if (pictureBox1.Location.X < this.Width - 55) { pictureBox1.Location = new Point(pictureBox1.Location.X + 2, pictureBox1.Location.Y); } else { direccion = Direccion.quieto; pictureBox1.Location = new Point(this.Width - 55, pictureBox1.Location.Y); } break; case Direccion.izquierda: pictureBox1.Image = Image.FromFile("pacman-left.png"); if (pictureBox1.Location.X > pictureBox1.Width - 43) { pictureBox1.Location = new Point(pictureBox1.Location.X - 2, pictureBox1.Location.Y); } else { direccion = Direccion.quieto; pictureBox1.Location = new Point(0, pictureBox1.Location.Y); } break; case Direccion.quieto: break; default: break; #endregion } if (Math.Abs(guinda.Location.X - pictureBox1.Location.X) < 20 && Math.Abs(guinda.Location.Y - pictureBox1.Location.Y) < 20) { if (guinda.Enabled) { guinda.Hide(); guinda.Enabled = false; puntaje += 10; } } if (Math.Abs(uva.Location.X - pictureBox1.Location.X) < 20 && Math.Abs(uva.Location.Y - pictureBox1.Location.Y) < 20) { if (uva.Enabled) { uva.Hide(); uva.Enabled = false; puntaje += 15; } } if (Math.Abs(rojo.Location.X - pictureBox1.Location.X) < 20 && Math.Abs(rojo.Location.Y - pictureBox1.Location.Y) < 20) { Salir salir = new Salir(); this.Hide(); salir.Show(); } if (Math.Abs(rosado.Location.X - pictureBox1.Location.X) < 20 && Math.Abs(rosado.Location.Y - pictureBox1.Location.Y) < 20) { Salir salir = new Salir(); this.Hide(); salir.Show(); } }