Why a "Game" class?

Started by
11 comments, last by Icebone1000 10 years ago

Hello, I just looked in my engine, I forgot i have a DataLoader class now.

So i just do like this :

DataLoader load;

load.SetFolder( "foldername" );

load.Texture( true , "name" ); // true is for global or false = each level

The DataLoader remembers the name, so it wont load twice.

Now with this i only have one global , and that is DataLoader load;

I,m hoping to get voted up now for once!

@Ravyne : Saying that i am uneducated, but not giving a better solution ?

S T O P C R I M E !

Visual Pro 2005 C++ DX9 Cubase VST 3.70 Working on : LevelContainer class & LevelEditor

Advertisement

Now with this i only have one global , and that is DataLoader load;

I,m hoping to get voted up now for once!

You don't typically get voted up for making your own problems better. Or even voted down for making yourself problems.

You get voted down for encouraging others to adopt your mistakes.

It should come as no surprise then, that helping others to avoid the mistakes you've made or that you know are mistakes is the way to get voted up.

@Ravyne : Saying that i am uneducated, but not giving a better solution ?

Better solutions are well known. Abuse of global is the first thing covered in any software engineering course or book. Even most introductory programming classes or books will get around to mentioning in their first half.

But somehow you missed this information, and instead glibly recommended against best practices and then boasted how good you must be to not have experienced any of its known problems.

I'm probably coming of harshly, but I'm just being frank. Everyone is welcome here but don't expect to be awarded points for mere participation. When you offer up advice, that advice will be judged. So before you offer it, consider whether it is good advice and whether you are actually qualified to judge whether it us or not. If you want to share something that there's no consensus on, present it as opinion rather than fact. And if you want to share something that is contrary to best practices, qualify when the problems can be ignored.

For example, if you had said something like "In small, throw-away projects under a couple thousand lines long, I like to just use global when I'm coding from the hip." is an entirely different answer than "I think globals are great!" and it probably wouldn't have gotten any down-votes at all.

throw table_exception("(? ???)? ? ???");

In my engine the Game class holds the state machine, hig perf timer, and the fixed step loop, feeded by the timer down the state machine.

When doing a game, I create a GameName class, derived from both Game and Window (Window is a wrapper for win32 windows).

In that class I put the other engine main systems, like sprite renderer, sound, networking. And overwrite the wndprocedure function from the Window class, for handling resizing /input etc. ( I initialize the systems on WM_CRATE).

My message loop is handled manually, I dont know how to make it part of the engine. I place the Game::FixedStepLoop() myself on the main, and just need to load the first state to start the game. Till now all states I create grab a pointer to the GameName class on initialization, to access the main systems.

This topic is closed to new replies.

Advertisement