getch() is able to cath keypresses including arrows, Arrows are
labeled as 72,80,78 or something in that direction
getch() is able to cath keypresses including arrows, Arrows are
labeled as 72,80,78 or something in that direction
Eehm, Well there was a something like arrows counted as 2
keypresses the first was the keycode and the second was ascii,
but i think you can just catch the first one.
If you have conio.h (which I guess since you mentioned getch() ):Originally posted by CheesyMoo
Thank you RoD but if you looked at my code you could understand that I'm not retarded and I'm not an udder n00b, the problem was how do I read input from the arrow keys(or the virtual keys I guess). I mean like getch() or cin or what?
Code://Use a useless key here #define NOKEYPRESSED 1 char Key = NOKEYPRESSED; while(Key != 27) { Key = NOKEYPRESSED; if(kbhit()) Key = getch(); switch(Key) { //An arrow key was pressed case 0: switch(getch()) { case 72: cout << "Up" << endl; break; case 75: cout << "Left" << endl; break; case 77: cout << "Right" << endl; break; case 80: cout << "Down" << endl; break; } break; } }
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
c:\documents and settings\chucky\local settings\temporary internet files\content.ie5\rgwb1hop\carlcash[1].cpp(34) : error C2065: 'gotoxy' : undeclared identifier
c:\documents and settings\chucky\local settings\temporary internet files\content.ie5\rgwb1hop\carlcash[1].cpp(488) : error C2065: 'clrscr' : undeclared identifier
Error executing cl.exe.
These are Boreland specific functions, You have borland?Originally posted by Silvercord
c:\documents and settings\chucky\local settings\temporary internet files\content.ie5\rgwb1hop\carlcash[1].cpp(34) : error C2065: 'gotoxy' : undeclared identifier
c:\documents and settings\chucky\local settings\temporary internet files\content.ie5\rgwb1hop\carlcash[1].cpp(488) : error C2065: 'clrscr' : undeclared identifier
Error executing cl.exe.
Where did you get the number 27 from?Originally posted by Travis Dane
Eehm, Well there was a something like arrows counted as 2
keypresses the first was the keycode and the second was ascii,
but i think you can just catch the first one.
getch() should return it.Originally posted by CheesyMoo
Where did you get the number 27 from?
27 is the ascii code for ESC.Originally posted by CheesyMoo
Where did you get the number 27 from?
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
I think he made a typo and ment 72Originally posted by Magos
27 is the ascii code for ESC.
--
Could've been coded better, also a bit buggy.
I am against the teaching of evolution in schools. I am also against widespread
literacy and the refrigeration of food.
Okay I made the code alot simpler and the game is less buggy, I think. Please tell me some bugs that you find.
Oh yeah, I didn't add in using the arrow keys because I think that it is easier to reach the other buttons like, 't' for talk etc.. Well thanks!