[Pygame] Not suitable for full HD games?


M

molul

Guest
Hi all! I've arrived here looking for Pygame forums (I'm surprised there's not an official forum, and I don't quite like the mailing lists), and these boards look like a good place to stay :)


I'm currently developing a 2D platformer (well, actually I started it a lot of years ago with another language, but I got stuck and stopped developing, and now I've rebooted the project with Pygame), and I'd like it to be something like Sonic or some other great platformers from the 16-bit era, specially from Sega Genesis (Dynamite Headdy, Rocketknight Adventures, Ristar...) but in full HD.


Yesterday I finished the tiled background engine, and I've noticed a 15 fps drop in 1920x1080. And when I added a 5 planes parallax scroll, fps are going down to 10-20. I doubt it's the machine, as I play games like Starcraft in Ultra settings on it. Also, I'm noticing most games developed with Pygame are 640x480 or 800x600. So the question would be: is Pygame suitable for doing a full HD side-scrolling platformer?


My current approach is to render all scrolls planes and the tiled background to a single surface (the ".image" of my Stage class), instead of rendering each one in different planes. I haven't tried separating yet, but I doubt it will improve performance, as the blitting will be the same.


I've read the Surface.blit function is slow for some reason and shouldn't be overused, but I don't know another way of rendering images to the screen. I tried using flags "HWSURFACE | DOUBLEBUF | FULLSCREEN" and it increased 2-3 fps. Am I missing some other optimization or am I just using the wrong engine for an HD platformer?


Thanks a lot in advance :)
 
Hi and welcome :)


You can try adding RLE acceleration (SDL_SetColorKey) and don't forget to change your images format to the one from the display (SDL_DisplayFormat). Those helped me a lot speedwise in my c++ sdl game, but I'm not a pygame expert ;)
 
Hi Jones, thanks for answering. I'll investigate that, but I think the format thing is already done.


Actually I've noticed the problem was even worse: the tiled background image (a pygame.Surface) was created like this before filling it with tiles:


"self.image = pygame.Surface((RESOLUTION[0] + (3 * BGBLOCK_SIZE), RESOLUTION[0] + (3 * BGBLOCK_SIZE))).convert()"


Now I changed it to:


"self.image = pygame.Surface((RESOLUTION[0] + (3 * BGBLOCK_SIZE), RESOLUTION[0] + (3 * BGBLOCK_SIZE))).convert_alpha()"


Changing convert() to convert_alpha caused an fps drop os 50fps. Is this normal?
 
Hi molul! Because these are boards for the Pandora, we're not generally concerned about resolutions higher than 800x480 ;) . But let's see if we can help.

Changing convert() to convert_alpha caused an fps drop os 50fps. Is this normal?
SDL is notoriously slow at handling alpha transparency, so you should avoid it whenever you can. The "convert" method turns your surface into the same format as the display, so it can blit faster, while "convert_alpha" does the same thing while also handling alpha transparency, which slows it down. If you don't need alpha, there's no need to use convert_alpha.


Otherwise, I haven't enough experience to tell you if PyGame is fast enough for a full-HD sidescroller. To get good performance, you will definitely need to redraw only the areas that change; I recall one analysis where a person got less than 30FPS just by redrawing the whole screen each frame, not even including any game logic. You could ask the pygame-users mailing list for more help. And if you still can't pull it off, you might want to try a different drawing library; pyglet has some popularity, and kivy is new and cross-platform. Good luck!
 
I recall one analysis where a person got less than 30FPS just by redrawing the whole screen each frame, not even including any game logic.
What happens if you need to scroll the playing area?
 
Thanks Tempel. I've finally registered in Pygame's mailing lists and I'm getting some interesting hints (still nothing was fixed, but maybe there's a way). I've also started researching alternative like Lua's LÖVE2D, which I'm finding very interesting (really simple and powerful, and it is OpenGL based, not SDL). If I don't succeed with Pygame, at least I have another path to follow :)


By the way, my apologies, I thought this was a Pygame users forum :ph34r:


Anyway, thanks for your time.
 
Back
Top