• Advertisement

Archived

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

Cursor Problem

This topic is 5150 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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; }

Share this post


Link to post
Share on other sites
Advertisement
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);

Share this post


Link to post
Share on other sites
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;

}

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement