• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Finalspace

Text and ECS (Entity Component System) architecture questions

8 posts in this topic

Hi there,

 

i have successfully implemented signed distance fields font creation and rendering and now i am in the planing process for my HUD/UI rendering right now. Normally i would just add a renderHUD() method after all the other rendering stuff and call it and use orthographic projection. Thats how i have done it in the past, but now i have a Entity Component Based Game Engine and i want to do this the "Entity->Component" way if possible.

 

What i want to achieve is:

 

- Rendering a bit of text based on triggers (which are components as well) in the 3D scene (Created and destroyed on the fly)

- Rendering simple game Menu UI (Start, Load, Save, Options, Credits, etc.)

- Rendering HUD for the player/game and scene stats

- Rendering tons of debug informations - if required

 

Do you guys have some tips for a good component based solution?

 

Thanks in advance,

Finalspace

0

Share this post


Link to post
Share on other sites

I agree with AvengerDr. Think really hard if you want to shove the UI rendering block into an ECS shaped hole. The ECS concept relates well to game objects, and afaik, the HUD is not a game object. You might try hard to represent it as one, but it really would end up like trying to push a cube through a round hole. ECS is just another tool in your toolbox, so use it where appropriate.

 

Do things the easy way. Do things the way it makes sense.

1

Share this post


Link to post
Share on other sites

I agree that not everything must be done in a ECS-way, but i really like the way how clean it is with all the systems, entities and components.

You have the update systems (like input, behavior, camera, physics engine - in that order) first and then you have the draw systems and every system encapsulates the logic or drawing which are really clean in my opinion. Currently i havent found anything yet which does not fit in the ECS - but these will come definitly i think.

 

But i will give it more though, to get a simple but good solution - for now i need to fix the damn letter advancement -.-

0

Share this post


Link to post
Share on other sites


The downside is that you'll have to find someway to have different UI-components communicate with each other.

 

Components should already be able to communicate with other components.

 

I actually think the HUD can easily be made with ECS and even fit with your old way of doing things, you should already have an image component and image render component a UI is just behaviors with those so: a clickable component and system that sends a message to all components in the entity when  entered, exited, mouse up, mouse down then a uicomponent with it's system that ties together multiple components in the same group (Like radio buttons).

0

Share this post


Link to post
Share on other sites

I'm still teaching myself all this stuff, but can't you do it with 2 different drawing systems?

 

System 1 iterates through all entities and draws them if they have 3D components

System 2 iterates through all entities and draws them if they have HUD components

 

That essentially gives you your renderHUD() method.

 

So you wind up doing something like

 

Systems.input.update()

Systems.AI.update()

Systems.physics.update()

Systems.WorldPainter.draw()

Systems.HudPainter.draw()

0

Share this post


Link to post
Share on other sites

Components should already be able to communicate with other components.

 

I actually think the HUD can easily be made with ECS and even fit with your old way of doing things, you should already have an image component and image render component a UI is just behaviors with those so: a clickable component and system that sends a message to all components in the entity when  entered, exited, mouse up, mouse down then a uicomponent with it's system that ties together multiple components in the same group (Like radio buttons).

 

Yes sure, but it would be more time-consuming to have them behave the way you want compared to using an explicit approach. You can't throw a ButtonComponent, a PanelComponent and LabelComponents in an Entity and expect a DropDownBox to appear and work like it should unless you coordinate the logic between all of them. I believe that's easier to do if you have a DropDownBox object where you can do everything you need. After all none of the major UI frameworks use anything even remotely similar to an ECS.

 

In my approach, I only have a UIComponent for the whole HUD. So it gives me the flexibility to switch HUDs at runtime and that's enough I guess. Further, in my approach I am using Direct2D to render controls from scratch. So they aren't simple textures and thus require a different rendering method than if they were billboards.

Edited by AvengerDr
0

Share this post


Link to post
Share on other sites
For the HUD i think i will just create a HUD system and a HUD component which are rendered in orthographic mode and the component just have a list of labels/ui-elements without interaction for now.
For the ingame text stuff, i think a TextComponent and a text render system should work also.

Thanks guys for all the tips ;-)
0

Share this post


Link to post
Share on other sites


I actually think the HUD can easily be made with ECS and even fit with your old way of doing things ...

Not to be offending, but: This kind of thinking has led to the omni-potent scene graph, hasn't it? It is not principally wrong to think so, but only if side-effects and longtime effects are considered, and that is not so easy as the history shows us.

 

If one uses OOP as the programming paradigm, two principle ways are given: Inheritance and composition (or in practice a mix of those). ECS is in fact object composition made available to the designer. Because composition by itself is so low level, nearly all problems can be solved that way. However, does that mean that all problems are related to ECS?

 

ECS is a framework made to deal with game objects. At Gas Powered Games, which made the technique popular, the entities were called so, abbreviated as GOs. Text output of a debugger is hardly a game object. The graphics of a game menu belongs to the menu game state, which is in parallel with the gameplay state, of which the ECS is part of; so having the game menu inside the ECS is also strange. Judging the HUD itself is not as easy though, and having a dialog item floating above an avatar shifts things even more towards a game object understanding.

 

The argument that all those is text, and the wanted achievement of unified text rendering hence requires all examples to end in the ECS because some of them look like components, is the wrong way. Having the game loop being split into sub-systems is a solution independently of using ECS. The graphics sub-system is usually the very last one called in a game loop. Ideally it should not know what the ECS is, because the ECS is a tool to model the world, and graphics rendering just needs a snapshot (in time) slice (spatially) of the world to do its job (keyword: decoupling by queuing rendering jobs). Hence graphics rendering is not interested in which other sub-system(s) sent jobs, only that jobs are waiting to be processed.

 

What's with the other sub-systems? Input has an impact, for sure. Animation may be used. AI, collision detection, physics, ... usually not. But all these are part of the game loop and work onto ECS. So, when using an ICS ("interface component system" ;) ) it would be wise to clearly separate ECS and ICS, so that belonging sub-systems can be invoked for one set without being disturbed by the other set. For example, something like the Spaces approach may be used (see an introduction by Sean here).

 

Just my 2 Cents, of course.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0