Sign in to follow this  
phil67rpg

breakout paddle

Recommended Posts

phil67rpg    443
I am using direct x and c++ to make a breakout game. I can get the paddle to move but it skips around a little bit. Here is the code I am using.
 
   if (KEY_DOWN(VK_LEFT))
	{			

		d3ddev->ColorFill(surface, NULL, D3DCOLOR_XRGB(255,255,255));
		//copy the surface to the backbuffer
        RECT rectw;
        rectw.left = m--;
        rectw.right = n--;
		rectw.top = 550;
        rectw.bottom = 600;

		d3ddev->StretchRect(surface, NULL, backbuffer, &rectw, D3DTEXF_NONE);

		d3ddev->ColorFill(surface, NULL, D3DCOLOR_XRGB(0,0,0));
		//copy the surface to the backbuffer
        RECT rectx;
        rectx.left = o--;
        rectx.right = p--;
		rectx.top = 550;
        rectx.bottom = 600;

		d3ddev->StretchRect(surface, NULL, backbuffer, &rectx, D3DTEXF_NONE);
	}	

    if (KEY_DOWN(VK_RIGHT))
	{			

		d3ddev->ColorFill(surface, NULL, D3DCOLOR_XRGB(0,0,0));
		//copy the surface to the backbuffer
        RECT recty;
        recty.left = m++;
        recty.right = n++;
		recty.top = 550;
        recty.bottom = 600;

		d3ddev->StretchRect(surface, NULL, backbuffer, &recty, D3DTEXF_NONE);

		d3ddev->ColorFill(surface, NULL, D3DCOLOR_XRGB(255,255,255));
		//copy the surface to the backbuffer
        RECT rectz;
        rectz.left = o++;
        rectz.right = p++;
		rectz.top = 550;
        rectz.bottom = 600;

		d3ddev->StretchRect(surface, NULL, backbuffer, &rectz, D3DTEXF_NONE);
	}

Share this post


Link to post
Share on other sites
jyk    2094
Hi phil67rpg,

When you post code, put it in source tags, like this:

[source]...code goes here...[/source]

That will put it in one of those nice little code boxes, which will make it much easier for people to read.

You can fix your current post using the 'edit' button in the upper right.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this