Thread: BreakOut clone problem

  1. #1
    Registered User cMADsc's Avatar
    Join Date
    Jun 2002
    Posts
    18

    Unhappy BreakOut clone problem

    Greatings all, the problem with my BreakOut clone is that after the program starts running it tends to slow up then terminates. I am not sure why it does this. Well my game loop is not the best but that may be the first place to look at. In other advice is welcomed. Thanks in advance.
    There are those who say they can, and there are those who acutally do.

    ...you can not learn programming in a class, you have to learn it on your own

  2. #2
    monotonously living Dissata's Avatar
    Join Date
    Aug 2001
    Posts
    341
    #include #define ID_TIMER 999 #define GAME_INIT 0 //#define GAME_IDLE 1 #define GAME_START 1 #define GAME_RUN 2 #define GAME_SHUTDOWN 3 #define GAME_EXIT 4 int game_state = GAME_INIT; LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); void DrawBlocks(HWND hwnd, int num_rows, int num_cols, int block_x, int block_y); void DrawBall(HWND); void HitMan(HWND hwnd, int NUM_ROWS, int NUM_COLS); void DrawPaddle(HWND); void GameText(HWND); int Game_Main(HWND); int TOTAL_WIDTH = GetSystemMetrics(SM_CXFULLSCREEN); int TOTAL_HEIGHT = GetSystemMetrics(SM_CYFULLSCREEN); bool keys[256]; const int WIDTH = 600; const int HEIGHT = 500; /*int ball_left = 100; int ball_top = 400; int ball_right = 120; int ball_bottom = 420;*/ int ball_left = 0; int ball_top = 0; int ball_right = 0; int ball_bottom = 0; int cxClient, cyClient; int ball_movex= 1; int ball_movey= 1; int xPixel, yPixel; int paddle_left=0; int paddle_top = 0; int paddle_right = 0; int paddle_bottom = 0; struct tagBlock { int left_pt; int top_pt; int right_pt; int bottom_pt; bool life; } Block[5][5]; void Init_Block(int NUM_ROWS, int NUM_COLS, int x1, int y1) { int i,j; for(j =0; j < NUM_ROWS; j++) { for(i=0; i< NUM_COLS; i++) { Block[j][i].left_pt = x1; Block[j][i].top_pt = y1; Block[j][i].right_pt = x1 + 70; Block[j][i].bottom_pt = y1 + 20; Block[j][i].life = true; x1 +=90; } x1 = 40;//start back at the left y1 += 40;//start new column } } //================================================== ======================================== int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { TCHAR szAppName[]= TEXT("IconDemo"); HWND hwnd; MSG msg; WNDCLASS wc; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = szAppName; if(!RegisterClass(&wc)) { MessageBox(NULL, TEXT("Register Class error!"), szAppName, MB_ICONERROR); return 0; } hwnd = CreateWindow(szAppName, TEXT("icondemo"), WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, TOTAL_WIDTH /5, TOTAL_HEIGHT / 5, WIDTH , HEIGHT, NULL, NULL, hInstance, NULL); ShowWindow(hwnd, iCmdShow); UpdateWindow(hwnd); while(1) { if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if(msg.wParam == WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } else { Game_Main(hwnd); } } return msg.wParam; } LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { // HDC hdc; // PAINTSTRUCT ps; switch (message) { case WM_CREATE: SetTimer(hwnd, ID_TIMER, 100, NULL); ball_left = 100; ball_top = 400; ball_right = 110; ball_bottom = 410; paddle_left = 100; paddle_top = 430; paddle_right = 170; paddle_bottom = 450; // Init_Block(5, 5, 40, 60); // game_state =GAME_INIT; return 0; case WM_TIMER: InvalidateRect(hwnd, NULL ,TRUE); return 0; case WM_SIZE: cxClient = LOWORD(lParam); cyClient = HIWORD(lParam); return 0; case WM_KEYDOWN: keys[wParam] = TRUE; return 0; case WM_KEYUP: keys[wParam] = FALSE; return 0; /* case WM_PAINT: hdc =BeginPaint(hwnd, &ps); GameText(hwnd); DrawBall(hwnd); DrawBlocks(hwnd,5, 5, 40, 60); // DrawPaddle(hwnd); HitMan(hwnd, 5, 5); EndPaint(hwnd, &ps); return 0;*/ case WM_DESTROY: KillTimer(hwnd, ID_TIMER); PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, message, wParam, lParam); } void DrawBlocks(HWND hwnd,int num_rows, int num_cols, int block_x, int block_y) { HDC hdc; HBRUSH hBrush,old_brush; int i,j; int space =10;//horizontal space between each block hdc = GetDC(hwnd); hBrush = CreateSolidBrush(RGB(0,0,255)); old_brush = (HBRUSH) SelectObject(hdc, hBrush); /* //initialize the blocks position for(j =0; j< num_rows; j++) { for(i=0; i< num_cols; i++) { Block[j][i].left_pt = block_x; Block[j][i].top_pt = block_y; Block[j][i].right_pt = block_x+70; Block[j][i].bottom_pt = block_y +20; // Rectangle(hdc, block_x, block_y, block_x+70, block_y+20); block_x+=90;//add space between the blocks } block_x = 40;//start back at the left block_y += 40;//start new column } */ //draw the blocks for(j =0; j< num_rows; j++) { for(i=0; i< num_cols; i++) { //if the block has not been hit draw it if(Block[j][i].life == true) { Rectangle(hdc, Block[j][i].left_pt, Block[j][i].top_pt, Block[j][i].right_pt, Block[j][i].bottom_pt); } else continue; } } DeleteObject(SelectObject(hdc, old_brush)); ReleaseDC(hwnd, hdc); } //process the ball void DrawBall(HWND hwnd) { HDC hdc; HBRUSH hBrush, old_brush; hdc = GetDC(hwnd); hBrush = CreateSolidBrush(RGB(255,255,0));//create a yellow brush for the ball old_brush = (HBRUSH)SelectObject(hdc, hBrush);//select brush in the device context //draws a small yellow ellipse to look like a ball Ellipse(hdc, ball_left, ball_top, ball_right, ball_bottom); //if the ball hits the bototm or top reverse its direction if((ball_bottom > cyClient) || (ball_top < 0)) ball_movey *= -1; //if the ball hits the left or right border reverse the directions if((ball_right > cxClient) || (ball_left < 0)) ball_movex *= -1; ball_left += ball_movex;//moves the ball ball_right += ball_movex; ball_top += ball_movey; ball_bottom += ball_movey; DeleteObject(SelectObject(hdc, old_brush));//deletes yellow brush ReleaseDC(hwnd, hdc);//release hdc // InvalidateRect(hwnd, NULL, TRUE); } void DrawPaddle(HWND hwnd) { HBRUSH paddle, old_brush; HDC hdc; hdc = GetDC(hwnd); paddle = CreateSolidBrush(RGB(255,0, 0));//create a red brush for the paddle old_brush = (HBRUSH)SelectObject(hdc, paddle);//select the red brush for coloring //draw the paddle and color it red Rectangle(hdc, paddle_left, paddle_top, paddle_right, paddle_bottom); //delete the brush and restore the default value DeleteObject(SelectObject(hdc, old_brush)); } /*decide if a block was hit or not X increases to the right----> Y increase values increases going down | | V left_pt and top_pt =============== | O | =============== block bottom_pt and right_pt */ void HitMan(HWND hwnd, int NUM_ROWS, int NUM_COLS) { int i,j; HDC hdc; hdc = GetDC(hwnd); //go through each block and decide if it active, if so decide if it has been struct for(j=0; j< NUM_ROWS; j++) { for(i=0; i< NUM_COLS; i++) {//check to see if the four corners of the ball are less then the four //corners of the ball. if so make the block life false and reverse the balls direction if((Block[j][i].life == true) && (ball_left > Block[j][i].left_pt) && (ball_right < Block[j][i].right_pt) && (ball_top > Block[j][i].top_pt) && (ball_bottom < Block[j][i].bottom_pt)) { Block[j][i].life = false; ball_movey *= -1; ball_movex *= -1; } }//End of INNER FOR loop }// end of OUTER FOR loop }//end of HITMAN function void GameText(HWND hwnd) { HDC hdc; HPEN hPen, old_pen; static TCHAR szGame[]= TEXT("BreakOut"); int size = strlen(szGame); hdc = GetDC(hwnd); hPen = CreatePen(PS_SOLID, 1, RGB(255,255,0)); old_pen = (HPEN) SelectObject(hdc, hPen); SetTextColor(hdc, RGB(0,0,0)); SetBkColor(hdc, RGB(255,255,255)); TextOut(hdc,20, 450, szGame, size); DeleteObject(SelectObject(hdc, old_pen)); ReleaseDC(hwnd, hdc); } //game loop int Game_Main(HWND hwnd) { if(game_state == GAME_INIT) { //GameText(hwnd); game_state = GAME_START; //return 1; } else if(game_state == GAME_START) { Init_Block(5,5,40,60); game_state = GAME_RUN; // return 1; } else if(game_state == GAME_RUN) { DrawPaddle(hwnd); DrawBlocks(hwnd, 5,5,40,60); DrawBall(hwnd); HitMan(hwnd, 5,5); if(keys[VK_ESCAPE]) { game_state = GAME_EXIT; } // return 1; } else if (game_state == GAME_EXIT) return 0; // else // return 0; }
    you can't be serious??

    get some legible code and maby someone will help you

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Code:
    #include<windows.h>
    
    #define ID_TIMER 999 
    #define GAME_INIT 0
    //#define GAME_IDLE  1
    #define GAME_START 1
    #define GAME_RUN 2
    #define GAME_SHUTDOWN 3
    #define GAME_EXIT 4
    
    int game_state = GAME_INIT;
    
    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    void DrawBlocks(HWND hwnd, int num_rows, int num_cols, int block_x, int block_y);
    void DrawBall(HWND);
    void HitMan(HWND hwnd, int NUM_ROWS, int NUM_COLS);
    void DrawPaddle(HWND);
    void GameText(HWND);
    int Game_Main(HWND);
    
    
    int TOTAL_WIDTH = GetSystemMetrics(SM_CXFULLSCREEN);
    int TOTAL_HEIGHT = GetSystemMetrics(SM_CYFULLSCREEN);
    
    bool keys[256];
    const int WIDTH = 600;
    const int HEIGHT = 500;
    
    /*int ball_left = 100;
    int ball_top = 400;
    int ball_right = 120;
    int ball_bottom = 420;*/
    
    
    int ball_left = 0;
    int ball_top = 0;
    int ball_right = 0;
    int ball_bottom = 0;
    int cxClient, cyClient;
    
    int ball_movex= 1;
    int ball_movey= 1;
    int xPixel, yPixel;
    
    
    int paddle_left=0;
    int paddle_top = 0;
    int paddle_right = 0;
    int paddle_bottom = 0;
    
    
    struct tagBlock
    {
    	int left_pt;
    	int top_pt;
    	int right_pt;
    	int bottom_pt;
    	bool  life;
    } Block[5][5];
    
    void Init_Block(int NUM_ROWS, int NUM_COLS, int x1, int y1)
    {
    	int i,j;
    
    
    	for(j =0; j < NUM_ROWS; j++)
    	{
    		for(i=0; i< NUM_COLS; i++)
    		{
    			Block[j][i].left_pt = x1;
    			Block[j][i].top_pt = y1;
    			Block[j][i].right_pt = x1 + 70;
    			Block[j][i].bottom_pt = y1 + 20;
    			Block[j][i].life = true;
    			x1 +=90;
    		}
    				x1 = 40;//start back at the left
    				y1 += 40;//start new column
    	}
    
    }
    //==========================================================================================
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
    {
    	TCHAR szAppName[]= TEXT("IconDemo");
    	HWND	hwnd;
    	MSG		msg;
    	WNDCLASS wc;
    
    	wc.style			= CS_HREDRAW | CS_VREDRAW;
    	wc.lpfnWndProc		= WndProc;
    	wc.cbClsExtra		= 0;
    	wc.cbWndExtra		= 0;
    	wc.hInstance		= hInstance;
    	wc.hIcon		= LoadIcon(NULL, IDI_APPLICATION);
    	wc.hCursor		= LoadCursor(NULL, IDC_ARROW);
    	wc.hbrBackground	= (HBRUSH)GetStockObject(BLACK_BRUSH);
    	wc.lpszMenuName		= NULL;
    	wc.lpszClassName	= szAppName;
    
    	if(!RegisterClass(&wc))
    	{
    		MessageBox(NULL, TEXT("Register Class error!"), szAppName, MB_ICONERROR);
    		return 0;
    	}
    
    	hwnd = CreateWindow(szAppName, TEXT("icondemo"), WS_OVERLAPPED | WS_CAPTION |
    		WS_SYSMENU | WS_MINIMIZEBOX,
    		 TOTAL_WIDTH /5, TOTAL_HEIGHT / 5, WIDTH , HEIGHT,
    		NULL, NULL, hInstance, NULL);
    
    	ShowWindow(hwnd, iCmdShow);
    	UpdateWindow(hwnd);
    
    	while(1)
    	{
    		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
    		{
    			if(msg.wParam == WM_QUIT)
    				break;
    
    			TranslateMessage(&msg);
    			DispatchMessage(&msg);
    		}
    		else
    		{
    		
    		Game_Main(hwnd);
    	 
    		}
    	}
     
    
    	return msg.wParam;
    }
    
    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    //	HDC hdc;
    //	PAINTSTRUCT ps;
    	 
    
    	switch (message)
    	{
     
    
    	case WM_CREATE:
    		SetTimer(hwnd, ID_TIMER, 100, NULL);
    		ball_left = 100;
    		ball_top = 400;
    		ball_right = 110;
    		ball_bottom = 410;
    
    		paddle_left = 100;
    		paddle_top = 430;
    		paddle_right = 170;
    		paddle_bottom = 450;
    
    	//	Init_Block(5, 5, 40, 60);
    	//	game_state =GAME_INIT;
    		return 0;
    
    
    	case WM_TIMER:
    		InvalidateRect(hwnd, NULL ,TRUE);
    		return 0;
    
    	case WM_SIZE:
    		cxClient = LOWORD(lParam);
    		cyClient = HIWORD(lParam);
    		return 0;
    
    	case WM_KEYDOWN:
    		keys[wParam] = TRUE;
    		return 0;
    
    	case WM_KEYUP:
    		keys[wParam] = FALSE;
    		return 0;
    
    
    /*
    	case WM_PAINT:
    		hdc =BeginPaint(hwnd, &ps);
    		GameText(hwnd);
    		DrawBall(hwnd);
    		DrawBlocks(hwnd,5, 5, 40, 60);
    	//	DrawPaddle(hwnd);
    		HitMan(hwnd, 5, 5);
      		EndPaint(hwnd, &ps);
    			return 0;*/
    
    	case WM_DESTROY:
    		KillTimer(hwnd, ID_TIMER);
    	 	PostQuitMessage(0);
    		return 0;
    	}
    
    	return DefWindowProc(hwnd, message, wParam, lParam);
    }
     
    
    void DrawBlocks(HWND hwnd,int num_rows, int num_cols, int block_x, int block_y)
    {
    
    		HDC hdc;
    		HBRUSH hBrush,old_brush;
    		int i,j;
    		int space =10;//horizontal space between each block
    
    		hdc = GetDC(hwnd);
    		hBrush = CreateSolidBrush(RGB(0,0,255));
    
    		old_brush = (HBRUSH) SelectObject(hdc, hBrush);
    
    
    	/*	//initialize the blocks position
    		for(j =0; j< num_rows; j++)
    		{
    			for(i=0; i< num_cols; i++)
    			{
    				Block[j][i].left_pt = block_x;
    				Block[j][i].top_pt = block_y; 
    				Block[j][i].right_pt = block_x+70; 
    				Block[j][i].bottom_pt = block_y +20;
    
    			//	Rectangle(hdc, block_x, block_y, block_x+70,  block_y+20); 
    				block_x+=90;//add space between the blocks	
    			}
    				block_x = 40;//start back at the left
    				block_y += 40;//start new column
    		}
    
    	*/	
    
    
    		//draw the blocks
    		for(j =0; j< num_rows; j++)
    		{
    			for(i=0; i< num_cols; i++)
    			{   //if the block has not been hit draw it
    				if(Block[j][i].life == true)
    				{
    				Rectangle(hdc, Block[j][i].left_pt, Block[j][i].top_pt, Block[j][i].right_pt, Block[j][i].bottom_pt);
    				}
    				else
    
    					continue;
    				}
    			
    		}
    		
    		DeleteObject(SelectObject(hdc, old_brush));
    		ReleaseDC(hwnd, hdc);
    }
    
    //process the ball
    void DrawBall(HWND hwnd)
    {
    
    	HDC hdc;
    	HBRUSH hBrush, old_brush;
    
    
    	hdc = GetDC(hwnd);
    	hBrush = CreateSolidBrush(RGB(255,255,0));//create a yellow brush for the ball
    
    	old_brush = (HBRUSH)SelectObject(hdc, hBrush);//select brush in the device context
    
    	//draws a small yellow ellipse to look like  a ball
    	Ellipse(hdc, ball_left, ball_top, ball_right, ball_bottom);
    			//if the ball hits the bototm or top reverse its direction
    			if((ball_bottom > cyClient) || (ball_top < 0))
    			 ball_movey *= -1;
    			//if the ball hits the left or right border reverse the directions
    			 if((ball_right > cxClient) || (ball_left < 0))
    			 ball_movex *= -1;
    
    			ball_left += ball_movex;//moves the ball
    			ball_right += ball_movex;
    			ball_top += ball_movey;
    			ball_bottom += ball_movey;
    
    	DeleteObject(SelectObject(hdc, old_brush));//deletes yellow brush
    	ReleaseDC(hwnd, hdc);//release hdc
    //	InvalidateRect(hwnd, NULL, TRUE);
    
    }
    
    void DrawPaddle(HWND hwnd)
    {
    
    	HBRUSH paddle, old_brush;
    	HDC hdc;
    
    	hdc = GetDC(hwnd);
    	paddle = CreateSolidBrush(RGB(255,0, 0));//create a red brush for the paddle
    
    	old_brush = (HBRUSH)SelectObject(hdc, paddle);//select the red brush for coloring
    	//draw the paddle and color it red
    	Rectangle(hdc, paddle_left, paddle_top, paddle_right, paddle_bottom);
    	//delete the brush and restore the default value
    	DeleteObject(SelectObject(hdc, old_brush));
    
    
    }
    /*decide if a block was hit or not
    
    X increases to the right---->
    Y increase values increases going down
    |
    |
    V  left_pt and  top_pt
    		===============
    		|   O         |
    		===============
                       block bottom_pt and right_pt
    
      
    */  
    void HitMan(HWND hwnd, int NUM_ROWS, int NUM_COLS)
    {
    	int i,j;
    	HDC hdc;
    
    	hdc = GetDC(hwnd);
    
    	//go through each block and decide if it active, if so decide if it has been struct
    	for(j=0; j< NUM_ROWS; j++)
    	{
    		for(i=0; i< NUM_COLS; i++)
    		{//check to see if the four corners of the ball are less then the four
    		 //corners of the ball. if so make the block life false and reverse the balls direction
    		if((Block[j][i].life == true) && (ball_left > Block[j][i].left_pt) && (ball_right < Block[j][i].right_pt)
    		 && (ball_top > Block[j][i].top_pt) && (ball_bottom < Block[j][i].bottom_pt))
    			{
    				Block[j][i].life = false;
    				ball_movey *= -1;
    				ball_movex *= -1;
    			 
    			}
    	
    		}//End of INNER FOR loop
    
    	}// end of OUTER FOR loop
    }//end of HITMAN function
    
    
    void GameText(HWND hwnd)
    {
    	HDC hdc;
    	HPEN hPen, old_pen;
    	
    	static TCHAR szGame[]= TEXT("BreakOut");
    	int size = strlen(szGame);
    
    	hdc = GetDC(hwnd);
    	hPen = CreatePen(PS_SOLID, 1, RGB(255,255,0));
    	old_pen = (HPEN) SelectObject(hdc, hPen);
    	SetTextColor(hdc, RGB(0,0,0));
    	SetBkColor(hdc, RGB(255,255,255));
    	TextOut(hdc,20, 450, szGame, size);
    
    
    	DeleteObject(SelectObject(hdc, old_pen));
    
    	ReleaseDC(hwnd, hdc);
    
    
    }
    
    //game loop
    int Game_Main(HWND hwnd)
    {
    
    	if(game_state == GAME_INIT)
    	{
     
    		//GameText(hwnd);
    		game_state = GAME_START;
    		 //return 1;
    		 
    	}
    	else
    		if(game_state == GAME_START)
    		{
    			Init_Block(5,5,40,60);
    	 
    			game_state = GAME_RUN;
    			// return 1;
    		}
    
    	else
    		if(game_state == GAME_RUN)
    		{
    			DrawPaddle(hwnd);
    			DrawBlocks(hwnd, 5,5,40,60);
    			DrawBall(hwnd);
    			HitMan(hwnd, 5,5);
    
    
    				if(keys[VK_ESCAPE])
    				{
    					game_state = GAME_EXIT;
    				}
    				 
    				// return 1;
    		}
    	else
    		if (game_state == GAME_EXIT)
    			return 0;
    
    
    //	else
    	//	return 0;
    			
    }
    Nothing wrong here?

  4. #4
    Registered User cMADsc's Avatar
    Join Date
    Jun 2002
    Posts
    18
    Sorry about that, I forgot about how notepad acts. This new file is
    in a zip file and contains the .cpp file. Also, there are no compiler errors but there most be some type of runtime error somewhere to cause the game so slow up and terminate.
    Last edited by cMADsc; 01-20-2003 at 11:53 AM.
    There are those who say they can, and there are those who acutally do.

    ...you can not learn programming in a class, you have to learn it on your own

  5. #5
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753
    It is most likely a resource leak. I took a look at your code and noticed in your drawing functions you are not deleting all the resources you create. For example, instead of just using ReleaseDC() in your drawing functions, delete it. It's not your main DC so you delete it. Also, it's good that you are saving and deleting defaults that come in DC's and such, but you aren't deleting the other objects that you declare. For example:
    Code:
    void DrawBall(HWND hwnd, HDC hdc)
    {
    
    	hdc = GetDC(hwnd);
    	HBRUSH hBrush, old_brush;
    
    	hBrush = CreateSolidBrush(RGB(255,255,0));//create a yellow brush for the ball
    
    	old_brush = (HBRUSH)SelectObject(hdc, hBrush);//select brush in the device context
    
    	//draws a small yellow ellipse to look like  a ball
    	Ellipse(hdc, ball_left, ball_top, ball_right, ball_bottom);
    			//if the ball hits the bototm or top reverse its direction
    			if((ball_bottom > cyClient) || (ball_top < 0))
    			 ball_movey *= -1;
    			//if the ball hits the left or right border reverse the directions
    			 if((ball_right > cxClient) || (ball_left < 0))
    			 ball_movex *= -1;
    
    			ball_left += ball_movex;//moves the ball
    			ball_right += ball_movex;
    			ball_top += ball_movey;
    			ball_bottom += ball_movey;
    
    	DeleteObject(SelectObject(hdc, old_brush));//deletes yellow brush
                    DeleteObject(old_brush);
    	DeleteDC(hdc);//release hdc
    //	InvalidateRect(hwnd, NULL, TRUE);
    
    }
    fix your other functions to be like that and it might fix your problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. Breakout Collision Detection Algorithm Help
    By xmltorrent in forum Game Programming
    Replies: 8
    Last Post: 08-24-2006, 02:32 PM