Twinklebear / LPCGame

Working on a C++ tile based 'engine' using SDL
MIT License
18 stars 1 forks source link

EntityManager vs. UIManager #10

Closed Twinklebear closed 11 years ago

Twinklebear commented 11 years ago

I think these classes should be merged into one, and then a function OnGUI should be implemented to draw things without any camera offsets to be called last in the draw order. So anything drawn in this function call will be drawn on top of everything and in window-space. This would in turn eliminate the need for a UIManager.

Twinklebear commented 11 years ago

Mouse interaction note: Because the UIManager doesn't apply a transform of the mouse into scene space it's what's used to determine clicks on Entities that are outside the scene. If the EntityManager and UIManager are to be rolled into one, the EntityManager will need to determine when is appropriate to apply the mouse transform.

Ie. if mouse clicked outside of scene space, don't apply any transforms. This will cause another issue though, if you click in the "scene physical area" ie. the top left corner of the window where the scene's untransformed physics are running you'll click a scene entity.

Instead I think the mouse coordinates should stay absolute and the collision boxes for in-scene Entities should be transformed to window-space when checking for clicks.

btstevens89 commented 11 years ago

What's the difference between an entity and a ui element?

Twinklebear commented 11 years ago

UI Elements are drawn without the camera offset, so this should be changed instead to be a flag that can be set to draw with/without the offset. Besides that, no difference, it's just a child of EntityManager that ignores the camera offsets. That's why I want to roll these two back together since it doesn't make sense for them to be separate things.

I'm a bit unsure as to why i decided to split them initially haha.

Twinklebear commented 11 years ago

I've removed the UIObjectManager, now entities are distinguished by the flag mUI, checked and set via IsUiElement() and IsUiElement(true). You can also enable/disable rendering of an entity with the mRender flag, via Render() and Render(true)

A note though, since for now some entities draw themselves via the script (should be changed) you must check if the camera will be null before drawing if you plan to test switching between ui element and not ui element (see player.lua)