Elementos que vamos a necesitar;
Código del programa;
int Score=0;
pictureBox1.Visible=false;
private void
timer1_Tick(object sender, System.EventArgs e)
{
Random R=new Random();
int x=R.Next(0,this.Width);
int y=R.Next(0,this.Height-panel1.Height);
pictureBox1.Location=new Point(x,y);
}
private void
button1_Click(object sender, System.EventArgs e)
{
Score=0;
label1.Text="Score : "+Score.ToString();
pictureBox1.Visible=true;
timer2.Enabled=true;
timer1.Enabled=true;
}
private void
button2_Click(object sender, System.EventArgs e)
{
timer1.Enabled=false;
timer2.Enabled=false;
pictureBox1.Visible=false;
}
private void
pictureBox1_Click(object sender, System.EventArgs e)
{
Score=Score+10;
label1.Text="Score : "+Score.ToString();
}
private void
button3_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void
timer2_Tick(object sender, System.EventArgs e)
{
timer1.Enabled=false;
if(Score>50)
{
MessageBox.Show(Score.ToString(),"OK \n It is Good");
}
else
{
MessageBox.Show(Score.ToString(),"It is Very Bad");
}
MessageBox.Show(Score.ToString());
}
No hay comentarios.:
Publicar un comentario