So I wrote my first SDL game (don't ask why I'm still using SDL, it's a programmer's thing), and everything looks good, except...
The lag happens when the background images are blitted. When I reach an area where the background is white and no images are blitted, everything looks smooth. Each image is loaded into a SDL_Surface (once), and blitted every 1 ms inside my draw() loop. The images are jpeg format.
To give you a better picture, this is the regular game scene and this is also where I'm laggy as I move around:
And this is the end of the scene, where the lag magically disappears:
As I walk back into the regular game scene, the game starts to get laggy again!
So, my question in a nutshell: How to make the game more efficient so that it doesn't lag out? (e.g does using bmp images have an effect? Should I not blit them every time in the loop?
Also, if you MUST see the code, here it is: http://pastebin.com/0tK4EWeP