🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How to produce FAST 2D hi-res scrolling engine ?

Started by
12 comments, last by Paladin 24 years, 7 months ago
Ummmmmm...I think it's pretty hard to fuck up a 2D side scroller with DirectX as the API, unless there are too many overlays and alpha blending. DOOM and Quake are 3D games, not "scrolling" games.

A side scrolling engine using DirectX on a Pentium 133 would acheive about 32 fps with a first generation video card.

Advertisement
Take a look at how many tiles you're blitting, how many layers you've got, and if you're alpha blending or not. Blit your base tiles with DX so you can get hardware acceleration. If you're not doing alpha, blit everything with DX.

Create an off screen surface that is two tiles taller and wider than your viewport. Blit the tiles into the off screen surface, then blit a sub section of that into your viewport. You could also create a blitter that clips and blit the tiles directly into your view port.

Hope this helps. There are lots of good articles in the programming section about tile based games. I've got a 32bit 640x480 tile engine that runs 150fps+ on a Pentium II.

Yes, there are, but mostly those are talking just about 320x200 resolution, AND if it's about 640x480, engine ISN'T made for "fast" use... I don't know why, but it seems to be that 640x480 "changes" scroller to strategy game or so...

So this engine that you made, was done with Direct-X API or not ?
It sounds pretty NICE
Just what I'm looking for...


30 fps in 640x480x16 isn't an unreasonable goal. But you're going ot have to work for it

You might want to look into the new Allegro extensions, which add hardware acceleration for some cards. I don't remember what it's called, but last I knew they had it implemented for some Matrox and ATI cards.

And keep in mind that you don't necessarily need 30 fps for this type of game. First Person games and Sidescroller games are two completely different animals.

OK.

Mostly the problem is that I don't know almost anything about optimizing programs. Actually I just saw pretty nice tutorial with something like 25 different ways to make small piece of blit() code better, but still I'm "newbie"

About assembly, are there any GOOD beginner tutorials for assembly ? I would like to know "basics" (if there is such a thing for assembly) ?

What do you mean that 30fps isn't reasonable for side scroller ? It needs to be smooth... In my opinion... STILL I'm wondering how the HELL did you manage to build same engine for 32bit WITH 640x480 ... and damn 120 fps

When I tried to build own engine, with 16bit, it was running with speed like 15fps with flickering car, and when it started to scroll, game dropped to under 10 frames.

So 32bit is actually two times more than 16bit... DARN, did you write whole thing with assembly ?

If you have any idea where to find this kind of "how to build FAST scroller" (for hi-res), I would like to know... Thats so freaking cool.. I mean 32bit 640x480 120fps


OK, here's the basic run down on what I did:

First, get your generic windows program running. Don't lock the game loop to any frame rate at all. I calculate a variable called DeltaTime which tells me how much time has passed since the last frame. Movement for objects is based on pixels per second / deltatime.

OK, on to the tile part. I'm using 64x64 tiles because I don't need lots of small items. Create a primary surface, attach a back buffer. Create BOTH in video memory! This is important. Load your tile bitmap in the video memory too. If your bitmaps don't fit in video memory, your blits won't be hardware accelerated and will be dog slow compared to ones in video memory.

With your tiles and back surface in video memory, blit your tiles onto the screen. Use a blit function that will clip them to your screen or viewport.

I've got a TNT card (not a TNT2) and everything runs great.

Hope this helps.

Marcus

Hmm... so we can get some hi-speeds with hi-resolution when we are using DX... How about software ? What kind of FPS could I get without hardware acceleration ? And how about OPENGL API ? (mostly I'm just interested because of Linux port).

I honestly don't know what kind of fps to expect without hardware acceleration. I'm fairly new to game programming and I don't have any OpenGL experience. If there is a graphics library for Linux that supports hardware acceleration (there should be one) then you'll be fine.

I've got a 2D vertical scroller, and in 16bit color, with DX, it does about 130fps (with all the music, colliosion detection, ....). When using the hardware, you can generally get pretty close results between the different color depths, so going to 32bit color isn't too much of a hit. However, there really isn't much chance of pulling off a 32bit software scroller, and I'd say that greater than 16bit color for 2D is way overkill. Those colors are for 3D shading.

Anyways, for my software version, I pull off almost 100FPS in 16bit mode. That's a fully tiled (only 1 level, no parallax) 640x480 scoller on a Mystique. It is a little tricky though (many optimizations, but no MMX yet), and if you don't know assembly it isn't likely you'll reach it. Also, for software drawing, the video card write speed is critical, so the FPS values can fluctuate quite a bit.

If you are fairly new, I'll just give you the age old advice of 'get something smaller and easier under your belt'. 2D scrollers are a good place to start, but to make it very fast requires some more experience.

Rock

Yes, I'm pretty "newbie", with about 1 1/2 year experience. I don't have experience with DX, but I'm trying to fix this at upcoming christmas (ah, my present; Lamothes new book .
I made this scroller engine already (allegro, djgpp), but I really didn't get enough speed out from it, and actually many people told that its not possible to get scroller with over 256 colors (hmm... I didn't believe this

Actually I'm not the head programmer of this project that I'm LEADING, but I have been trying to get some help, because we have been wondering so much about this big question: Are we going to need 3D-API to get this game fast enough ?

"My" programmer is working with Linux, and so he wouldn't like the idea that we use DX (he doesn't have windows next to linux), and I would like to have DX, so I have been just wondering that do we need API afterall, IF we can make scrolling fast enough with pure Allegro code (only software)... hmm... this has been pretty hard question. Actually if you people think that it's stupid to skip 3D-acceleration (mostly just for 2D purpose), let me know !

It's just that game will need two API's, DX and OPENGL (for Linux)... And how much is this extrawork ?


This topic is closed to new replies.

Advertisement