Advertisement Jump to content
Sign in to follow this  

Several questions..

This topic is 3678 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

Right now all objects in my game are instances of an object class(An asteroids like game) however only one/a few of those objects should be able to recieve input, some of the mechanics differ too(missiles move constantly while ships have to recieve input..). How should I go/What would be the best method to isolate the objects that recieve input from those that don't? I am using c++ and well I have a class that has a 'map' used to store pointers to 'new' objects of a certain class. I want to have them all deleted/destroyed on that class' destructor but I am stuck, how do you go about deleting the pointers... What I mean is, should I just use 'map.clear()' or should I iterate through all stored objects and then how do I get the pointers 'out' of the iterator to delete them? Hope I am not too confusing..
	std::map<std::string, Sprite *>::iterator it = sprite_map.begin();
	for(; it!= sprite_map.end() ; it++)
//How do I 'delete it'?

Last question, I made a 15x15pixel sprite of a ship but when it gets displayed in-game it shows up all blurred(I had to scale it 3 times its size in case its relevant). [Edited by - Antonym on December 25, 2008 10:12:36 AM]

Share this post

Link to post
Share on other sites
WRT your first question, there's a few different ways. My own preference is to have the input system able to directly invoke events which in turn are directly hooked up to the controlable object(s) in question.

WRT your second question:

delete it->second;

Map iterators iterate over std::pair<const key,value>s -- in this case, std::pair< const std::string, Sprite* >. This means it->first refers to the key, and it->second refers to the value.

You do want to use a loop like you've posted to delete everything you've new-ed before .clear()ing the sprite_map.

WRT your third question:
Not nearly enough information. You haven't even told us if you're using, say, Direct3D, OpenGL, or something else to do your drawing. "had to scale it 3 times" could mean a few different things as well.


Share this post

Link to post
Share on other sites
Hmm could you elaborate on the first answer?

Heh sorry for the lack of info, I've fixed it already though, the scaling was the one responsible.(DirectX)

Thanks a lot.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!