Jump to content
  • Advertisement
phil67rpg

C++ win 32 pong

Recommended Posts

Advertisement
23 minutes ago, GoliathForge said:

What I was hoping for was your current over all source to see where you really are with this so far. 

He said he solved his problem. What's with this 'where you really are with this so far' business?

Share this post


Link to post
Share on other sites
Posted (edited)

I am trying to draw two different sprites. it is only drawing one type of sprite. sorry but I solved my problem.

void DrawBitmap(char *filename, int x, int y)
{
    //load the bitmap image
    HBITMAP image = (HBITMAP)LoadImage(0,"paddle.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
    HBITMAP image_one = (HBITMAP)LoadImage(0,"red.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);

    //read the bitmap's properties
    BITMAP bm;
    BITMAP bm_one;
    GetObject(image, sizeof(BITMAP), &bm);
    GetObject(image_one, sizeof(BITMAP), &bm_one);

    //create a device context for the bitmap
    HDC hdcImage = CreateCompatibleDC(device);
    HDC hdcImage_one = CreateCompatibleDC(device);
    SelectObject(hdcImage, image);
    SelectObject(hdcImage_one, image_one);

    //draw the bitmap to the window (bit block transfer)
    BitBlt( 
        device,                  //destination device context
        x, y,                    //x,y location on destination
        bm.bmWidth, bm.bmHeight, //width,height of source bitmap
        hdcImage,                  //source bitmap device context
        0, 0,                    //start x,y on source bitmap
        SRCCOPY);                //blit method
    BitBlt( 
        device,                  //destination device context
        x, y,                    //x,y location on destination
        bm_one.bmWidth, bm_one.bmHeight, //width,height of source bitmap
        hdcImage_one,                  //source bitmap device context
        0, 0,                    //start x,y on source bitmap
        SRCCOPY);                //blit method

    //delete the device context and bitmap
    DeleteDC(hdcImage);
    DeleteDC(hdcImage_one);
    DeleteObject((HBITMAP)image);
    DeleteObject((HBITMAP)image_one);
}

 

Edited by phil67rpg

Share this post


Link to post
Share on other sites
Posted (edited)
55 minutes ago, GoliathForge said:

"Usually somewhere in the bottom of main" <-- LOL

I have to ask what is so laugh out loud about that?

And if you're quoting me, I said...

On 7/2/2019 at 6:24 PM, fleabay said:

For simple games in C++ it is near the bottom of main()

 

Edited by fleabay

Share this post


Link to post
Share on other sites
2 hours ago, fleabay said:

He said he solved his problem. What's with this 'where you really are with this so far' business?

As an aside, in his entire 10+ year history of trolling this site, Phil has never once actually really solved his problem when he says he has.

Share this post


Link to post
Share on other sites
Posted (edited)

I can see why now on SO they are so picky about duplicates and unnecessary posts, maybe Phil is going to bring that movement to these forums. He went from making Pong to making Breakout because he found code in a boo k that would make everything `just work`, and no ones advice even made its way into his code block :)

Edited by Daniel Ricci

Share this post


Link to post
Share on other sites

Can a moderator close this post, the initial question of "I am working on a pong game  using windows and c++ I am trying to get the computer paddle to move  up and  down by itself, here is my movement code" is no longer what is being asked about.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!