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 9,808 01-29-2013, 09:14 AM
Last Post: xolara
  Dual Menu Strip Issue Moldraxian 3 19,374 08-15-2012, 12:36 PM
Last Post: brandonio21
  MySQL Database Issue Moldraxian 7 32,930 08-13-2012, 08:58 PM
Last Post: brandonio21
  Module Issue Vinwarez 18 68,704 07-24-2012, 11:47 PM
Last Post: Vinwarez
  Launching Projectile [Game Issue] Vinwarez 11 39,991 07-13-2012, 03:29 PM
Last Post: brandonio21
  How to remove these errors? Vinwarez 6 25,180 03-12-2012, 10:01 PM
Last Post: Vinwarez

Forum Jump:


Users browsing this thread: 1 Guest(s)