key input

1 view
Skip to first unread message

jLl

unread,
Jan 22, 2006, 2:36:27 PM1/22/06
to C++ Game Programming
Is there any simple way to just pick up on the 4 arrow keys??

I'm trying to avoid using a huge class that has capabilities of reading
every key, so the final file size is reduced...if possible.

jakob lin

unread,
Jan 22, 2006, 2:38:10 PM1/22/06
to C-Game-Pr...@googlegroups.com
nope
--
Jakob Lin Mall

jLl

unread,
Jan 22, 2006, 3:11:03 PM1/22/06
to C++ Game Programming
...how convenient...

is there any way, at all??
cause I haven't found anything...I was just hoping to keep it small...

jakob lin

unread,
Jan 22, 2006, 3:13:52 PM1/22/06
to C-Game-Pr...@googlegroups.com
why do you want to keep it small ?   are you lazy ?  or sumthin  ?    90 % of people have 300 gb hard drive   i don't understand why people want to keep it small.    plus people are using 4 ghz cpu so why woudl any one want to make the program  .....

On 1/22/06, jLl <mos...@gmail.com> wrote:



--
Jakob Lin Mall

jLl

unread,
Jan 22, 2006, 3:23:44 PM1/22/06
to C++ Game Programming
I want to keep it small cause it's a simple concept...a 2D
puzzle...scrolling and alpha-numerics.

I can easily get the alpha-numerics...just need to get the scrolling.

btw...I'm using a laptop with only a 60GB HDD and a 1.6GHz mobile
processor.

I'm in college and this is meant to be an "Extra Credit" project.

jLl

unread,
Jan 22, 2006, 3:37:19 PM1/22/06
to C++ Game Programming
Most ppl want to keep it small cause it's more convenient.
And, no...90% of people don't have 300GB or more...maybe 30% do...5-10%
don't even own computers...and 50-70% buy generics or "bare-bone"
computers from Dell, HP, E-Machines, and similar companies.

Many businesses still use computers that run DOS or older OSs.
And trying to simply say "You need to update" isn't going to work.
Cause the cost of updating would be too great when they already have a
system that works.

So...with that in mind...why wouldn't you want to go small??
Unless the program was completely for personal use...when you know you
have the resources...why wouldn't you try to make it as small as
possible??

Spy187

unread,
Jan 23, 2006, 5:36:01 AM1/23/06
to C++ Game Programming
There is a way to do it (i assume you are using directx) but you won't
be using direct input you will be using windows messages which can be
laggy.

Do this in your window handle fucntion:
bool keys[256]; // Array Used For The Keyboard Routine

LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
UINT uMsg, // Message For This Window
WPARAM wParam, // Additional Message Information
LPARAM lParam) // Additional Message Information
{
switch (uMsg) // Check For Windows Messages
{
case WM_KEYDOWN: // Is A Key Being Held Down?
{
keys[wParam] = TRUE; // If So, Mark It As TRUE
return 0; // Jump Back
}

case WM_KEYUP: // Has A Key Been Released?
{
keys[wParam] = FALSE; // If So, Mark It As FALSE
return 0; // Jump Back
}
}
// Pass All Unhandled Messages To DefWindowProc
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}

jakob lin

unread,
Jan 23, 2006, 11:38:28 AM1/23/06
to C-Game-Pr...@googlegroups.com
dude dude u forgot key left and key right    :P  
--
Jakob Lin Mall

Saumav Dutta

unread,
Jan 23, 2006, 8:09:01 PM1/23/06
to C-Game-Pr...@googlegroups.com

:)) Jacob, Here WM_KEYUP and WM_KEYDOWN doesn’t mean up arrow key nd down arrow key. It means a key is pressed nd released. It also commented there. Didn’t u notice that.

 


jakob lin

unread,
Jan 23, 2006, 9:03:47 PM1/23/06
to C-Game-Pr...@googlegroups.com
oh you meant any arrow key press      not 4 arrows keys functions    my bad !!!  :p 
--
Jakob Lin Mall
www.angelfire.com/co2/jake3

Spy187

unread,
Jan 24, 2006, 3:25:19 PM1/24/06
to C++ Game Programming
heheh!! lol..

use

if (keys[VK_UP]) cout << upkeypressed

Vaelek

unread,
Jan 25, 2006, 9:45:07 AM1/25/06
to C++ Game Programming
All you have to do is put this case statement in your window callback
procedure function:

case WM_KEYUP:
// Has A Key Been Released?
{

if( wParam == VK_UP)
// do the code for the up arrow being
released
else if( wParam == VK_DOWN)
// do the code for the down arrow being
released
else if( wParam == VK_LEFT)
// do the code for the left arrow being
released
else if( wParam == VK_RIGHT)
// do the code for the right arrow being
released

break;
}

This will check to see if one of the arrow keys have been released up.
If you want the user to be able to just hold down the keys and the
effects are repeated then use case WM_KEYDOWN instead of WM_KEYUP.

jakob lin

unread,
Jan 25, 2006, 11:38:12 AM1/25/06
to C-Game-Pr...@googlegroups.com
that is the code i was thinking about .

BlueRaja

unread,
Jan 25, 2006, 4:11:08 PM1/25/06
to C-Game-Pr...@googlegroups.com
Jakob, please stop spamming the forums or you will be banned, thanks.

jatin makhija

unread,
Feb 9, 2006, 2:13:26 AM2/9/06
to C-Game-Pr...@googlegroups.com
small is not always great--keep in mind
but the thing is that,,,for expandability of any business you have to consider the
large things---like you have just specified the 300GB storage capacity
 
 
i thing it shuld be more than this
 
DOS And OTHER OS's are doing great also now a days but for doing things faster
and now all the things are GUI based that really a great development
in the graphics.
 
why WINDOWS is making//updating its versions
why WINDOWS have made Vista
all because of security reasons
...........

Craig Truzzi

unread,
Feb 10, 2006, 11:04:33 AM2/10/06
to C-Game-Pr...@googlegroups.com
Well sadly I cannot help at this because I am not sure if there is any way to keep it small. But I do know why you want to. I am the same way when i program. We are sort of old fashion even if we are brand new or semi new. I try and keep even the most retarted codes very small. I am not sure why even though people have 60+ gig hard drives we act like we are still in the 4gig stage. It's better to be small as well because it jhust means it will look over all better to some. Prespective is really different in every one.
Well any ways you are going to have to define every single key, sort of like how you have to use different libraries to get different functions. This is because you are the key inbetween the room and the locked door. The computer has no idea what you want it just does what it is told. Also back when C++ was created (or C) there where no games on the computer, no one considered the up arrow to be forward. Any ways there are a few programming languages that are for gaming more and are easier to define.

 
--
- Craig Truzzi
TERESA AND SNOWBOARDING ARE MY LIFE.

Craig Truzzi

unread,
Feb 10, 2006, 11:07:31 AM2/10/06
to C-Game-Pr...@googlegroups.com
Sorry for posting twice but how about you try.
 
Modula 3
Reply all
Reply to author
Forward
0 new messages