Jump to content
  • Advertisement
Sign in to follow this  
_MM_UnL1573d

keeping track of enemies

This topic is 4859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am planning on making a side scrolling platform game, yes, in the essence of Mario. How would I go about keeping track of the enemies if they are off screen, or if they die...I know that I could use a class to keep track of whether the enemy is alive or dead, but how would I tell if the enemy is on-screen or off-screen? thanks :-)

Share this post


Link to post
Share on other sites
Advertisement
Iwould just have it store their location. If theyt are off the left side, they are negative. If they are off the right, then they are just numbers bigger than the screen size. Definately seems the easiest way. Depending on the game, you could have it is they are more than a certain amount off, they are destroyed... This occured in the old mario games.

Share this post


Link to post
Share on other sites
Yeah just store the position of each enemy and basically do a bounding box test to see if its inside window coordinates. It's not very hard at all.

Share this post


Link to post
Share on other sites
You would store the position of the player (which might or might not be centered on the screen) and the positions of the enemies as well.

If you keep track of the position by the left of the screen, then you just check if the enemy is less than that position. If he is then it is off the screen to the left. If the enemy is greater than the left plus the width of the screen, then he is off the side at the right. That would be the bounding box for the left and right (if you need up and down, then you can probably figure that out as well).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!