Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Class design

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
NoMercy
Master Cheater
Reputation: 1

Joined: 09 Feb 2009
Posts: 289

PostPosted: Tue Jul 05, 2011 2:53 am    Post subject: Class design Reply with quote

Hello,

I'm trying to make a wrapper class for Direct2D, this is what I've now.

-DirectX classes

    InitDX
    BitMapDX
    TextDX


In the InitDX, I make the factory and the com etc, but the bitmap and text classes need the factory, so should I use class friendly ship or is it better to use a function to get the static pointer of a factory?

Further the BitMap class will load a bitmap and then you can draw it or not etc, but how if I would like to load 10 bitmaps, I've to make 10 variables of bitmaps, but next time it could be 26 bitmaps. An array would be nice. But I guess that's not possible for this?

I did not code anything yet, since this is just my design.

Thanks for reading.

NM
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Tue Jul 05, 2011 10:26 am    Post subject: Reply with quote

Your base factory could be a singleton (static pointer setup) as one method of setting up. Everyone has their own opinion about singletons, so its up to you to choose that method if you want it.

If you plan to allow other extensions to be able to render everything you will want to virtualize any major function and allow it to be overridden by a lower base. (DirectX, OpenGL, etc.)

As for the Bitmap question, just use a container of a type. If you're using a custom class like; CCustomBitmap, you could use any of the container types to hold an array of them ex.

std::list<CCustomBitmap> m_vBitmaps;
std::vector<CCustomBitmap> m_vBitmaps;

(or std::map, std::hash

There are a bunch of other containers, or you can code your own.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
NoMercy
Master Cheater
Reputation: 1

Joined: 09 Feb 2009
Posts: 289

PostPosted: Tue Jul 05, 2011 5:17 pm    Post subject: Reply with quote

Thanks that helped, I just made the pointer static and a GetPointer function. That works now.

So my next problem is that I made a CBackground class and for the background Im just drawing a bitmap as background. Then at top of that I draw the other pictures etc. But how if I would like a map to be chaning, for example in some games when you walk right the map changes to, it goes right. How do they do this?

Another thing, the D2 examples all uses .rc files, I would like to load from a directory is this possible?

Thanks.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Tue Jul 05, 2011 7:04 pm    Post subject: Reply with quote

You can load textures from resources or files. Look at:
D3DXCreateTexture
D3DXCreateTextureFromFile
D3DXCreateTextureFromFileEx
D3DXCreateTextureFromFileInMemory
D3DXCreateTextureFromFileInMemoryEx
D3DXCreateTextureFromResource
D3DXCreateTextureFromResourceEx

If you want to map to scroll you will have to code the texture to scroll with the movement of your focused object. (Whatever the camera is fixed to.) At the end of the textures you will need to begin drawing the next.

Some concepts:
http://www.gamedev.net/page/resources/_/reference/programming/isometric-and-tile-based-games/298/smooth-scrolling-a-tile-map-r743
http://msdn.microsoft.com/en-us/library/dd254919.aspx

You should be able to find other info on scrolling textures via Google if you need more.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
NoMercy
Master Cheater
Reputation: 1

Joined: 09 Feb 2009
Posts: 289

PostPosted: Thu Jul 07, 2011 3:38 am    Post subject: Reply with quote

Well, I'm creating further and further, but im not sure if my design is done well. Since I need lots of static pointers. Ill show the classes.

Quote:
CMain.Wndproc -> calls the CMessage(WM.PAINT and WM.CREATE).

CMessage.WmCreate->CBackground->SetBackGroundColor(white)
CMessage.WmCreate->CBackground->SetBackGroundBitMap("BitMapname")

CMessage.WmPaint -> CBackground->DrawBackGround


Now in CBackground I've got 2 static members, the color and one for the bitmap. I'm not sure but it seems there has to be a better way to do this.

Also if Ill code further all things will become static in other classes to, that's not my intention.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Jul 07, 2011 6:34 pm    Post subject: Reply with quote

Why are you using static pointers for color / bitmap?
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
NoMercy
Master Cheater
Reputation: 1

Joined: 09 Feb 2009
Posts: 289

PostPosted: Fri Jul 08, 2011 3:00 am    Post subject: Reply with quote

Because I use another instance of a class. I'm not sure if I can save that one somewhere or something.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites