What code do I punch in to make the arrow keys move my little guy?
What code do I punch in to make the arrow keys move my little guy?
well, since you haven't told us what platform this is for or what input API you're using (if you're using one, at all) it's hard to say.
You need to give more details about how you're writing this game in the first place.
if kbhit()
{
char dir=getch();
if (dir==72)
x--;
}
...etc.
Just look around to find the codes for the other keys.
PS: I might be wrong about left being 72.
um he said sprite not console char, if im understanding correctly
No, Leeman, the code that smartperson posted would work. It is almost identical to the code that I have used in several of my early 13h graphical programs. Of course it needs some tailoring to the purpose of the invidiual program, but that general code is a very good example and will work.
The numbers of the arrow keys in the ASCII character set are:
right arrow = 77
left arrow = 75
up arrow = 72
down arrow = 80
oh ok, 13h mode. i was refering to thinking he was asking about an api such as allegro, dx, opengl or something of that likes.
I don't think DavidP was neccessarily saying that Hyper was using 13h, but just saying that the code was similar to what HE used in 13h. Although I could be wrong. Maybe the thread starter should clear this up, then he'll probably get the answer that he is looking for.
Yes, although it is very similar to what I used in 13h, it can be used in other graphic modes an APIs. Even in OpenGL, DX, SDL, etc. Although I suggest using those API's built in keyboard handlers, you can also handle the keyboard this way in those API's, except for using the getch function, you would probably need a different function instead of getch.
if you are going to make a free roaming game, collision detection will kill you if you put it in . It may be just me, but I have always sucked at collision detection.
Sorry, I should've been more specific, its a console application, and the game is an overhead view. (It is me, I just didn't feel like logging in)