Advertisement Jump to content
Sign in to follow this  
mike003

pong update

This topic is 4911 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

Ive been working on pong now for a while, and i'm trying to use getchar() to detect the keys. for some reason, it always keeps on pausing for input of the character every time. heres that part of my source code, tell me if anything is wrong with it: char key = getchar(); if(key==119) { pong[49][rpaddle+2]=' '; rpaddle=rpaddle-1; if(rpaddle==0) { rpaddle=1; } } if(key==115) { pong[49][rpaddle]=' '; rpaddle=rpaddle+1; if(rpaddle==24) { rpaddle=23; } }

Share this post


Link to post
Share on other sites
Advertisement
Getchar will not work, it is supposed to pause for input. I forget, however, which function needs to be used. Lemme look it up.

Share this post


Link to post
Share on other sites
You need real-time keyboard input. getchar() waits until you hit a key so it won't work. If you are in Windows, look into GetAsyncKeyState(). If you are doing this without an API, then your only choice is writing up an interrupt handler.

NOTE: The left statements are equivalent to the right statements
x = x + 1 -> x++
x = x - 1 -> x--

Mark

Share this post


Link to post
Share on other sites
how would i use GetAsyncKeyState() in my code?

edit:

any1 feel like answering?...

[Edited by - mike003 on August 11, 2005 3:34:51 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!