Thread: Carl Cash! My new game!

  1. #16
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    getch() is able to cath keypresses including arrows, Arrows are
    labeled as 72,80,78 or something in that direction

  2. #17
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Wouldn't those numbers be capital letters?

  3. #18
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Eehm, Well there was a something like arrows counted as 2
    keypresses the first was the keycode and the second was ascii,
    but i think you can just catch the first one.

  4. #19
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by CheesyMoo
    Thank you RoD but if you looked at my code you could understand that I'm not retarded and I'm not an udder n00b, the problem was how do I read input from the arrow keys(or the virtual keys I guess). I mean like getch() or cin or what?
    If you have conio.h (which I guess since you mentioned getch() ):
    Code:
    //Use a useless key here
    #define NOKEYPRESSED 1
    
    char Key = NOKEYPRESSED;
    while(Key != 27)
    {
       Key = NOKEYPRESSED;
       if(kbhit()) Key = getch();
    
       switch(Key)
       {
          //An arrow key was pressed
          case 0:
             switch(getch())
             {
                case 72:
                   cout << "Up" << endl;
                   break;
    
                case 75:
                   cout << "Left" << endl;
                   break;
    
                case 77:
                   cout << "Right" << endl;
                   break;
    
                case 80:
                   cout << "Down" << endl;
                   break;
             }
             break;
       }
    }
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  5. #20
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    c:\documents and settings\chucky\local settings\temporary internet files\content.ie5\rgwb1hop\carlcash[1].cpp(34) : error C2065: 'gotoxy' : undeclared identifier
    c:\documents and settings\chucky\local settings\temporary internet files\content.ie5\rgwb1hop\carlcash[1].cpp(488) : error C2065: 'clrscr' : undeclared identifier
    Error executing cl.exe.

  6. #21
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by Silvercord
    c:\documents and settings\chucky\local settings\temporary internet files\content.ie5\rgwb1hop\carlcash[1].cpp(34) : error C2065: 'gotoxy' : undeclared identifier
    c:\documents and settings\chucky\local settings\temporary internet files\content.ie5\rgwb1hop\carlcash[1].cpp(488) : error C2065: 'clrscr' : undeclared identifier
    Error executing cl.exe.
    These are Boreland specific functions, You have borland?

  7. #22
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Originally posted by Travis Dane
    Eehm, Well there was a something like arrows counted as 2
    keypresses the first was the keycode and the second was ascii,
    but i think you can just catch the first one.
    Where did you get the number 27 from?

  8. #23
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by CheesyMoo
    Where did you get the number 27 from?
    getch() should return it.

  9. #24
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by CheesyMoo
    Where did you get the number 27 from?
    27 is the ascii code for ESC.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  10. #25
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by Magos
    27 is the ascii code for ESC.
    I think he made a typo and ment 72
    --

  11. #26
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Here's the latest build.
    Questions?
    Comments?

  12. #27
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    Could've been coded better, also a bit buggy.
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  13. #28
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Okay I made the code alot simpler and the game is less buggy, I think. Please tell me some bugs that you find.

    Oh yeah, I didn't add in using the arrow keys because I think that it is easier to reach the other buttons like, 't' for talk etc.. Well thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 20q game problems
    By Nexus-ZERO in forum C Programming
    Replies: 24
    Last Post: 12-17-2008, 05:48 PM
  2. Need book to program game into multiplayer...
    By edomingox in forum Game Programming
    Replies: 3
    Last Post: 10-02-2008, 09:26 AM
  3. Try my game
    By LuckY in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 09-15-2004, 11:58 AM
  4. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 04:19 AM
  5. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM