2d Engine

Started by
5 comments, last by GameDev.net 24 years, 6 months ago
Are you using DirectX (DirectDraw in particular)?

------------------

-Kentamanos

-Kentamanos
Advertisement
Using DirectDraw it is :

code:
DDBLTFX ddbltfx;ZeroMemory( &ddbltfx, sizeof(ddbltfx) );ddbltfx.dwSize = sizeof(ddbltfx);ddbltfx.dwFillColor = RGB(0,0,0);lpDDSBack->Blt(NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);

CU

------------------
Skullpture Entertainment
#40842461

Graphix Coding @Skullpture Entertainmenthttp://www.skullpture.de
Yes I'm using DD.

So will memcpy work?

Use the above code -- its faster then memset would be because it can be hardware accelerated.

--TheGoop

OK, thats working..Thanks everyone.

Next prob.

Scrolling. If I put a screen up thats say 640x480. Now I want to scroll infinte, whats the code for that. I know the idea how it works, but unsure of where to start.

It's like, move the screen down by say 3 lines. Those 3 lines print at the top..yes?

If so, how do I actually read the lines in and out?

Thankyou

Hi Everyone,

I'm making a 2d engine and come across my first problem. I want to clear the screen, how?

I'm trying to use as many fast commands as possible. I thought of using memcpy but I think it doesn't work, my computer just hangs.

In DOS I did "memcpy(VGA,0,64000);"
Is there a Windows version?

Thanks

The old wrap around technique when blitting in DOS (using memcpy) does not work in DirectDraw, instead, you have to blit the main area, then do two more blits to fill in the empty spaces above and to the side of the main blit, then you need to blit a forth surface to fill in the empty corner.

Also, make sure you clip the blits to the screen correctly, or your system may hang or get VERY slow, causing alot of INVALID_PARAM errors when using ->bltfast().

How ive done it..
I have made my own function called BlitFastClip() which automatically clips the blit to the screen no matter what co-ordinates I throw at it. This is very useful, as it eliminates excess calculations when bliting backgrounds and sprites.

Check out the FoxBear sample code in your DX3SDK package. It has the code to scroll backgrounds horizontally. All you have to do is modify the code so it will scroll vertical as well.

  Downloads:  ZeroOne Realm

This topic is closed to new replies.

Advertisement