Thread: My first C++ game is done!

  1. #16
    Registered User
    Join Date
    Jun 2002
    Posts
    267
    Originally posted by Klinerr1
    and the ability to move the piece a few seconds after it hits should be an option us the users can turn off.
    Yea well, I'm not going to "re-open" the project to add stuff like that... there were many things I had originally wanted to add, but I just decided not to because I wanted to drop this sloppy project and move onto something else

    (if you look at the source you'll see it's un-commented, sloppy, and very n00bish! )

    But hey, I learned a lot from this... so I'm happy

  2. #17
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542
    Originally posted by d00b
    Ways to stop program execution:
    • Pull out PSU power cable
    • Press and hold hardware reset
    • Shut off main power breaker to the house
    • Climb nearest pole and cut power line to house
    • Load 12 gauge shotgun and fire at CPU
    Nice hehe
    what does signature stand for?

  3. #18
    Registered User
    Join Date
    Aug 2001
    Posts
    244
    >_< I just tried that thing with climbing the pole and cutting the power line!11`
    The execution stopped, BUT NOW I CAN NEVER STOP AN EXECUTION AGAIN >_<







    signature under construction

  4. #19
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542
    Really? Lucky
    what does signature stand for?

  5. #20
    Registered User GrNxxDaY's Avatar
    Join Date
    Jul 2002
    Posts
    140
    i'm trying to make a game that i can use the arrow keys on the keyboard.. but it seems that they have the same ASCII value as some letter keys, and in your code you define them the same.. how does the computer konw the difference when they are pressed?
    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.

  6. #21
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542
    Use the VK_ extention... eg: VK_LEFT or VK_RIGHT
    what does signature stand for?

  7. #22
    Registered User GrNxxDaY's Avatar
    Join Date
    Jul 2002
    Posts
    140
    huh?
    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.

  8. #23
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542
    I had that in a tutorial... i cant remember
    what does signature stand for?

  9. #24
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Code:
    case WM_KEYDOWN:
         switch(lParam)
         {
              case 'A':
                   letterA();
                   break;
              case 'b':     //This won't work, it has to be uppercase.
                   letterB();
                   break;
              case VK_UP:
                   goUp();
                   break;
         }
         break;
    
    case WM_KEYUP:
         switch(lParam)
         {
              case 'A':
                   unLetterA();
                   break;
              case 'b':     //This won't work, it has to be uppercase.
                   unLetterB();
                   break;
              case VK_UP:
                   stopUp();
                   break;
         }
         break;
    I never tried it, but I think that's how it's supposed to work (although I might have gotten lparam and wparam mixed up).
    Last edited by Hunter2; 08-13-2002 at 01:20 PM.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  10. #25
    Registered User
    Join Date
    Jun 2002
    Posts
    267
    I used this function to get keypresses:
    Code:
    bool Keypress(char &Key)
    {
    	INPUT_RECORD	Event;
    	DWORD	NumberOfEvents, EventsRead, EventCounter;
    
    	GetNumberOfConsoleInputEvents(hConsole_in, &NumberOfEvents);
    
    	if (NumberOfEvents == 0)
    		return false;
    	
    	for (EventCounter = 0; EventCounter < NumberOfEvents; EventCounter++)
    	{
    		PeekConsoleInput(hConsole_in, &Event, 1, &EventsRead);
    		if ((Event.EventType == KEY_EVENT) && ((Event.Event.KeyEvent.bKeyDown)))
    		{
    			ReadConsoleInput(hConsole_in, &Event, 1, &EventsRead);
    			Key = Event.Event.KeyEvent.wVirtualKeyCode;
    			if (!(FlushConsoleInputBuffer(hConsole_in)))
    				exit(0);
    			return true;
    		}
    		else
    			ReadConsoleInput(hConsole_in, &Event, 1, &EventsRead);
    	}
    
    	return false;
    }
    So then you could do this:
    Code:
    char key = 0;
    for (;;)
    {
    	if (Keypress(key))
    	{
    		switch(key)
    		{
    		case VK_LEFT:
    			// left
    		case VK_RIGHT:
    			// right
    		default:
    			// anything else
    		}
    	}
    	// something to do if no key is pressed
    }

  11. #26
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    *sorry, I'm doing a Windows app right now.. thought you meant keypresses in a window.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  12. #27
    Registered User GrNxxDaY's Avatar
    Join Date
    Jul 2002
    Posts
    140
    wha
    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.

  13. #28
    Registered User
    Join Date
    Jun 2002
    Posts
    267
    Hunter thought you meant how to capture keystrokes in a GUI window

  14. #29
    x4000 Ruski's Avatar
    Join Date
    Jun 2002
    Location
    Outer Space!
    Posts
    542
    Originally posted by Hunter2
    Code:
    case WM_KEYDOWN:
         switch(lParam)
         {
              case 'A':
                   letterA();
                   break;
              case 'b':     //This won't work, it has to be uppercase.
                   letterB();
                   break;
              case VK_UP:
                   goUp();
                   break;
         }
         break;
    
    case WM_KEYUP:
         switch(lParam)
         {
              case 'A':
                   unLetterA();
                   break;
              case 'b':     //This won't work, it has to be uppercase.
                   unLetterB();
                   break;
              case VK_UP:
                   stopUp();
                   break;
         }
         break;
    I never tried it, but I think that's how it's supposed to work (although I might have gotten lparam and wparam mixed up).
    I remember some code I saw.. was something like:
    Code:
    if(GetKeyStat orsomething like that... == VK_UP && 0x80)
    {
    do whatever();
    }
    what does signature stand for?

  15. #30
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    There was a function called GetAsyncKeyState(int vKey)... that way you don't have to go thru all the Windows messages. You just call GetAsyncKeyState, and it'll tell you if vKey is pressed or unpressed.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-08-2010, 12:08 AM
  2. Open Source / Semi Open source game idea. Help needed
    By CaptainPatent in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 05-16-2007, 10:44 AM
  3. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 03:46 PM
  4. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM