• Advertisement
Sign in to follow this  

Need little help :)

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

Hi guys, i'm new on these forum and new in game programming and currently i'm making my first game :) I'm making rogue-like game and until now i've done the player creating, combat & movement functions and some kind of map-generator (it uses allready maked rooms, but place them randomly in the level). Now i'm going to write the game loop... and have a problem - i dont know how the find what type of key is pressed (right arrow, space...) :/ It will be nice if you can give me an advice or two :) btw at the moment the game is console (the DOS-console), but i'm thinking to make it with graphics, when i have a playable version. EDIT: ah, i forgot - i'm coding in C++ :)

Share this post


Link to post
Share on other sites
Advertisement
you can use the getch() function. For extended characters you will have to call getch() twice - the first time will return a value indicating that it's an extended character, then the second will be the actual value you're interested in. The arrow keys generate extended characters.

getch() is in conio.h

You can use the kbhit() function if you don't want to wait for the user to press a key.

Share this post


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

  • Advertisement