Jump to content

  • Log In with Google      Sign In   
  • Create Account


Is my Game Engine right?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 BlueSin   Members   -  Reputation: 142

Like
0Likes
Like

Posted 22 April 2013 - 02:34 PM

So I know there are alot of game engines out there, but still for educational purposes I want to try my hand at making my own.  Truth be told, I have been remaking virtual the same one for quite some time now and they work fabulously but I always quit out of fear that I am maybe doing something wrong.  I don't want to build my game on corrupted framework, but I want to actually move forward in creating a game!  So if you could please just read this over, and I know it is somewhat lengthy, but your patience and input is appreciated.

 
For my engine, what is the difference between a State and a Screen?  A State tells us where we are in the game. (i.e.- main menu, credits, etc.) Only one state can be active at a time.  A State can contain one or more active screens.  (i.e.- background screen, foreground screen, etc.) Each screen is made up of Components.  A Component is anything interacting with it's parent screen or being drawn to the screen. (i.e.- player, enemies, fps count, etc.)
 
Static GameEngine Class
Static StateManager Class
Static ScreenManager Class
 
Abstract State Class
Abstract Screen Class
Abstract Component Class
 
Game Class calls GameEngine.Update().  GameEngine.Update() calls StateManager.Update().  StateManager.Update() calls CurrentState.Update().  CurrentState.Update() calls ScreenManager.Update().  ScreenManager.Update() calls Screen.Update() on all active screens.  Screen.Update() calls Component.Update() on all components in it's component list.
 
Game Class calls GameEngine.Draw().  GameEngine.Draw() calls StateManager.Draw().  StateManager.Draw() calls CurrentState.Draw().  CurrentState.Draw() calls ScreenManager.Draw().  ScreenManager.Draw() calls Screen.Draw() on all active screens.  Screen.Draw() calls Component.Draw() on all components in it's component list.
 
My fear is that there are unnecessary steps in there, but at the same time isn't the object of the OOM to define objects?  Each of these classes plays a unique role within the structure, and are organized in an obvious hierarchy.  Once the GameEngine has been initialized and loaded, other than to call Update & Draw, the GameClass has no other interaction with the game other than to exit.  It is very streamlined, and the process can quite literally play itself.
 
From here, Screens can make requests to their parent State for a state change.  The state then requests an active state change from the state manager.  The state manager will call for an unload down the hiearchy, then change the active state and call a Load() down the hierarchy.  Then the Update/Draw cycles continue.
 
Components can remove themselves from a screen's component list by calling their parent screen's RemoveComponent() method.
 
StateManager keeps a list of all the states passed to it during game initialization.  Likewise, the screen manager keeps a copy of the list of screens for the active state, so that the active state doesn't manage them, the ScreenManager does.


Sponsor:

#2 Andy474   Members   -  Reputation: 659

Like
0Likes
Like

Posted 23 April 2013 - 01:55 AM

So I know there are alot of game engines out there, but still for educational purposes I want to try my hand at making my own.  Truth be told, I have been remaking virtual the same one for quite some time now and they work fabulously but I always quit out of fear that I am maybe doing something wrong.  I don't want to build my game on corrupted framework, but I want to actually move forward in creating a game!  So if you could please just read this over, and I know it is somewhat lengthy, but your patience and input is appreciated.

 

Your engine doesn't have to be AAA Standard, or finished for you to write a game. I am doing something similar, i have written an engine to handle game screens and states, but it wont stop me making a game, the engine is constantly changing. I am writing new things and thinking "Wait, why did i write this like this?" or "How on earth does this actually work" and going back, redesigning it on top of the game i am currently building.

 

There is no "Proper" way of building an "engine" because most of the time, it has to suit your needs, which change depending on the game your writing.

 

By Reading through the calls above, we cannot say "yep that's right" or "No, your doing it all wrong". If it works for you, it works for you.

 

Personally, i wouldnt have a CurrentState i Have a ScreenManager which handles the states, which is defined as an Enum. The Engine doesn't know what states your game needs, other than "Splash Screens" / "Menus / Game" So, leave gamestate up to whoever writes the game to decide. so your screenmanager only needs (in my eyes) to Screen.Update() or Screen.Draw()



#3 Prateek Malhotra   Crossbones+   -  Reputation: 209

Like
0Likes
Like

Posted 24 April 2013 - 08:46 AM

I can understand how you feel about the basic framework of the engine being 'perfect'. A couple of years before today, if you would have asked me, I would say the same thing. Basically you have to think of a perfect engine as a goal, and to achieve it you have to make mistakes with your engine and build it again and again. I am too in the process of making an engine.

 

From what you typed, I can tell you have a good idea of what you want to do. If the engine is functional enough to make a game on it, then just do it and keep updating and optimising the engine as time goes; as Andy474 said it doesn't have to be AAA standard or completely finished.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS