Programming 2D Games

The official forum for "Programming 2D Games" the book by: Charles Kelly

It is currently Fri Feb 28, 2020 9:24 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Texture Manager
PostPosted: Tue Aug 05, 2014 6:23 pm 
Offline

Joined: Sat Oct 12, 2013 4:48 pm
Posts: 44
Hi,
In later projects, you have changed you texture manager so would you explain in more details the new code, what exactly is happening in that class and what difference is it to the old version??

Is it really necessary to have a texture manager or could we not just include that within the Image class?

Why is the sprite structure and drawing functions defined in the Graphics class and not in the Image class??

Kind regards

JC MAZZA


Top
 Profile  
Reply with quote  
 Post subject: Re: Texture Manager
PostPosted: Tue Aug 05, 2014 10:56 pm 
Offline
Site Admin
User avatar

Joined: Sat Jan 28, 2012 4:36 pm
Posts: 554
guizmo01 wrote:
In later projects, you have changed you texture manager so would you explain in more details the new code, what exactly is happening in that class and what difference is it to the old version?
The newer Texture Manager class supports the ability to load multiple textures files. The comments for the initialize function explain how it works.
Code:
    // Initialize the textureManager
    // Pre: *g points to Graphics object
    //      file is name of texture file to load.
    //      If file extension is .txt it is assumed to
    //      contain a list of texture file names, one name
    //      per row.
    // Post: The texture file(s) are loaded
    virtual bool initialize(Graphics *g, std::string file);
The Tile Collision demo from chapter 10 uses this feature. Here is part of that code:
Code:
    // tile textures
    if (!tileTextures.initialize(graphics,TILES))
        throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing tile textures"));
Code:
const char TILES[] = "pictures\\tiles.txt";     // game tiles


guizmo01 wrote:
Is it really necessary to have a texture manager or could we not just include that within the Image class?
It is not necessary to use a Texture Manager class if you implement the same functionality somewhere else in code. I like to use single purpose classes whenever possible.

guizmo01 wrote:
Why is the sprite structure and drawing functions defined in the Graphics class and not in the Image class?
I tried to put all of the DirectX specific code in just a few classes. That will make it easier to update the engine to use newer versions of DirectX or OpenGL.

_________________
Professor Kelly


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group