Results 1 to 10 of 10

Thread: HighScore, getting the users name

Threaded View

  1. #1

    Thread Starter
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802

    HighScore, getting the users name

    I'm witing a highscore table for a game I'm making, and I've run in to a problem... Whenever I press a key the game quits... I get this error message: "First-chance exception in Game.exe: 0xC0000005: Access Violation." I have no idea what this means...
    Code:
    void HighScores()
    {
    	bool bHSRunning = true;
    	bool bDown = true;
    	bool bChanged = false;
    	char strTemp[2];
    	char strName[50];
    	char strABC[30]("abcdefghijklmnopqrstuvwxyzåäö");
    	char str123[11]("0123456789");
    	int iKey = 0;
    
    	SetTextColor(g_hdc, RGB(255, 0, 0));
    
    	while(bHSRunning)
    	{
    		if(GetAsyncKeyState(VK_ESCAPE))
    		{
    			bHSRunning = false;
    			CleanUpHighScores();
    			g_iMenuState = 4;
    		}
    		for(int i = 0; i < 95; i++)
    		{
    			if(!bDown)
    			{
    				if(HIWORD(GetAsyncKeyState(i)))
    				{
    					if(i >= 48 && i <= 57)
    					{
    						strncpy(strTemp, str123 + (i - 48), 1);
    						bChanged = true;
    						iKey = i;
    						bDown = true;
    						i = 256;
    					}
    					if(i >= 65 && i <= 90)
    					{
    						strncpy(strTemp, strABC + (i - 65), 1);
    						bChanged = true;
    						iKey = i;
    						bDown = true;
    						i = 256;
    					}
    					if(i == 8) //8 == BackSpace
    					{
    						chardel(strName, strlen(strName));
    						TextOut(g_hdc, 100, 100, strName, strlen(strName));
    						iKey = i;
    						bDown = true;
    						i = 256;
    					}
    				}
    			}
    			if(bDown)
    			{
    				if(!HIWORD(GetAsyncKeyState(iKey)))
    				{
    					bDown = false;
    				}
    			}
    		}
    		if(GetAsyncKeyState(VK_SHIFT) || GetAsyncKeyState(VK_LSHIFT) || GetAsyncKeyState(VK_RSHIFT))
    		{
    			strupr(strTemp);
    		}
    		if(bChanged)
    		{
    			strcat(strName, strTemp);
    			TextOut(g_hdc, 100, 100, strName, strlen(strName));
    			bChanged = false;
    		}
    	}
    }
    It's a win32 app written in vc++6.0
    Last edited by McCain; Dec 27th, 2002 at 08:03 PM.
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width