Thread: how!?!?!?!?!?!?!?!!?!?

  1. #1
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608

    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
    Email: [email protected] || AIM: MisterSako || MSN: [email protected]

    -the shroom has spoken

  2. #2
    Registered User
    Join Date
    Jul 2002
    Posts
    94
    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

  3. #3
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    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
    Email: [email protected] || AIM: MisterSako || MSN: [email protected]

    -the shroom has spoken

  4. #4
    Registered User
    Join Date
    Jul 2002
    Posts
    94
    Well I'm sorry if you don't get it, it can't be that hard to put it all together.

    Brendan
    Draco dormiens nunquam titillandus

  5. #5
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    ok.. just help me wiht this part

    while (keyPressed!=K_ENTER) // Assume K_ENTER has already been defined

    how wold i "define" k_enter
    Email: [email protected] || AIM: MisterSako || MSN: [email protected]

    -the shroom has spoken

  6. #6
    Registered User
    Join Date
    Jul 2002
    Posts
    94
    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
    Draco dormiens nunquam titillandus

  7. #7
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    thanks for your help
    Email: [email protected] || AIM: MisterSako || MSN: [email protected]

    -the shroom has spoken

  8. #8
    Registered User GrNxxDaY's Avatar
    Join Date
    Jul 2002
    Posts
    140
    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?
    AOL: GrNxxDaY
    IDE: Dev-C++ Beta 5 (v4.9.4.1)
    Project: Eye of Sahjz (text-RPG)
    If you think I may need help, please IM me.

  9. #9
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    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.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  10. #10
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    wut header file is needed for keypressed and wut is needed for gotoxy
    Email: [email protected] || AIM: MisterSako || MSN: [email protected]

    -the shroom has spoken

  11. #11
    Registered User
    Join Date
    Jul 2002
    Posts
    6
    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

  12. #12
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    "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()".
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  13. #13
    Registered User
    Join Date
    Jul 2002
    Posts
    6
    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

  14. #14
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282

    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 ((
    getch()) != 27)
        {
            
    printf("%3c\t%4d\n"c, (int)c);
            
    fflush(stdin);
        }


  15. #15
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    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
    Email: [email protected] || AIM: MisterSako || MSN: [email protected]

    -the shroom has spoken

Popular pages Recent additions subscribe to a feed