Advertisement

Game Engine Classes

Started by April 25, 2002 03:11 PM
1 comment, last by Tszafran 22 years, 7 months ago
Hi, Im making a SDL game engine and so far have two classes, CGraphcis, and CInput. The problem is I want to have a public: data member in CInput to be accessible to CGraphics. My Engine class looks like this. class CEngine { public: CGraphics Graphics; CInput Input; }; PS. The reason I need to get that data member from CInput to CGraphics is becaue CGraphics has a member function called CGraphics::DebugInfo() which prints out the video driver, screen width, screen height, screen BPP, FPS, and mouse X and mouse Y (which is located in the Mouse structure in CInput).
MSN Messenger: Thomas_Szafran@hotmail.com
Have you heard of Singleton Classes? Using this idea you can have a class that holds a bunch of info you want to be used in multiple objects. There''s an article about it in Game Programming Gems.
It''s a pretty commonly used idea, so you can find out about implementations from tons of online sources.

Advertisement
Separating your components into Singletons may be the best way, and don't put them all in one class as members, because you're going to find many cases where your components will need to access each other.

Examples:

Click a button to kick a player from the session (Form calls Network)
When a player joins, pop up a messagebox (Network calls Form)
Click a button to minimize the app (Form calls Window)
When window restores, pop up a message (Window calls Form)

You get the idea.


[edited by - Waverider on April 25, 2002 4:56:03 PM]
It's not what you're taught, it's what you learn.

This topic is closed to new replies.

Advertisement