Thread: ascii values for keys

  1. #1
    Registered User
    Join Date
    May 2003

    ascii values for keys

    I'm having trouble with keys. What happen was we were doing a game, really basic, and by we I mean me and two friends. So far we have a feature that we can have an unlimited number of people saving into the same .dat file. We have a system using linked pointer for a graph of rooms. starting at one we did the first line and added 5 to the "top"pointer when it moved "east"
    done using this struct...just a fancy bin tree no biggie
    struct room
        //room id(used for finding what is in that room so we can use
        //some repeated desc[]'s
        int id;
        //description of each room
        char desc[201];
        //each room possibly has 4 exits
        struct room *north,*south,*east,*west;
    uh after that we then started to pull out some creativity to make desc's for each room. We are having trouble with one thing however. Our commands are using the ascii values that pressing a key using getch(); in conio.h with visual studio (don't know if it's in the standard library.) So m is 109 and k is 107 and soforth. However pressing the right arrow key in the numpad while numlock is off or on the regular arrow pad it does the same thing as m which requires that command = getch(); == 107 to be run. So now that I've figured out this problem I discovered OTHER problems with this too for example page up does things that the ascii value fo s does and F10 does what 'i' does I know we use ascii values for it all but I want to know if there is a way we can diferentiate them IE a different method of "keytrapping" using ascii values or anyhting...also when I discovered this I said well if I can find the ascii values for up and down we can use those to move, so I tried looking them up and they don't seem to have one. I fond one thing that was way out of our league. Basically what I'm really looking for is a tried and trued method of going around getting several commands from alot of keys. We need one to pick up items, move east, south west and north, talk to people and other things that will be gradually added to the game. So far the story is more or less an outline, having a history complete and alot of the details worked out. A few of the details IE and EXACT script of who says what and what everyone does at the EXACT time does. That will come later on. Hopefully before the game is finished anyway... anyhelp would be greatly appreciated. Oh one more thing...We were messing with making pictures out of non-standard ASCII values taht dos doens't use but rather changes them into different shapes...mostly being french letters like U's with a colon sideways above it, french accent. And we then started lookig for things that would let us add a bit O color without doing an insane color thing. We did find on program that did let us do the pic editing in it and use colors but my visualy C++ compiler didn't let us use it, instead it printed out a ton of garbage and beep at us...alot. Anyone know of an easy way to use colored text in C under DOS? ANY help for ANY of these problems would be greatly appreciated.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    So far we have a feature that we can have an unlimited number of people saving into the same .dat file.
    You're best served with another method here. You'll likely want to store each player seperately so that if you delete one player, you don't have to shuffle your main .dat file around.

    This will also help in the event of player corruption. (IE: One corruption nukes your whole .dat file.)

    Either that or you'll want to use an actual database (MySQL or what not) for your storage.

    The F-keys are actually two keystrokes. The first is an escape character, followed by the corresponding key value. There are tons of tutorials and what not that will give you what you're looking for. All you do is have to look for it.

    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    May 2003
    We got the key problem fixed, thanks. All the characters in one file is for now. This is the first programming effort to make the game. Right now the ascii picture guy wants color. Bithcy ain't he. Uhh, he thinks hex values will work. we're going to try that. Thanks for your help.

    For the file when we "delete" a character we don't actually delete it, we just mark a field called deleted to 1 and if deleted = 1 it will not write it and we overwrite the file every time...if they corrupt a player...$$$$ happens.
    Last edited by acid45; 05-12-2003 at 07:17 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. reading values from a file
    By megastar in forum C Programming
    Replies: 4
    Last Post: 06-25-2007, 02:08 AM
  2. Computing Large Values
    By swbluto in forum C++ Programming
    Replies: 8
    Last Post: 04-07-2005, 03:04 AM
  3. can't assign proper values to an array of string
    By Duo in forum C Programming
    Replies: 1
    Last Post: 04-04-2005, 06:30 AM
  4. adding ASCII
    By watshamacalit in forum C Programming
    Replies: 0
    Last Post: 12-26-2002, 05:25 PM
  5. How to read in empty values into array from input file
    By wpr101 in forum C++ Programming
    Replies: 5
    Last Post: 11-28-2002, 10:59 PM