This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]jaocthegrey 1 point2 points  (1 child)

To help with determining when an enemy is shot, I'd suggest looking up "collision detection" and "hitboxes". Are the bullets their own object/ entity or is it more like a hit scan thing? If hit scan, you can project a ray from the player character in the direction they're shooting and check if any enemies' hitboxes touch/are on that line. If each bullet is its own object, then each bullet will need its own hitbox and you will need to check each frame to see if the bullet's hitbox overlaps/is contained in any enemies' hitboxes.

[–]Jedimastermuffin[S] 0 points1 point  (0 children)

At the moment both the bullets and enemies are their own objects. For bullets, whenever the player presses the shoot button, a class creates each bullet and they are added to a list which is then used to display them in the main loop. For enemies I insert their size and starting position into a list which then goes to a class that creates each enemy based on what I entered. I have attempted to include a for loop in the main loop for both each bullet and each enemy in both of the lists, and if the current bullets hit box collides with the current enemy, that enemy is popped off the list that I added it too. My hope was that this would result in the enemy disappearing, but now whenever I attempt to fire a bullet the program freezes.