Hi Lochok,

Welcome to the site, I've had a brief look at your code. I can't run it at the moment as I'm at work. But it looks like your rendering algorithm is quite wasteful.

If I'm reading it correctly,

You create a seperate layer object for each layer in your map. So if you have 3 layers, each frame you're software blitting (800x600x3)x3, that's not even including any tile rendering. On top of this, you have the overhead of rendering the tiles to each layer.

There are things you can do to speed this up.

You are doubling up your work. You don't need to do this. Remember, anything you render using software has to travel down the AGP bus and it's got a limited bandwidth. Send as little as possible and you'll see your render speed increase.

1, do not render to layer surfaces. Treat your layers as logical entities instead of physical entities. Blit your tiles directly to the main screen surface. Put this in a loop to render the lowest layer + any sprites, then the next lowest and so on.. this will give you exactly the same effect as your layer routine but without the massive overhead of re-blitting the entire thing via the layer surface.

2. You're using 24bit, consider 16bit or 32. I've had performance problems with 24 bit and for some odd reason, 24bit was slower than 32 bit. 16 bit should be twice as fast as 32 bit because you're only sending half the amount of information. I'd really only use 32bit colour if I was using Hardware using OpenGL.

3. You're doing 2 flips at the end of your loop. You really only need one.

You're also only rendering when the player moves. Is this what you really want? This will mean that you won't be able to have any ambient animation.

Apart from the things I've mentioned, I can't see immediately what's causing such a long delay.

I'll run it tonight when I get home.