Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Speed issue with gosu
- By di3go Date 2009-07-26 19:53
Anyone get issue speed with gosu and ruby drawing more than 1000 simples objects on screen?

Its just a image, 100x100 px, that i draw 1000 times on screen

Im using Ubuntu with Atlhon X2 3ghz, when i open the System Monitor, one cpu its 100% loaded with gosu and the fps is about 45/50

This issue was not in my game, was just a performance test that i maked, but, in the game im making, im not gonna have all this objects on screen all the time, but some times i could have this value or even more

Have any way to improve performance?

Maybe change ruby 1.8 to 1.9, gosu internally use threads? opengl to render? format my computer, hehe?

Thanks!
- By benko Date 2009-07-26 20:23
Do you really think that rendering 1000 sprites and getting 50 fps is an "issue"? O__o

Anyway, Ruby 1.9 is much faster than Ruby 1.8, you could try and see how many fps you get...
- By jlnr (dev) Date 2009-07-26 20:45
Ruby 1.8 to 1.9 will bring the performance up by a good factor usually, but it mostly affect your Ruby code, not the actual Gosu rendering.

There are two general ways around these sort of scaling problems. The first one is to use a good data structure, for example by organizing the objects into several sectors and only drawing and updating the currently visible ones. Or generally, preferring a 2D tilemap over a loose set of objects for the map, things like that. At the same time, you should still not use a complicated set of classes, prefer Fixnums over Floats etc., to keep the Ruby code simple. Sorry if all that is obvious :)

The other way is to avoid having so many individual objects on the Ruby side in general, and instead grouping things by any means possible (which keeps the Garbage Collector runs short too). One example would be ippa's game "A Tiny World", where he used TexPlay to add blood stains to the leg by using TexPlay instead of redrawing them every frame. Maybe you can prerender parts of the map on the development machine using RMagick. And if a lot of objects don't move relative to each other, functionality is in development that will allow you to 'record' a lot of drawing operations into a new Gosu::Image that will then draw all the original images, except much faster.

Both methods strongly depend on the way the game works, but I hope this helps.
Up Topic Gosu / Gosu Exchange / Speed issue with gosu

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill