protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { x = goku.Location.X; y = goku.Location.Y; if (keyData == Keys.Up && play == true) { for (int o = 0; o < 45; o++) { Thread.Sleep(10); y = y - 5; goku.Location = new Point(x, y); } for (int o = 0; o < 45; o++) { Thread.Sleep(10); y = y + 5; goku.Location = new Point(x, y); } } if (keyData == Keys.Right && play == true) { if (x + 25 > 0 && x + 25 < 526) { x = x + 25; } } if (keyData == Keys.Left && play == true) { if (x - 25 > 0 && x - 25 < 526) { x = x - 25; } } if (keyData == Keys.Down && play == true) { interseccioBolas(); } if (keyData == Keys.Space && play == true) { } if (keyData == Keys.Escape) { timer1.Stop(); FinalPunctuation FP = new FinalPunctuation(NameGamer, punctuation, false); FP.Show(); this.Close(); } goku.Location = new Point(x, y); return true; }
public void interseccioBolas() { for (int p = 0; p < bolas.Count; p++) { bola b = (bola)bolas[p]; if (goku.Bounds.IntersectsWith(b.Bounds)) { punctuation = punctuation + b.Puntuacio; Controls.Remove(b); bolas.Remove(b); bolasCount--; } if (bolasCount == 0) { timer1.Stop(); FinalPunctuation FP = new FinalPunctuation(NameGamer, punctuation, true); FP.Show(); this.Close(); } } }
public void timer_Cronometre() { seconds--; cronometre.Text = "Time left: " + seconds + " seconds"; if (seconds == 0) { timer1.Stop(); FinalPunctuation FP = new FinalPunctuation(NameGamer, punctuation, false); FP.Show(); this.Close(); } }