0

hi i have two problems in c++ console application


1. I want a function to execute when a certain key is pressed .kbhit() is for any key but i want to modify it to a specific key ..plz tell me about it also if any other function can do this


2.i want to retrieve the x and y coordinates of of an object...how can i do this

Edited by learner guy: n/a

2
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by Narue
0

kbhit() is for any key but i want to modify it to a specific key ..

kbhit() tells you if a key has been pressed. You can then use getch() to determine the value of the key.

i want to retrieve the x and y coordinates of of an object...how can i do this

Please specify what you mean by an "object".

0

thanks Narue for ur reply

can u plz tell how to use kbhit withi getch()


object means any character

0

can u plz tell how to use kbhit withi getch()

if (kbhit() && getch() == character_you_want) {
    // Yay!
}

object means any character

Well, you can manually keep a copy of the visible screen in memory. I don't think the conio.h library supports extracting already written characters even on Borland compilers. Your next step if you don't want to maintain your own copy of the screen is to use a library such as PDCurses which have the functionality you want (the inch() functions in particular for curses variants).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.