Results 1 to 10 of 10

Thread: How to "clear" in DirectDraw?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Great White North, ey?
    Posts
    202

    Unhappy How to "clear" in DirectDraw?

    I've always been blitting to the backbuffer but now I blitted a sprite to a background picture and moved the sprite around but of course got that trail that the sprites leaves behind. You would normally use the .cls method, but how can I do this in Direct Draw?

    Thanks

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    I had thought flipping did this... But I've forgotten. Try using bltcolorfill with a rect of the screen and the colour 0 (black).
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Great White North, ey?
    Posts
    202
    Rect of the screen? do you mean the background or the backbuffer?

  4. #4
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    You usually do a BltColorFill every frame on the whole screen or just the area that needs cleaned up.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Great White North, ey?
    Posts
    202

    Unhappy

    Hmm, I still can't get it to work. Here is my project, maybe someone can take a look please? The right and left keys move the background, the up and down keys move the sprite. So the sprites leaves it's trail and I would like to get rid of that. I know I can blit the sprite to the backbuffer but I don't want that because it won't move with the background.

    Thanks.
    Attached Files Attached Files

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Great White North, ey?
    Posts
    202
    *BUMP*

  7. #7
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    Whew! There's some pretty big problems there. Here's at least a partial fix. One tip - don't use a textbox for calculating framerate, use a variable. Another tip - use standard formatting for your code. It's very difficult to read as you have it.
    Attached Files Attached Files

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Great White North, ey?
    Posts
    202
    Thanks for the tips, but I think I didn't explain too clearly what I want. You know the part where it says:

    ddrval = backbuffer.BltFast(sx, sy, You, Ryou, DDBLTFAST_SRCCOLORKEY Or DDBLTFAST_WAIT)


    that's blitting the sprite to the "backbuffer", wheres I need it to be blitted to the "Background" like this:

    ddrval = Mainsurf.BltFast(sx, sy, You, Ryou, DDBLTFAST_SRCCOLORKEY Or DDBLTFAST_WAIT)

    because I need the sprite to be "attached" to the background to move with it and at the same time to be able to move up and down without leaving that trial behind. Any ideas? Hope this explains a bit better

    Sorry for asking so much.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Great White North, ey?
    Posts
    202
    Ok, here is the solution

    ddrval = Mainsurf.BltFast(sx+sx1, sy, You, Ryou, DDBLTFAST_SRCCOLORKEY Or DDBLTFAST_WAIT)

    I have to add the postion of the mainsurf otherwise the sprite is not where it should be.

  10. #10
    Addicted Member
    Join Date
    Aug 2002
    Location
    Baltimore, MD
    Posts
    230
    You should almost never blit to the primary surface, if that's what you're doing. I don't remember your code. You should keep track of the sprites position with variables and then blit it wherever it should be.

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