This is an old revision of the document!
“Update and Render functions? Where we're going we don't need hardcoded Update and Render functions”
First of all, a disclaimer: You don't really *HAVE* to use the Proton Entity System to use the framework. If you already have a system you like, or are porting existing code, you can safely ignore most of this section.
I've made a lot of engines and a lot of game frameworks and for some reason I'm constantly trying new methods, mostly because it keeps things fun and interesting.
Here are some past methods I've tried when creating games:
Using all of these, this is how it went:
(Ladies, look at your game programming development cycle)
(Now look at mine)
What if we could trade some initial complexity in the beginning for a more sane experience over all?
Aka, “my interpretation of how Unity internals sort of work after I used it for a few hours”.
If you take a look at Entity.h you'll see some functions but nothing about thinking/updating or drawing. So what can an entity do?
Well, not much, alone. It's fairly lightweight at about 200 bytes.
Instantiate an entity
Ok, time to just cannon-ball into the pool and show you what this stuff can do. The important thing to realize is we're just using entities and components to do everything.
If you say a weird function, like, BobEntity(), realize that it's just a helper function from EntityUtils.cpp and is components to manipulate things to make any entity “bob”. These helpers are not that complicated and just save on repetitive code, so dig in and look at them.
My philosophy is if it's a simple one line of code to add a fade, zoom, or bob to a visual, you are that much more likely to do it.
If you'd like to work along with me, open the RTSimpleApp project now!
//Open App.cpp. Find MainMenuCreate(pGUIEnt) in App::Update(), comment it out and add two lines so you have this: //MainMenuCreate(pGUIEnt); AddFocusIfNeeded(pGUIEnt); //so it will render, update, and draw. Really it just adds a few components. Entity *pEnt = CreateOverlayEntity(pGUIEnt, "logo", "interface/proton.rttex", 0,0);
Instead of the menu as before, you should see the proton logo rendered. (I've set my screen output to iPhone size in main.cpp btw)
Well, we see the logo there. If you looked inside of CreateOverlayEntity, you'd see it creates an Entity, and adds a RenderOverlay component to it and sets some properties. (All of which are storied in either entity's VariantDB (like pos2d, color, scale2d, etc) or the components VariantDB if it is specific to the component. (properties like fileName, and framex, framey)
Add a few lines of code: