anyone know how to move the character @ up, down, left, and right when the specific buttons are pressed?
dank you
anyone know how to move the character @ up, down, left, and right when the specific buttons are pressed?
dank you
Code:#if _emo #define stereo_type_i_dislike #endif
Like this?:
Sorry about not commenting....Code:#include <iostream.h> #include <conio.h> #include <stdlib.h> void main() { char ch; int x = 10, y = 10; gotoxy(x, y); cout << "@"; while(1) { ch = getch(); gotoxy(x, y); cout << " "; switch(ch) { case 'a': x--; break; case 's': x++; break; case 'z': y++; break; case 'w': y--; break; default: exit(0); } gotoxy(x, y); cout << "@"; } }
well, not like that. that code closes when a button is pressed. How about using the getch(); command??
Code:#if _emo #define stereo_type_i_dislike #endif
>well, not like that. that code closes when a button is pressed. How about using the getch(); command??<
What do you mean the code closes when a button is pressed?
And, if you pay attention to the code, you'll notice I do indeed use getch().
Press [a] to move the character left.
Press [s] to move the character right.
Press [w] to move the character up.
Press [z] to move the character down.
Hope that helps...