private void Form1_MouseMove(object sender, MouseEventArgs e) { Position.SetControlPosition(btnGlavni, e.Location.X, e.Location.Y); if (provjera) { this.Close(); player.Stop(); System.Media.SoundPlayer player2 = new System.Media.SoundPlayer(); player2.SoundLocation = "C:\\Users\\HOME\\Desktop\\New folder\\Amir\\Igrica\\Game\\Game\\Super Mario Bros - You're dead Sound effect.wav"; player2.Play(); Thread.Sleep(3000); EndGame(); DialogResult = DialogResult.OK; } }
private void MoveRandBtn() { while (true) { if (stop) { break; } Thread.Sleep(100); Action a = () => { if (i < this.Controls.Count) { if (this.Controls[i++] is Button) { if (i >= this.Controls.Count) { i = 0; } var btn = this.Controls[i] as Button; if (btn != null && btn.Name != btnGlavni.Name && btn.Name != btnEnd.Name) { Position.SetControlPosition(btn, btn.Location.X - btn.Size.Width, btn.Location.Y); if (btn.Location.X <= -btn.Location.X) { this.Controls.Remove(btn); } } } } }; if (provjera == true) { break; } BeginInvoke(a); } }
public void RandBtn() { while (true) { if (stop) { break; } Thread.Sleep(1000); Action a = () => { Button RandButt = new Button(); RandButton.SetRandButton(RandButt); Random random = new Random(); Position.SetControlPosition(RandButt, this.Size.Width - RandButt.Size.Width, random.Next(this.Size.Height - RandButt.Size.Height)); if (Level != ChangeLevel.Level) { ChangeLevel.NextLevel(RandButt); } this.Controls.Add(RandButt); bodovi += 3; bodoviZaIgru += 3; if (bodoviZaIgru > 33) { bodoviZaIgru = 0; } UcitajStatistiku(); if (bodovi % 33 == 0) { Level = ChangeLevel.NextLevel(btnGlavni, this); bodoviZaIgru = 0; pbBodovi.Value = 0; } }; if (provjera == true) { break; } BeginInvoke(a); } }