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

Archived

This topic is now archived and is closed to further replies.

paulcoz

DirectInput and Keyboard

4 posts in this topic

I have written some code using the DirectX diks structure which interprets keyboard input from the user like this: if ( particular key is down ) do this if ( another key ) do this All is working fine but I would like to know if you can do the same thing for the key being released. I know there is a WM_KEYUP message for the window but I would really like to use DirectX to do it and I also don't want some code in my DirectInput function and some in the Windows message handler. Any ideas?, Paulcoz. Edited by - paulcoz on 1/20/00 7:08:51 PM
0

Share this post


Link to post
Share on other sites
What you are looking for is, I beleived, the buffered input feature of DirectInput. You set a size for input buffer for DirectInput, then from time, poll it, retreive the buffer values. Instead of checking the current states of the keyboard keys, now you get a list of keydowns and keyups and the time they occurred(timestamps) in sequence.
Check up buffer input in DirectInput for more information
0

Share this post


Link to post
Share on other sites
My solution to this is as follows:
Make three boolean arrays, one for the keys that are down, one for the keys that were down last frame, and one for keys that were just released. Right before you do your keyboard if statements, scan through the arrays and set the appropriate values. If the keys was down last frame and is not down now, set the release for that key to true, otherwise set it to false. Then set the last frame array to the current keystates.

int j;
for (j = 0; j < 256; j++)
{
if (m_KeyL[j] && !keys[j])
m_KeyR[j] = TRUE;
else
m_KeyR[j] = FALSE;
m_KeyL[j] = keys[j];
}

Good luck,
Wraith


Edited by - Wraith on 1/23/00 5:28:02 PM
0

Share this post


Link to post
Share on other sites
why bother with bool and scanning...
simply save the last keystate into prev or whatever you prefer to call it then just check for keydown in the previous keystate and that the key is up in the current:

if ( (state_prev[Key] & 0x80) && !(state[Key] & 0x80) ) // take action

Edited by - Staffan on 1/23/00 5:34:54 PM
0

Share this post


Link to post
Share on other sites

Buffered Input is definitely the way to go here.
This way you''ll only have to run through your set
of "if" statements when you get a new keypress in
the buffer rather than having to go through it
ever frame.
0

Share this post


Link to post
Share on other sites