-
how!?!?!?!?!?!?!?!!?!?
how can i make a thing like a menu and u use the arrow keys to change ur slection and somewhere on the screen (perhap a varibale) changes (a description varibale of that selection) and u hit enter to do it. i know this is possible. but how. i am not asking for you to write the code for me. i am aksing if you knwo of any tutorials etc. if you would like to give me a code thats ok also. :-D
-
I worked on something like this earlier for a "Mists of Avalon" thing. Bacially, you display all your options, right? Like so:
Code:
Items ---
--------------------
Elixir
Heal
DP Up
MP Up
Level Up
Next, using printf() and gotoxy, you would show the first location of the arrow thing.
Code:
Items ---
--------------------
Elixir <
Heal
DP Up
MP Up
Level Up
Finally you'd just put in a loopand check to see if the arrow keys or enter is pressed:
Code:
while (keyPressed!=K_ENTER) // Assume K_ENTER has already been defined
{
if (keyPressed == UP)
{
gotoxy(x,y); // where x and y are the coordinates of the item
printf("<");
}
...
}
Hope that helps!
Brendan
-
umm its a lot easier to read if u put it all into one code then say **** about it. i didnt get to muhc on wut u siad
-
Well I'm sorry if you don't get it, it can't be that hard to put it all together.
Brendan
-
ok.. just help me wiht this part
while (keyPressed!=K_ENTER) // Assume K_ENTER has already been defined
how wold i "define" k_enter
-
Like so:
#define K_ENTER 13
Then you'd use a function like getch() and test to see if Enter was pressed. Red_Baron's Dungeons of Moria game has the source code with it. One of the header files, keys.h, defines all the keys I think there are. You may find it useful :).
Brendan
-
-
I see they keyboard's Enter code (or whatever you call it) is 13. Is there a website that will give me all the ASCII? values for the keyboard keys?
-
Use google to search for ASCII. The fourth or fifth site that comes up holds an Ascii table and is even named www.asciitable.com.
If you need it as source code, Red_Baron's Dungeons of Moria game has the source code with it. One of the header files, keys.h, defines all the keys I think there are.
-
wut header file is needed for keypressed and wut is needed for gotoxy
-
Well, actually keyPressed is just a variable. I made my own gotoxy() function, works quite well. With the keyPressed thing:
Code:
int keyPressed = GetKey();
...
int GetKey()
{
int result = getch();
return result;
}
Some thing like that. Hope that helps. And about the gotoxy() thing, I can post the code on that later, I don't have it with me right now.
Brendan
-
"getch()" will not work on windows machines. Why? Because it will not "move" until the ENTER key is pressed. You must hunt for the header "conio_mingw.h" and include it into your project. Then call the function "_getch()".
-
Sorry works fine for me. Though I do have other code in there besides just what I showed, but I don't remember it offhand. I'm on the wrong computer right now.
Brendan
-
here..
This nifty program that I wrote prints
the keycodes of almost every key that you press...
(except "Control", "Alt" , etc )
PHP Code:
#include <stdio.h>
#include <conio.h>
main()
{
char c;
printf("KEY\tCODE\n");
while ((c = getch()) != 27)
{
printf("%3c\t%4d\n", c, (int)c);
fflush(stdin);
}
}
-
moonwalker, i saw ur website and i thought ur programs there were koool, i jsut wanted to makr that, but i was wondering if u could e-mail me the bg music u have on the left frame? i tried to find the url by viewing th source but the frame looked confusing