Sign in to follow this  

Base Image Class

This topic is 3487 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'm working on a game using SDL and was not quite sure how to implement a base image class. I want the image class to represent the graphics of my sprite class, but I'm unsure how I'd manage the different image types (or maybe just using PNG's will work?) and animated images within the image and sprite classes. Does anyone have some advice before I dive into it and implement this?

Share this post


Link to post
Share on other sites
Make the image class generic eg. it only holds the raw color data, width, height, etc. and then make different loaders for different file types. As for animations, they're a collection of images so shouldn't really be implemented within the image class.

Share this post


Link to post
Share on other sites
I'm not sure I understand how you intend to use this class. What does this class represent and what classes do you want to derive from it?

If this class represents an image that can be drawn, then it should only contain drawing functionality and not worry about image formats. In this case I think there is also no point in having derived classes (what will they be used for?).

If this class will be used to load images (maybe you wanted each derived class to load a specific format), then I wouldn't bother. SDL_mixer (EDIT: Sorry, meant to say SDL_image, thanks JParishy for the correction.) can load various image formats so that is already taken care of for you.

As for animation, I would create a separate class. It will store the frames of animation and the animation state such as the current frame, the time elapsed since the last frame, etc.

[Edited by - Gage64 on May 29, 2008 2:09:48 AM]

Share this post


Link to post
Share on other sites

This topic is 3487 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this