Presentation is loading. Please wait.

Presentation is loading. Please wait.

GAM 200 Club. How to Game Engine GAM 200 Club Zachary Nawar.

Similar presentations

Presentation on theme: "GAM 200 Club. How to Game Engine GAM 200 Club Zachary Nawar."— Presentation transcript:

1 GAM 200 Club

2 How to Game Engine GAM 200 Club Zachary Nawar

3 DISCLAIMER There are many methods and ways of going about and creating a Game Engine, this is a very simple yet useful method for starting to build your engine

4 Step 1: Object Architecture Inheritance based VS Component based Very generic base object Each object inherits Tons of abstract objects Simple and easy UE3 is a great example One object class Components add logic Faster iteration More complicated to do



7 Step 2: Object Management Decide on what method to use for object management: > Single Game Space Each object exists in the same “space” or collection of objects > Multiple Game Spaces Multiple “spaces” which contain their own sets of objects

8 Now to build our Engine I build from small to large

9 When declaring and defining your functions imagine what you want the end user (Your team) to experience when they try to do things in your engine

10 Engine / Game Space / Game Object

11 Step 3: The (Base) Component Base Component has very basic stuff! Constructor / Destructor Initialize / Update / Remove functions ptr to the owning Space (optional) ptr to the owning Object TypeID (enum, int, const char*, you choose!) Keep it simple, clean, and virtual Real components inherit from this


13 Step 4: The Game Object What put inside? Constructor / Destructor Initialize / AddComponent / GetComponent / Update / Remove functions Array of Component pointers Global ID (?) More complicated things* Object Parenting info Archetype names


15 Step 5: The Game Space Think of it as an object manager Constructor / Destructor Update function Array of Objects pointers Other helper functions Cleanup, Clear, AddObject


17 Step 6: The Engine Core The core of your entire engine Home to your Init, AddSystem, Loop, Shutdown No need to implement these just yet Stores all of your Game Spaces Array of pre-allocated spaces? Array of pointers? Pointer to additional Systems Make a global pointer to your Core


19 We have now achieved our desired structure

20 Step 7: The “Object Factory” We need a way to make Objects! Our “Object Factory” does exactly this Could be a class full of static functions Just have the first parameter take a GameSpace* CreateObject() Allocates space for an object Adds object to game space Returns the new object

21 Step 7.1: Serialization The Factory is a great place to load objects Allocate object Load file File says what components to add to object File says what to set variables in components to Add object to game space Return the object (No need to really) Data driven! yay! CS225 should cover JSON serialization Also could be covered in future presentation

22 Making Objects in C++

23 Step 8: Engine Systems Currently all we have is an object engine We should add features to our engine! Graphics, Physics, Audio, GameLogic I call these “Systems” or “Modules” Expand and provide functionality to the engine Makes our Game Engine capable of running games

24 Step 8.1: Base Engine System This is the base/generic system Constructor / Destructor Init / Update / Shutdown functions Name (optional) Remember to keep it virtual Every system we add (Graphics, Physics…) inherits from this basic system


26 Step 8 Example Graphics System SetTransform(MATRIX33 m) // Sets matrix to use when drawing SetDrawMode(DMODE_ENUM dm) // Sets draw mode SetTexture(D3DTexture tex) // Sets the texture to draw DrawSprite() // Draws a sprite using transform, drawmode, texture StartFrame() // Starts a frame EndFrame() // Ends the current frame, swaps buffers Update() // Iterate through spaces/objects/components call Draw if we can?

27 Step 9: Back to the Engine Core Implement those engine functions! AddSystems Initialize Loop

28 Step 9.1: AddSystem void Core::AddSystem(ISystem* sys) Responsible for adding a system pointer into the Engine Core list of systems Push pointer into back of system pointer array/vector

29 Step 9.2: Init void Core::Init(void) Responsible for Initializing all engine systems Iterate through each System in array of Systems Call Init function

30 Step 9.3: Loop / MainLoop / Update void Core::Loop(void) Responsible for keeping the game running, the game loop ●While RUNNING ○ If Framerate controller says go ■ Iterate through systems in systems list ●Call Update function

31 Something that’s missing: GameLogic GameLogic can/should be a system too Iterates through all game spaces Update Game Space Iterate through all Objects Update Object Iterate through all Components Update Component This method is simple and works


33 Invoking our Engine 1.Create Engine Core 2.Create and add engine systems 3.Initialize Engine Core 4.Load a game level or something 5.Call Loop function 6.Call Shutdown function 7.Exit program

34 Things to work on next: Handle manager Messaging (Hooks, Events, ect.) Cache friendly memory management Archetypes Saving and Loading levels Introspection and Serialization Scripting languages

Download ppt "GAM 200 Club. How to Game Engine GAM 200 Club Zachary Nawar."

Similar presentations

Ads by Google