using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Media; using System.Runtime.InteropServices; namespace Hra { public partial class Form1 : Form { int Pocet; SoundPlayer Player = new SoundPlayer(); Random Pozice = new Random(); int Cas_blecha; int Cas_bar; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { progressBar1.Visible = false; progressBar1.Value = 0; pictureBox1.Visible = true; pictureBox2.Visible = true; pictureBox3.Visible = true; pictureBox4.Visible = true; label_zacatek.Visible = true; timer1.Stop(); timer2.Stop(); timer3.Stop(); timer4.Stop(); Pocet = 4; } private void konecToolStripMenuItem_Click(object sender, EventArgs e) { this.Close(); } private void timer1_Tick(object sender, EventArgs e) { timer1.Interval = Cas_blecha; pictureBox1.Left = Pozice.Next(40, 600); pictureBox1.Top = Pozice.Next(60, 400); } private void timer2_Tick(object sender, EventArgs e) { timer2.Interval = Cas_blecha; pictureBox2.Left = Pozice.Next(100, 800); pictureBox2.Top = Pozice.Next(200, 500); } private void timer3_Tick(object sender, EventArgs e) { timer3.Interval = Cas_blecha; pictureBox3.Left = Pozice.Next(300, 1000); pictureBox3.Top = Pozice.Next(250, 550); } private void timer4_Tick(object sender, EventArgs e) { timer4.Interval = Cas_blecha; pictureBox4.Left = Pozice.Next(400, 900); pictureBox4.Top = Pozice.Next(150, 500); } private void začátečníkToolStripMenuItem_Click(object sender, EventArgs e) { label_zacatek.Visible = false; progressBar1.Visible = true; progressBar1.Value = 0; Cas_blecha = 700; Cas_bar = 300; Pocet = 4; pictureBox1.Visible = true; pictureBox2.Visible = true; pictureBox3.Visible = true; pictureBox4.Visible = true; timer1.Start(); timer2.Start(); timer3.Start(); timer4.Start(); timer_bar.Start(); } private void timer_bar_Tick(object sender, EventArgs e) { timer_bar.Interval = Cas_bar; progressBar1.Increment(1); if (progressBar1.Value == 100) { timer1.Stop(); timer2.Stop(); timer3.Stop(); timer4.Stop(); timer_bar.Stop(); pictureBox1.Visible = false; pictureBox2.Visible = false; pictureBox3.Visible = false; pictureBox4.Visible = false; MessageBox.Show("POZDĚ!", "Musíte víc trénovat!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); progressBar1.Value = 0; label_zacatek.Visible = true; this.pictureBox1.Location = new System.Drawing.Point(322, 215); pictureBox1.Visible = true; this.pictureBox2.Location = new System.Drawing.Point(450, 215); pictureBox2.Visible = true; this.pictureBox3.Location = new System.Drawing.Point(580, 215); pictureBox3.Visible = true; this.pictureBox4.Location = new System.Drawing.Point(700, 215); pictureBox4.Visible = true; } } private void expertToolStripMenuItem_Click(object sender, EventArgs e) { label_zacatek.Visible = false; progressBar1.Visible = true; progressBar1.Value = 0; Cas_blecha = 400; Cas_bar = 300; Pocet = 4; pictureBox1.Visible = true; pictureBox2.Visible = true; pictureBox3.Visible = true; pictureBox4.Visible = true; timer1.Start(); timer2.Start(); timer3.Start(); timer4.Start(); timer_bar.Start(); } private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { this.Player.SoundLocation = @"laser.wav"; this.Player.Play(); timer1.Stop(); pictureBox1.Visible = false; Pocet = Pocet - 1; if (Pocet == 0) { timer_bar.Stop(); progressBar1.Value = 0; progressBar1.Visible = false; MessageBox.Show("Výborně!", "Gratuluji!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); label_zacatek.Visible = true; this.pictureBox1.Location = new System.Drawing.Point(322, 215); pictureBox1.Visible = true; this.pictureBox2.Location = new System.Drawing.Point(450, 215); pictureBox2.Visible = true; this.pictureBox3.Location = new System.Drawing.Point(580, 215); pictureBox3.Visible = true; this.pictureBox4.Location = new System.Drawing.Point(700, 215); pictureBox4.Visible = true; } } private void pictureBox2_MouseDown(object sender, MouseEventArgs e) { this.Player.SoundLocation = @"laser.wav"; this.Player.Play(); timer2.Stop(); pictureBox2.Visible = false; Pocet = Pocet - 1; if (Pocet == 0) { timer_bar.Stop(); progressBar1.Value = 0; progressBar1.Visible = false; MessageBox.Show("Výborně!", "Gratuluji!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); label_zacatek.Visible = true; this.pictureBox1.Location = new System.Drawing.Point(322, 215); pictureBox1.Visible = true; this.pictureBox2.Location = new System.Drawing.Point(450, 215); pictureBox2.Visible = true; this.pictureBox3.Location = new System.Drawing.Point(580, 215); pictureBox3.Visible = true; this.pictureBox4.Location = new System.Drawing.Point(700, 215); pictureBox4.Visible = true; } } private void pictureBox3_MouseDown(object sender, MouseEventArgs e) { this.Player.SoundLocation = @"laser.wav"; this.Player.Play(); timer3.Stop(); pictureBox3.Visible = false; Pocet = Pocet - 1; if (Pocet == 0) { timer_bar.Stop(); progressBar1.Value = 0; progressBar1.Visible = false; MessageBox.Show("Výborně!", "Gratuluji!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); label_zacatek.Visible = true; this.pictureBox1.Location = new System.Drawing.Point(322, 215); pictureBox1.Visible = true; this.pictureBox2.Location = new System.Drawing.Point(450, 215); pictureBox2.Visible = true; this.pictureBox3.Location = new System.Drawing.Point(580, 215); pictureBox3.Visible = true; this.pictureBox4.Location = new System.Drawing.Point(700, 215); pictureBox4.Visible = true; } } private void pictureBox4_MouseDown(object sender, MouseEventArgs e) { this.Player.SoundLocation = @"laser.wav"; this.Player.Play(); timer4.Stop(); pictureBox4.Visible = false; Pocet = Pocet - 1; if (Pocet == 0) { timer_bar.Stop(); progressBar1.Value = 0; progressBar1.Visible = false; MessageBox.Show("Výborně!", "Gratuluji!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); label_zacatek.Visible = true; this.pictureBox1.Location = new System.Drawing.Point(322, 215); pictureBox1.Visible = true; this.pictureBox2.Location = new System.Drawing.Point(450, 215); pictureBox2.Visible = true; this.pictureBox3.Location = new System.Drawing.Point(580, 215); pictureBox3.Visible = true; this.pictureBox4.Location = new System.Drawing.Point(700, 215); pictureBox4.Visible = true; } } } }