• 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.
  • entries
    33
  • comments
    37
  • views
    38379

[Engine] Handling Input

Sign in to follow this  
Followers 0
superman3275

556 views

Handling Input. For many it seems simple, and it relatively seems to be. However finding a good way to structure you're input management can be hard. Mainly because for a lot of libraries input is either handled by the Window or an Event object. When it's handled by the window, it's hard to figure out where to place your resources (Should the Input object have a pointer to the window, or should it have the window so my Draw class can have a pointer to it?). Here's some small things I recently found out when writing my own input manager.

1) Single Responsibility Is Important
I've already talked about the Single Responsibility principle, however I feel, especially in this case, that I should emphasize it. It may be tempting to have your input manager also draw everything to the screen (I mean, it already has the Window and Event, right?!?!). However, as we've already seen, that can have adverse affects. You want to make it so that everything is completely isolated to it's own object. It'd be misleading also. Imagine having your Input object also draw everything. That's confusing, isn't it! It get's even more important when you're making a tile based game, like I am, because there are more complex algorithms and functions that I use to figure out what I need to draw and how I need to draw it.

2) Being Specific Isn't Bad
In my Input class, I have a function that can get key presses by taking in the type of key press (As an sf::Key::Type) as a parameter. Then it's simply seeing if that sf::Key::Type is equal to the current key being pressed. Now, arguably, I could use this for many cases by just programming them in whatever is using Input. But that makes for a bad interface and badly written code that no one can read. So instead, I have a plethora of functions that compliment that one. The same goes for getting mouse input. I made many functions for different cases I knew I'd need instead of going through having one complicated and hard to read function. This is important because it makes your code easily readable. Imagine your game getting huge. If you get fellow programmers to help you, having that one hard to understand function that's trying to "catch-all" will make it nearly impossible for them to understand what's going on without looking through an insane amount of code.

Overall, your Input class should handle input, and only input, and should have a large amount of options for you to check different kinds of input.

If you enjoyed this blog post, please comment down below about what you'd do different and share your tips.

0
Sign in to follow this  
Followers 0


0 Comments


There are no comments to display.

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