Scrolling Game

snarfblam

Ultimate Contributor
Joined
Jun 10, 2003
Messages
2,097
Location
USA
I am making a scrolling game that will have scrollable areas of up to 1920,1200 (or maybe 2560,1600) at 32 bpp. That comes out to 8.8 megs (or 15.7 megs).

If i were to pre-render the entire scrollable area and then blit the viewable area to the screen, would that 8.8 megs, or the 15.7 megs, be too much? (I want to avoid using system memory for my graphics.)

On my computer i have 128 megs graphic memory, so its not a problem on the developping end, but I dont know what the average joe has for graphic memory, so I don't know if that would be too much for the end user.
 
Yes, that's way too much unless you want your game to run at the resolution 1920x1200 (or 1600x1280 or similar large res's). I can't imagine you would...

Using a tiled approach, most tiled games are limited to either 800x600 or 1024x768 (that I've seen). Maybe you can buck the trend, but usually a 2D game is made for smaller hardware and that may mean a 32meg card max.

Kep in mind that you're going to need twice as much memory for the display with Double Buffering (pretty much a must) plus all the actual textures used for things that *aren't* the map (the player, objects, etc.).

Not to mention you may want to increase your map size one day (who knows?), and having an architecture that relies on a single bitmap/texture for the whole map would mess everything up.

Also, if you ever want to move up to Direct3D there is a limit on the size of a single texture. Many cards, even those that have 32, 64, or even 128 meg RAM will have a texture limit. Sometimes it's 2048x2048, but it's generally smaller, 512x512 is common.

-nerseus
 
I'm not planning on using this method, just considering.

The screen is 640x480, so the double buffering isnt going to take up much of the video memory at all, even if there are 32 megs, so the twice as much for display is a total of 2.5 megs for 32 bit color.

The reason I ask is because i'm having clipping issues and no one is offering any help, and there is essentially no documentation for managed directdraw, so this method would eliminate my clipping issues and make the programming easier.
 
Before I can help you with this you must tell me what kind of scroller it is. If it scrolls in all directions for example.

Next thing i need to know is what your graphics is like. If it's tiled, then how big are your tiles?

If you are using the tiled technic (wich i prefer, cus it's more fun), based on the resolution of 640x480 i would use tiles of size 64x32 (I think spontaniously :p) wich would give you a 20x15 tiled screen.

Also, you will need 2 backbuffers. One is the real backbuffer wich you use to prevent flickering. But the other one is a mapbuffer. This is the background of your scene. Since i guess you will have characters running around in your game, you better separate the backbuffer from the background since you don't wan't to recalculate the map each frame (huge performance loss).

What you do instead is that each time your screen is scrolling into an area wich is not yet calculated, is that you actually scrolls the mapbuffer a whole tile, reset the offset to to the center of your mapbuffer, add an extra row of tiles on the edge where you just scrolled in, and start all over again.

This gives you a backbuffer sized the screen buffer and a mapbuffer sized 704x512 pixels with 22x17 tiles.

I'm a bit tired now so excuse me if I wasn't clear enough, but if you need help just send me a mail and I'll do my best to help you with a technic that suits your game best.

/Frasse
 
I am using 40x40 tiles, and right now, im redrawing the entire level every frame without a problem (not that that is my final decision or solution).
 
Depending on the amount of detail you want, 32x32 or 16x16 tiles are usually ideal. There's also of course polygons or triangles which you can use for tiling, but that requires a bit of math.
 
The reason I ask is because i'm having clipping issues and no one is offering any help, and there is essentially no documentation for managed directdraw, so this method would eliminate my clipping issues and make the programming easier.

You're using DirectDraw right?

Check out this code for clipping, it worked for me (I didn't write it):

.....................................................................................................


Public Sub DDBltFast(surface As DirectDrawSurface7, RECTvar As RECT, x As Integer, y As Integer, Optional transparent As Boolean = True, Optional Clip As Boolean = True)
'This subroutine will BltFast a surface to the
'backbuffer. This wont work with clipper.

'CLIPPING
'Temporary rect
Dim rectTemp As RECT
rectTemp = RECTvar

If Clip = True Then
'Set up screen rect for clipping
Dim ScreenRect As RECT
With ScreenRect
.Top = y
.Left = x
.Bottom = y + (RECTvar.Bottom - RECTvar.Top)
.Right = x + (RECTvar.Right - RECTvar.Left)
End With
'Clip surface
With ScreenRect
If .Bottom > cWindowHeight Then
rectTemp.Bottom = rectTemp.Bottom - (.Bottom - cWindowHeight)
.Bottom = cWindowHeight
End If
If .Left < 0 Then
rectTemp.Left = rectTemp.Left - .Left
.Left = 0
x = 0
End If
If .Right > cWindowWidth Then
rectTemp.Right = rectTemp.Right - (.Right - cWindowWidth)
.Right = cWindowWidth
End If
If .Top < 0 Then
rectTemp.Top = rectTemp.Top - .Top
.Top = 0
y = 0
End If
End With

End If

If transparent = False Then
Call ddsBack.BltFast(x, y, surface, rectTemp, DDBLTFAST_WAIT)
Else
Call ddsBack.BltFast(x, y, surface, rectTemp, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
End Sub

.....................................................................................................
 
normally i would use tiles that are 2^x,2^x big, but for this game 40x40 is ideal, and using 32x32 or 16x16 would offer no advantage.

Also, I had made my own clipping routine, but i didnt want to use it because it would eat up more cpu power than letting directdraw do it for me. And you also posted vb6 code for unmanaged directdraw. That doesn't do me any good.

I figured out my clipping problem. The tutorial I followed set a clipper for the primary buffer, but not the backbuffer. For some reason i suppose that i assumed that they shared the clipper, and the thought that i would need to set one to the backbuffer never occured to me.

And to answer my own question: no, you can not use drawfast with clipping.
 
yea... um kinda sloppy with that.. thought maybee someone out there could use that clipping function. Well, I'm glad that you fixed your problem :)
 
Back
Top