Can someone please look at my little attachment and perhaps mabye tell me why the background doesn't move, yet my sprite moves. It is very small code, it is actully slightly modified from DirectX4VB site tutorial. Thanks.
I'm assuming you're trying to move the background to the left when you press the left arrow key. If so, the problem lies in the fact that you're trying to blit offscreen. Add the following to your blt function:
'Add this above the two lines where you set rBack
rBack.Left = Abs(sx1)
'or make this change in your Init function
If GetKeyState(vbKeyLeft) < -5 Then sx1 = sx1 + 1 'background
'and add this above the two lines where you set rBack
rBack.Left = sx1
'Change your first BltFast to this:
ddrval = backbuffer.BltFast(0, 0, Mainsurf, rBack, DDBLTFAST_WAIT)
If this isn't what you're trying to do let me know.
Hey, that is almost what I want, the sliding part is excellent, but the background seems to get cut off to fit to screen, I actually need it to be intact and blited of screen, so I can slide it in and out of view. Sorry I didn't make myself clear in the previous post. Thanks a lot, I really appreciate your help!
NEVER MIND!!! I GOT IT TO WORK! YES, FULLSCREEN, DIRECTDRAW, SINGLE PICTURE SCROLLING ENGINE! HAHAHHAHA, YES!!!!!!!!!!!!!!!!!!!!!!!
Ok it was just a matter of changing a few lines to this:
rBack.Left = 0 - sx1
rBack.Right = 800 - sx1
rBack.Top = 0 - sy1
rBack.Bottom = 600 - sy1
Now my world scrolls up, down, left, right. All at over 120FPS! Thank you, Thank you Mircrosoft for developing the almighty DIRECTX! And thank you Machaira for getting me of to a good start.