bitmap come down

Started by
18 comments, last by Evil Steve 15 years, 5 months ago
Hello guys, I started to learn DirectX. I understand now the function "display" and the function with that sound handling. But i want know, that a bitmap come down from the top to the ground pixel for pixel. How can i make that? So far... alien ;D
Advertisement
Like have it move a line, pause, then move again, or just have it slide? Either way you need to have something that pauses for a certain length of time, changes the Y coordinate of the bitmap, then redraw with the new Y value.
I want that it slides over the window. But when i make it with a "for" or "while" loop, it doesn't work. It didnt show me then the picture sliding.
you need to change the Y coordinate that you are drawing the bitmap at each time you call render. so this means clear the screen and redraw the bitmap. some code would be helpful like post your for or while loop.
i just made it like this...


for(int i = 0; i < 100; i++)
{
weep_display.abdeckung(i);

}


try and do something similar to weep_display.y(i); not really sure how its done in xna if you are using that
no, im using directX...

when i make it with my for loop, it doenst come slow down. Its just a big distorted image on the screen.
Quote:Original post by alieniZe
no, im using directX...

when i make it with my for loop, it doenst come slow down. Its just a big distorted image on the screen.
Because you're not rendering it - just moving it. Your code does this:
  • Move the bitmap 100 times.
  • Draw it.

    You want:
  • Move the bitmap 1 line
  • Draw it
  • Move the bitmap another line
  • Draw it
  • Etc

    That means you need to do a whole render loop (Clear, BeginScene, render, EndScene, Present) each time you move your bitmap.
  • thanks a lot, i understand my problem now, but i dont know how i can fix it ;/

    U told me a way, but i cant make it to a code :/

    mfg alien

    Well, it depends on how the code from your book is structured. Typically you'll have some kind of render loop which will call some main draw and/or update method X times per second. In this method you'd typically increase a variable y coordinate and then use dsply.Blt(someX, yourY, yourSprite); to draw it to the screen at the new position.

    Going from your last topic I don't know if this is the case with your code, so it'll probably only get confusing to try and explain the general approach further. Looking at the book index you posted last time, you might want to check out paragraph 3.2 (page 138-159), since that seems to deal with movements.

    This way you know the info correctly applies to the code you're using, which should prove more useful than our random guesses as to how your code works [smile]
    Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!

    This topic is closed to new replies.

    Advertisement