public override void Update() { //move player bullet if (picEntity.Top > 0) { picEntity.Top -= Velocity; } else { Destroy(); } //loop through each enemy to check if player bullet intersects with one of them foreach (Enemy Invader in List.Enemies) { if (Invader.picEntity.Visible && this.Bounds.IntersectsWith(Invader.Bounds)) { Destroy(); Invader.Destroy(); Sound.ChangeSound2URL("thunk.wav"); Sound.PlaySound2(); return; } } }
public void DestroyEverything() { //destroy all entities that may already exists due to past instances foreach (Bullet bull in List.Bullets) { bull.Destroy(); } List.Bullets.RemoveAll(p => true); foreach (InvaderBullet bull in List.InvaderBullets) { bull.Destroy(); } List.InvaderBullets.RemoveAll(p => true); foreach (Enemy Invader in List.Enemies) { Invader.Destroy(); } List.Enemies.RemoveAll(p => true); }
public override void Update() { //depending on which key is clicked, player will move in that direction //if player's movement exceeds form's dimensions, player would location would be set to specific locations if (L) { if (picEntity.Left < Velocity) { picEntity.Left = 0; } else { picEntity.Left -= Velocity; } } if (R) { if (picEntity.Left > 870 - Velocity) { picEntity.Left = 870; } else { picEntity.Left += Velocity; } } if (U) { if (picEntity.Top < 415 + Velocity) { picEntity.Top = 415; } else { picEntity.Top -= Velocity; } } if (D) { if (picEntity.Top > 570 - Velocity) { picEntity.Top = 570; } else { picEntity.Top += Velocity; } } //loop through each invader bullet to check if they intersect with player foreach (InvaderBullet bull in List.InvaderBullets) { if (bull.Bounds.IntersectsWith(this.Bounds)) { Destroy(); return; } } foreach (Enemy Invader in List.Enemies) { if (Invader.Bounds.IntersectsWith(this.Bounds)) { Destroy(); Invader.Destroy(); return; } } }