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

PROBLEM - Block breaker with air hockey PLAYED with 2 HUMAN PLAYERS

4 posts in this topic

Hi Guys,
I just want to ask if can I check for "KEY"(keyboard) that is HOLD/PRESSED for a long time, because I am to create a clone of breakout with air hockey for 2 different human players.
Here's the list of my concern:

1. Do I need other/ 3rd party library for KEY HOLDS?

2. Is multi-threading needed? I don't know anything about this multi-threading stuff and
I don't think about using one(I'm just a NEWBIE).

3. One more thing, what if the two players pressed their respective key at the same time,
how can I program to avoid error or worse one player's key is prioritized first before
the the key of the other.
example:
Player 1 = W for UP & S for DOWN
Player 2 = O for UP & L for DOWN
(example: W & L is pressed at the same time)
Great thanks for help.
PS: I use GLUT for the visuals of the game.
0

Share this post


Link to post
Share on other sites
You do need a library to get this kind of access to the keyboard. Each OS most likely provides a native way to do this, I would probably use a library that abstracts the details of the platform away, like SDL of SFML. No need to use multithreading for this.

Read a bit of documentation and maybe a tutorial on how to do keyboard input with SDL or SFML and post back if you can't figure it out. Edited by alvaro
2

Share this post


Link to post
Share on other sites
#1 no... easy as pie, use 2 arrays, on keydown, mark key as down, on key up, mark key up... next frame, copy 1st array to the second, and repeat... A key that was down last frame and this frame is held, else it's a new button press.

#2 no...

#3 Input should be just like any other task such as physics, or rendering, ie: it will be processed during a slice of the timestep, so collect your key ups key downs when they occur, process them all at once.

As Alvaro mentioned, each os will have it's own method of providing keyboard input. In windows, this would be the windows message pump, and the keyup/keydown messages. This is where a prebuilt library will help, but it is not necessary.
1

Share this post


Link to post
Share on other sites
I think the above answers have covered your question reasonably well, but I just wanted to note that if you're already using GLUT for graphics it does also provide support for keyboard input, so you wouldn't necessarily want SDL or SFML as suggested above -- although they [i]are[/i] certainly good choices. As mentioned above, you don't have to use one of these libraries -- you could just use the calls provided by your operating system -- but using a library such as GLUT, SDL, SFML, Allegro, etc. will make things much easier on you and make it easier to write cross-platform code if you wish to do so once you're more experienced.

You can find a couple of tutorials on keyboard handling with GLUT [url="http://www.swiftless.com/tutorials/opengl/keyboard.html"]here[/url] and [url="http://www.lighthouse3d.com/tutorials/glut-tutorial/keyboard/"]here[/url].


For your third question, certain keyboards can have trouble with missing key events if certain combinations of keys are pressed simultaneously, but this is a hardware problem that even effects commercial AAA titles and isn't something you should really worry about, and would only normally be a problem if you would expect a large number of keys to be held down simultaneously. As mentioned by others, the order of key-presses should not be a problem.


Let us know if you have trouble implementing your input and we'll give you some more tips, but hopefully you've got a good starting point. You should probably stick with a nice simple input system for your first couple of games, but once you've got a good handle on that you might consider more advanced functionality such as allowing your players to re-map the keys; there are some thoughts on how to do so in ApochPiQ's journal entry "[url="http://www.gamedev.net/blog/355/entry-2250186-designing-a-robust-input-handling-system-for-games/"]designing a robust input handling system for games[/url]" and a link to a sample implementation of the code, although it may be a bit advanced till you've had some more practice.


Hope that's helpful! [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
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