6 Replies - 10983 Views - Last Post: 23 June 2010 - 12:49 PM Rate Topic: -----

#1 v0rtex  Icon User is offline

  • Caffeine: db "Never Enough!"
  • member icon

Reputation: 223
  • View blog
  • Posts: 773
  • Joined: 02-June 10

2D SDL Game: Engine Structure

Posted 23 June 2010 - 06:28 AM

Hey all, after much learning, I am finally getting ready to attempt my own 2D engine in C++ using SDL as the sole graphics library. However I need some clarification in terms of setting up the structure of the "engine", I have heard that the best idea is to have headers dealing with the various sections such as graphics.h and then a main header such as engine.h that using multiple inheritance inherits all the public functions andvariables of the various other headers and using a function such as Engine::Start(), start the various functions from the various headers.

However I have also heard that it would be easier to perhaps just have a header such as Engine and then deal with the structure by having all the headers in one place thus avoiding multiple inheritance and most likely sticking to simple inheritance as I have heard multiple inheritance can get very frustrating.

My engine will be rather simple as it is my first attempt, if anyone can clarify the question abover OR
provide me with a 2D Engine Structure, I would be most appreciative, thanks a lot
v0rtex

Is This A Good Question/Topic? 0
  • +

Replies To: 2D SDL Game: Engine Structure

#2 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: 2D SDL Game: Engine Structure

Posted 23 June 2010 - 07:12 AM

Why not check out stayscrisp's SDL tutorials here? He has some good ideas on how to set up an SDL game state management, the 4th tutorial, that may help you. Just a suggestion.
Was This Post Helpful? 0
  • +
  • -

#3 v0rtex  Icon User is offline

  • Caffeine: db "Never Enough!"
  • member icon

Reputation: 223
  • View blog
  • Posts: 773
  • Joined: 02-June 10

Re: 2D SDL Game: Engine Structure

Posted 23 June 2010 - 07:23 AM

Thanks a lot, that does help, thanks to stayscrisp aswell for making those tutorials, I will definitely look at them but I understand how a game loop should work aswell as states etc but what is my concern is the design of the engine, how should I structure the 2D engine, my post above this one will hopefully make the question a little bit less vague!
Thanks.
Was This Post Helpful? 0
  • +
  • -

#4 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: 2D SDL Game: Engine Structure

Posted 23 June 2010 - 07:28 AM

I was talking about his ideas of state management, not really the game loop. You have a single base class that describes your game. Each state of your game is a derived class. You would have the graphics in a class of its own and call any drawing from the game state class. I believe it was the 4th one that he explained it best.
Was This Post Helpful? 0
  • +
  • -

#5 v0rtex  Icon User is offline

  • Caffeine: db "Never Enough!"
  • member icon

Reputation: 223
  • View blog
  • Posts: 773
  • Joined: 02-June 10

Re: 2D SDL Game: Engine Structure

Posted 23 June 2010 - 11:42 AM

Oh ok, thanks alot.
Was This Post Helpful? 0
  • +
  • -

#6 Fib  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 161
  • View blog
  • Posts: 554
  • Joined: 12-March 09

Re: 2D SDL Game: Engine Structure

Posted 23 June 2010 - 12:20 PM

I think this is more of what you are looking for.

http://gpwiki.org/in...Engine_Overview

It does include some OpenGL components in the graphics part, but I'm sure you will be able to modify it a bit to meet your goals.

I hope that helps!

This post has been edited by Fib: 23 June 2010 - 12:21 PM

Was This Post Helpful? 0
  • +
  • -

#7 v0rtex  Icon User is offline

  • Caffeine: db "Never Enough!"
  • member icon

Reputation: 223
  • View blog
  • Posts: 773
  • Joined: 02-June 10

Re: 2D SDL Game: Engine Structure

Posted 23 June 2010 - 12:49 PM

That is exactly what I am looking for! thanks, Sorry my question was very vague, I wanted the structure of an engine and you both aided me alot, I will try to make my questioning more to the point and precise, after all it will hopefully bring better results, that way. thanks alot.
~v0rtex

This post has been edited by v0rtex: 23 June 2010 - 12:55 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1