On Sat, Apr 21, 2012 at 2:55 PM, Xander Deseyn <[email protected]>wrote:

> Hello everybody,
>
> I'm learning Python and I am using Cocos2D to develop my first project
> in Python.
> It will be a top-down space shooter. I got a prototype up and running
> in less than a day but I have problems with my framerate.
> I have approximately 10-20 bullet sprites, 10 rock sprites and 1
> player sprite on the screen at any given time.
>

Thats 31 sprites max


> I made a ResourceManager class so that every image for my sprites is
> loaded into memory only once.
>

pyglet.resource does that for you, ie

sp1 = cocos.sprite.Sprite('grossini.png')
sp2 = cocos.sprite.Sprite('grossini.png')

would produce only one texture that will be used for both sprites.


> However, my framerate lies between 15-30, which is unacceptable for a
> game IMO.
>
> Is this normal? And if not, what can I do to improve?
>
>


 No, I don't think is normal. With num_sprites below 50 you should see at
least 60 fps even in old and weak hardware, even not using batches.

It is impossible to suggest something concrete without knowing what is
doing your code.

What you can do:

You can try to confirm the slowness with other gpu hardware (at some point
there were reports in pyglet that non power of two textures rendered very
slow in certain hardware)

You can upload somewhere a runnable snapshot of your app and
    a. ask for confirmation of the issue in other hardware
    b. ask for suggestions

( if your snapshot is a download - and - run zip most surely you will get
answers to a. , if it misses resources or something, thats more unlikely;
b. is more uncertain: the more long and sloppy the code, the less likely to
get responses)

You should try to identify the slowest parts in your code and upgrade those
or change design to not need the slow code.
Profiling, and visualizations for profiling data are your friends here.
cProfile is a profiling module included with Python
There are many visualizations for profile data, by example RunSnakeRun [0]

Also you can comment out different code parts to see if you can pinpoint
which are is the source of your problems

[0] http://www.vrplumber.com/programming/runsnakerun/


claudio

--

-- 
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cocos-discuss?hl=en.

Reply via email to