• 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
Dominik2000

Input handling in ECS system

7 posts in this topic

I ask me the question how the input managment is best implemented in an ecs system. Especially how to stop the program, when ESC is pressed.

 

The architecture is like this:

A core game class, which initializes the renderer, different systems (placement system, physics system, ...) and the entity manager, which only stores many maps of components, with an entity id. All systems take their components from the system manager, so every system has access to all components it needs. The input low level class will be initialized by the input system. On the update cycle of the input system  if an ESC click occurs, the input system, sets the game isRunning property to false.

 

Or should I initialize the input low level also in the game class and then message direct from the low level input to the game class? I don't think so because I break the layers in this way.

 

Are there any advantages in the second method? Or is my first approach ok?

0

Share this post


Link to post
Share on other sites

And what is if I want to move the camera on the W key forward? The input manager holds a queue of key presses, the input system translates the key press to a move foreward message. Should I implement a MoveComponent, where I only store the MOVE_FORWARD message, and the placement system, moves the appropriate entity forward?

 

Or should this be a great queue in the game class? Don't think so, because the game class should have nothing to do with input handling or messaging. Maybe an own event messaging class?

0

Share this post


Link to post
Share on other sites

Your InputHandler works in the update method of the system in the handleInput phase. Do you get the translated commands from the InputHandler? Do you say the InputHandler, in which commands you system is interested in, at initializing?

0

Share this post


Link to post
Share on other sites

When you look at it, there are not many different kinds of abstract input. There is an action to be taken (a command), a transient binary state (on or off), or a value on a continuous axis. If you wish you could also express the binary state by using the extremes of an axis. You may have a look at the Unity 3D input system or the USB HID specification for such abstracted input. Any sub-system has a defined set of needs w.r.t. such input. E.g. your core game system has the need to shut down, obviously best presented by an action input. Sub-systems may derive their needs for input from components, like e.g. the controller for the player character.

 

So what I actually do (although it need not be done this way) is that sub-systems export instances of abstract input. Such instances provide a type as described above (e.g. action), a variable appropriate for the type, a display name if needed, and a flag that indicates whether the input is configurable. If so, then they are also binding points for input configurations. When a sub-system's needs can be described this way, then it just needs a standard InputHandler that translates from raw input to abstract input using said input configuration. If it needs more pre-processing, then it could install a derived InputHandler.

0

Share this post


Link to post
Share on other sites

Another option would be, your input system simply updates all the Input Components.  So, your player entity could have an input component, your camrea entity could have an input component, and you could have the main game/menu system have an input component.

 

The menu system would look for ESCAPE_KEY (probablymapped to Esc) in the Input Component, the Camera would look for CAMERA_MOVE_FORWARD_KEY (possibly mapped to 'w') from the Input Component, and the player would look for WEAPON_FIRE_KEY, PLAYER_MOVE_FORWARD_KEY, etc. from the input component.

0

Share this post


Link to post
Share on other sites

Good thought, but who stores in which key mappings the system is interested? The system or the component. The component would be perfect if it delivers only the keys in which the parent system is interested.

 

The system could search for every mapping every frame, if it exists, if yes -> do it if no -> do nothing. I don't like this...

0

Share this post


Link to post
Share on other sites

Good thought, but who stores in which key mappings the system is interested? The system or the component. The component would be perfect if it delivers only the keys in which the parent system is interested.

 

The system could search for every mapping every frame, if it exists, if yes -> do it if no -> do nothing. I don't like this...

Sure, part of the InputComponent could be a list of keys the specific entity is interested in, and, the InputSystem would only add keys the Input Components want to store.

 

So, the Camera Entity just wants CAMERA_MOVE_<direction>_KEY keys, and when it creates it's InputComponent, it gives it that list.

 

When the Input System runs, if a key mapped to CAMERA_MOVE_LEFT_KEY is pressed, then it is added to the Camera's InputComponent only.

 

The next time the Camera System runs, it see it's InputComponent has a key being pressed, and it uses it.

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