Answer the question
In order to leave comments, you need to log in
What functions (or non-functions) should be used to create a moving object in the console on pressing a certain key?
Let's say I have a char variable. I want to make it so that when I press, for example, the "W" key, my character moves up, when I press "S" - down, etc.
Answer the question
In order to leave comments, you need to log in
if on Windows, then the simplest:
#include <conio.h>
....
char key = getch();
switch(key) {
case 's': direction = DOWN;
break;
}
charm;
char m=getch();
switch(m)
{case "W":Example1();break;
case "S":Example2();break;
default:break;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question