Cursor Problem

Started by
5 comments, last by Dunezone 20 years, 3 months ago
Im writing a console game right now for class but for some odd reason my cursor jumps two spots instead of just one. Heres the code for the move. if(InputRecord.Event.KeyEvent.wVirtualKeyCode == VK_RIGHT) { PlaySound("walk.wav", NULL, SND_FILENAME | SND_ASYNC); CursorPosition.X = CursorPosition.X + 1; Score.score = Score.score + 1; }
Advertisement
You might be getting two key events: One for keydown, and one for keyup.

I like pie.
[sub]My spoon is too big.[/sub]
Well heres the code to intialize the movement. Its followed up by the do loop which contains the code in my first message.


HANDLE hInput, hOutput;
INPUT_RECORD InputRecord;
COORD CursorPosition;
DWORD Events=0;

hInput = GetStdHandle(STD_INPUT_HANDLE);
hOutput = GetStdHandle(STD_OUTPUT_HANDLE);

SetConsoleMode(hInput, ENABLE_PROCESSED_INPUT);

CursorPosition.X = 0;
CursorPosition.Y = 0;

Score.score = 0;

static HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
static HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
quote:Original post by RenderTarget
You might be getting two key events: One for keydown, and one for keyup.

I like pie.


Thats exactly what my problem was. So I had this friend add this code to the program and it worked at school but now its saying "isOnDownEvent" is an undeclared identifier,ill know for certain what im doing wrong tommorrow but anyone have any ideas?


if(InputRecord.Event.KeyEvent.wVirtualKeyCode == VK_RIGHT)
{
if(isOnDownEvent)
{
//change pos
CursorPosition.X--;
Score.score = Score.score + 1;
}
//change the event type state
isOnDownEvent = !isOnDownEvent;

}

Apparently the files at school are not the same as those at home since you have yet to declare isOnDownEvent.

Colin Jeanne | Invader''s Realm
Yeah, obviously. I sat there and watched him to do, and I dont remember him adding anything else in, but I will see the working source tommorrow. I was just hopeing someone would happen to have a clue so I could work with that tonight.
isOnDownEvent is a bool. It looks like that''s all you need to define.

Colin Jeanne | Invader''s Realm

This topic is closed to new replies.

Advertisement