Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove Enemy [Game Issue]
#1
When you hit an enemy, it removes from the screen, but if you shoot at the position it was, you will still get score. I need help removing it from the screen FOREVER.

Here is the code:
Code:
'TODO: Check for collisions with enemies here
If bullet.Bounds.IntersectsWith(Me.enemy.Bounds) Then
    bulletsToRemove.Add(bullet)
    Controls.Remove(enemy)
    Score += 5
End If
Also known as Rocketalypse.
System.out.println("I prefer Java.");
#2
Well, just like the player's bullets, for the enemy you need to setup an array and scroll through the array to check for collisions.

However, if you don't want to do that, and you have only one enemy, you can simply say..

Code:
'TODO: Check for collisions with enemies here
If bullet.Bounds.IntersectsWith(Me.enemy.Bounds) AndAlso Me.Controls.Contains(enemy) Then
    bulletsToRemove.Add(bullet)
    Controls.Remove(enemy)
    Score += 5
End If

So this makes it so before we check for collisions, we make sure that the enemy actually exists inside of the form.
My Blog | My Setup | My Videos | Have a wonderful day.
#3
Alright. There will be multiple enemies, but I am testing stuff with only one before I add more.

Thank you!
Also known as Rocketalypse.
System.out.println("I prefer Java.");
#4
No problem!
My Blog | My Setup | My Videos | Have a wonderful day.


Possibly Related Threads…
Thread Author Replies Views Last Post
  Full screen game overlay? Ecnarf 1 8,597 01-29-2013, 09:14 AM
Last Post: xolara
  Dual Menu Strip Issue Moldraxian 3 16,837 08-15-2012, 12:36 PM
Last Post: brandonio21
  MySQL Database Issue Moldraxian 7 29,044 08-13-2012, 08:58 PM
Last Post: brandonio21
  Module Issue Vinwarez 18 59,379 07-24-2012, 11:47 PM
Last Post: Vinwarez
  Launching Projectile [Game Issue] Vinwarez 11 33,468 07-13-2012, 03:29 PM
Last Post: brandonio21
  How to remove these errors? Vinwarez 6 21,665 03-12-2012, 10:01 PM
Last Post: Vinwarez

Forum Jump:


Users browsing this thread: 1 Guest(s)