Advertisement

What's wrong with this?

Started by August 01, 2000 12:55 PM
4 comments, last by Strife 24 years, 4 months ago
Okay, I've been having these problems for a REALLY long time now. I've posted to the DirectX board, asked people in #gamedev, and did some experimenting, but I can't figure out what's wrong. Basically, I'm trying to get the game to start when I press 'S' from inside the main menu (and I tried to make ENTER work too, to no avail). However, nothing happens when I do this. But for some reason, the 'Q' key works to quit. I have come to the assumption that there must be something wrong in either the way I'm reading keyboard input (with DirectInput), or the main game function (roids_main()) has something terribly wrong with it. The main source file is here. If you have any suggestions to as why this is happening, I'd be more than happy to hear them. If you code it, they will come... Commander M (a.k.a. Crazy Yank) http://commanderm.8m.com cmndrm@commanderm.8m.com Edited by - CmndrM on 8/1/00 12:57:55 PM Edited by - CmndrM on 8/1/00 1:01:01 PM
I''ve read your other posts before and I thought someone had already sorted this one out, but I''ll give it a go (I know nothing about DI at the moment, but I''m reading the SDK for DX7 and LaMothes book Tricks of the windows....)

the following line (according to both DX SDK and LaMothe) is wrong:

lpdikey->GetDeviceState(sizeof(keystate),&keystate);

it should read :

lpdikey->GetDeviceState(sizeof(keystate),(LPVOID)&keystate);

Try that, if someone has already suggested it and it does not work then I think something is way wrong there.

Are you using the latest SDK? I''ve found that DX 7 is easier to program then DX 5 / 6 (IMHO).

hth
When I find my code in tons of trouble,Friends and colleages come to me,Speaking words of wisdom:"Write in C."My Web Site
Advertisement
Well, I'd think it would give me some sort of "casting required" error, but I'll try it. Also, that still doesn't explain why one key works... I think I'll make some dummy keys that'll pop up a message box to test those. I've pretty much come to the conclusion that there's something wrong with roids_main(). However, I will still try your suggestion. Thanks for replying

If you code it, they will come...

Commander M
(a.k.a. Crazy Yank)
http://commanderm.8m.com
cmndrm@commanderm.8m.com

Edited by - CmndrM on August 1, 2000 8:55:50 PM
I am taking a look at your code, and without going through it in too much detail, here are the things that I can see.

First off, the GetDeviceState method returns an array of chars. You have the variable declared as an array of unsigned chars. Unfortunately, the codes that you are checking for are in the range 0x10 to 0x1F which should not cause a problem as the MSB is not set.

The second thing is that the game state (menu / game) is very confusing. This could be a state machine,

gameState = kIntroState;
done = false;

while(!done) {

switch(gameState) {
case kIntroState:
intro();
gameState = kMenuState;

case kMenuState:
// ... menu stuff ...
if (start_key) {
gameState = kRunGame;
}
if (quit) {
done = true;
}
break;

case kRunGame:
// All the game code
if (killed) {
gameState = kMenuState;
}
else if (force_quit) {
done = true;
}
break;
}

or something to that effect.

Good luck with your coding.

- Carl

Okay, thanks for the advice. I''ll give it a shot whenever I get the time (I''ve been REALLY busy lately, so it may be a while).

If you code it, they will come...

Commander M
(a.k.a. Crazy Yank)
http://commanderm.8m.com
cmndrm@commanderm.8m.com
Hmmm, I was hoping someone else would have a suggestion or two...

Oh well.

Anyway, I haven''t had the time yet to try some of these things, but I hopefully will soon. (only have about 5-10 minutes right now to be sitting here and typing this...)

If you code it, they will come...

Commander M
(a.k.a. Crazy Yank)
http://commanderm.8m.com
cmndrm@commanderm.8m.com

This topic is closed to new replies.

Advertisement