• 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
Mia Blue

Mapping Multiplayer Controls for Play on a Single PC

6 posts in this topic

Hi, I'm currently programming player controls in a small RPG. Because the game also has a co-op mode, I want to make it so that both players can comfortably play on the same computer without getting in each other's way. My question is, how can I do this while ensuring that each configuration has the same advantages as the others? In other words, one mapping is not harder to use than another.

 

These are the default key configurations I came up with thus far:

 

AWDS   ARROW KEYS    NUMBERPAD               MOUSE

 

   w              /\                            8                    <point and click>
a    d       <       >                   4       6
   s               \/                            2     *(or 5)       *(hold the click to continue moving in that direction)

 

I am aware that many laptops lack a number pad and not everyone has access to a mouse.

 

How can I allow the player to also set his or her own key configuration if he or she is not comfortable with one of the default settings? Should I put it in the pause menu, where it can be changed during gameplay, or under "settings" in the main menu?

0

Share this post


Link to post
Share on other sites

Is controller support out of the question? Or are you looking specifically for keyboard only controls?

 

I would imagine if you support controllers, you would just plug another controller in and player 2 gets the same input as player 1 without having to share a keyboard.

 

 

For allowing players to specify their controls,  you would build a screen that lets each player map a physical key to a virtual button and do some sanity checking to ensure there aren't missing or duplicate mappings. The mapping could be as simple as an array that maps a physical key ID to a virtual key ID (you would have one mapping for each user or gamepad). When you process the physical inputs you would write to your input buffer, When you want to see if you want to perform a certain action mapped to  a virtual key, you would look at the physical key state mapped to the virtual input and act accordingly.

1

Share this post


Link to post
Share on other sites

How can I allow the player to also set his or her own key configuration if he or she is not comfortable with one of the default settings?

Not really any simple answer to this, most of this lands in the purview of an input system, usually you want to move from using raw keys to instead making "actions" or something, whatever you would probably label it as on the rebind menu, and have the game code translate a key press into that using a map or something.

For instance you could configure it so when the W key is pressed it translates that from a keypress into a "p1MoveUp" event, or something, you could use an enum or something for that if you want. Then just take it from there, either make an array of events and set their state or something if you want to use polling, or have an actual callback to tell the code player 1 is pressing the move up key.
 

Should I put it in the pause menu, where it can be changed during gameplay, or under "settings" in the main menu?

No brainer, they should be able to do both.

There's really not any design reason why it wouldn't be better that way. In fact most games should(and tend to fail at) give you the same options ingame to change as they do at the title screen. Edited by Satharis
1

Share this post


Link to post
Share on other sites

You should also be wary of hardware limitations. Some keyboards can't have more than 2-4 keys pressed with them registering as individual keypresses. This has to do with the interface type of the keyboard (PS/2 or USB), the type of keyboard (mechanical vs membrane) and the build process (how the internal hardware registeres key presses).

Look into ghosting and key rollover for more info.

 

What you plan here is having 2 players on one keyboard. If we assume the minimal number of simultaneous key presses required is 2 (diagonal movement), then you'll reach the maximum number of registered key presses really fast (for people who have (2|3|4)-KRO keyboards), with the result of only one player moving, or both players moving in only one direction (and not diagonal which they wanted). I suggest you provide alternative input devices for extra players on the same computer, otherwise your game might be unplayable for some people.

Edited by Strewya
1

Share this post


Link to post
Share on other sites

Is controller support out of the question? Or are you looking specifically for keyboard only controls?

 

I would imagine if you support controllers, you would just plug another controller in and player 2 gets the same input as player 1 without having to share a keyboard.

 

 

For allowing players to specify their controls,  you would build a screen that lets each player map a physical key to a virtual button and do some sanity checking to ensure there aren't missing or duplicate mappings. The mapping could be as simple as an array that maps a physical key ID to a virtual key ID (you would have one mapping for each user or gamepad). When you process the physical inputs you would write to your input buffer, When you want to see if you want to perform a certain action mapped to  a virtual key, you would look at the physical key state mapped to the virtual input and act accordingly.

 

Thank you very much! Your post is very helpful. I hadn't thought about using a controller (I suppose it's a USB connection?). That's a good idea though. For the time being, I can only develop using the keyboard and the mouse because I do not currently own a controller to test the controls with.

0

Share this post


Link to post
Share on other sites

 

How can I allow the player to also set his or her own key configuration if he or she is not comfortable with one of the default settings?

Not really any simple answer to this, most of this lands in the purview of an input system, usually you want to move from using raw keys to instead making "actions" or something, whatever you would probably label it as on the rebind menu, and have the game code translate a key press into that using a map or something.

For instance you could configure it so when the W key is pressed it translates that from a keypress into a "p1MoveUp" event, or something, you could use an enum or something for that if you want. Then just take it from there, either make an array of events and set their state or something if you want to use polling, or have an actual callback to tell the code player 1 is pressing the move up key.
 

 

 

I had been using the raw key input, but I understand now that enumerations would be a lot more useful and versatile in this case. Thank you.

0

Share this post


Link to post
Share on other sites

You should also be wary of hardware limitations. Some keyboards can't have more than 2-4 keys pressed with them registering as individual keypresses. This has to do with the interface type of the keyboard (PS/2 or USB), the type of keyboard (mechanical vs membrane) and the build process (how the internal hardware registeres key presses).

Look into ghosting and key rollover for more info.

 

What you plan here is having 2 players on one keyboard. If we assume the minimal number of simultaneous key presses required is 2 (diagonal movement), then you'll reach the maximum number of registered key presses really fast (for people who have (2|3|4)-KRO keyboards), with the result of only one player moving, or both players moving in only one direction (and not diagonal which they wanted). I suggest you provide alternative input devices for extra players on the same computer, otherwise your game might be unplayable for some people.

 

I wasn't aware of that limitation. Thanks for bringing it to my attention! The alternate input device I provided was the mouse, but I also noted that this could be a problem for laptop users who would normally use a touch pad rather than a USB mouse. Cardinal suggested that I consider game controller support, and I think that might just be the thing to alleviate that problem.

 

Perhaps I could include support for all three mediums--keyboard, mouse, and game controller--to make the game accessible to as many players as possible. I would have to buy a controller first, however, to develop such a thing. Thanks for the response!

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