Sign in to follow this  

Python + Pygame = slow game?

This topic is 3323 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! We are making 2D side-scroller platform adventure action game with elements of RPG. Problem is that even in this starting stages game is really slow. Right now it have 25 fps and in full screen with hardware acceleration turned on it have 35 fps. We use convert while loading sprites, and we are not bliting objects that are not in current screen. Right now there is around 5 monsters that are on screen and around 20 tiles. Problem is that this should be fast paced side-scroller and in future there will be a lot of monsters,pyshics,special effects etc. We tryed dirty draw technique which helps, but we need camera to move quickly so it's no use... Is it even possible to make game like this with Pygame? What would you suggest ,should we use some other library then Pygame? How good is PyGlet? And how big changes we need to do in code to implement it? Thanks in advance! p.s. we are testing it on this configuration (laptop) : Pentium M 1.7GHz,2GB RAM and some integrated graphic card.

Share this post


Link to post
Share on other sites
Well, for starters your not exactly running on a very high end system. integrated graphics in particular is going to slow you down a lot, specially if you don't have a strong processor or running it at full power (integrated graphics actually runs the graphics through the processor, using local ram for storage). be especially leary of using large textures, which are stored in the ram in your case. I would say go ahead and start running tests with a bunch more enemys. profile various pieces of code and see where your bottlenecks are. Python is no where near as fast as say C++, .NET, or JAVA, but it should still be enough for most things.

Share this post


Link to post
Share on other sites
Quote:
Original post by rip-off
Are you using alpha blending?


We are using alpha blending while loading sprites. Did u mean on that? Can you explain how could that help and for what alpha blending can be used? thx

Share this post


Link to post
Share on other sites
Quote:
Original post by PaulCesar
(integrated graphics actually runs the graphics through the processor, using local ram for storage).
Although integrated cards do share RAM with the cpu, many of the recent models (the Intel GMA 4500, for instance) have their own processor(s) for hardware transform, lighting and even shaders.
Quote:
Python is no where near as fast as say C++, .NET, or JAVA, but it should still be enough for most things.
Pygame implements almost all of the 'heavy' processing tasks (such as blitting surfaces) in C, so there shouldn't be a drastic difference between python and C programs using pygame - unless of course you are doing some other heavy processing task directly in python.

Share this post


Link to post
Share on other sites
It depends on what you mean by "hardware acceleration". AFAIK pygame is a nice wrapper over SDL. This means that it could be using SDL's 2D rendering system, or OpenGL.

If the latter, then using alpha blending is not a problem. If the former, you need to be very careful when you use alpha blending. Doing blending during loading should be fine - as long as the final surface hasn't an alpha channel.

However, if any of your live blits are alpha-blended, this will be performed in software. SDL does not support hardware alpha blending. This incurs an additional penalty: surfaces stored in video memory have to be fetched back into system memory for blending to work.

In any case, using OpenGL will probably be faster than using SDL's 2D rendering system. My understanding is that Pyglet uses OpenGL. Pygame may or may not be able to use OpenGL, I've never used it.

Share this post


Link to post
Share on other sites
Quote:
Original post by rip-off
In any case, using OpenGL will probably be faster than using SDL's 2D rendering system. My understanding is that Pyglet uses OpenGL. Pygame may or may not be able to use OpenGL, I've never used it.
Pygame is pretty much a straight wrapper of SDL, and as such, you can use OpenGL. IMHO, however, pyglet is a far superior way to access OpenGL from python.

Share this post


Link to post
Share on other sites
You really need to profile to determine the slowest parts of your code. Right now it's all guesswork what's causing the slowdown.

There is the free CodeAnalyst profiler for AMD chips, which will also work to some degree for Intel machines, give it a try.

Good Luck!

-ddn

Share this post


Link to post
Share on other sites
Hi,

- check to see if your background images have no alpha channel. Blitting alpha channel images is slower.
- profile.
- learn from other side scrolling games.
- 30 fps is enough.
- consider using a lower bit depth for some images if your graphics suit it. eg, 16bit images can look fine for some things (like if there is less than 65536 colors)
- consider using a smaller screen resolution.

Try learning from other side scrolling games which get decent speed:
http://www.pygame.org/project/406/


I know from experience that you can make scrolling games fast enough with pygame.

Have you done any profiling?
http://www.pygame.org/wiki/Profiling?parent=CookBook

With profiling you can see the slow parts of your code and likely speed up those parts.


Note, that you can have a fun game running at 30fps. It's mostly about keeping a consistent frame rate -- rather than keeping a massive one.


If your game is open source, post a link to it to the pygame mailing list, and people will most likely help you speed it up. If not, ask anyway :)



cheers,

Share this post


Link to post
Share on other sites
ok..thanks everyone for help till now..

here is profiling of our code...can someone tell me where are critic sectors (bottle necks)...and what sectors takes more time then they should (and on what time we should try to set it)...thanks in advance!!!!
p.s. sorry for big post but i dont know how to use spoilers in this forum (if even is possible)


 
490578 function calls (490463 primitive calls) in 28.605 CPU seconds

Ordered by: standard name

ncalls tottime percall cumtime percall filename:lineno(function)
919 0.006 0.000 0.006 0.000 :0(append)
35606 2.693 0.000 2.693 0.000 :0(blit)
3305 0.014 0.000 0.014 0.000 :0(clock)
1 0.000 0.000 0.000 0.000 :0(close)
2473 0.015 0.000 0.015 0.000 :0(colliderect)
115 0.021 0.000 0.022 0.000 :0(eval)
5628 4.880 0.001 4.880 0.001 :0(fill)
820 5.531 0.007 5.531 0.007 :0(flip)
804 0.017 0.000 0.017 0.000 :0(get)
804 0.004 0.000 0.004 0.000 :0(get_focused)
804 0.004 0.000 0.004 0.000 :0(get_fps)
7287 0.035 0.000 0.035 0.000 :0(get_height)
34774 0.400 0.000 0.400 0.000 :0(get_pressed)
1647 0.009 0.000 0.009 0.000 :0(get_ticks)
7287 0.042 0.000 0.042 0.000 :0(get_width)
5 0.000 0.000 0.000 0.000 :0(index)
5 0.000 0.000 0.000 0.000 :0(play)
117 0.002 0.000 0.002 0.000 :0(pop)
16985 0.472 0.000 0.472 0.000 :0(pump)
3 0.000 0.000 0.000 0.000 :0(random)
804 0.011 0.000 0.011 0.000 :0(range)
8844 0.733 0.000 0.733 0.000 :0(remove)
804 0.081 0.000 0.081 0.000 :0(render)
855 0.074 0.000 0.074 0.000 :0(rotate)
115 0.001 0.000 0.001 0.000 :0(set_alpha)
1 0.020 0.020 0.020 0.020 :0(setprofile)
51 0.008 0.000 0.008 0.000 :0(smoothscale)
16985 0.578 0.000 0.578 0.000 :0(sum)
804 1.036 0.001 1.036 0.001 :0(tick)
116/1 0.000 0.000 28.585 28.585 <string>:1(<module>)
804 0.042 0.000 0.093 0.000 GFX_OSD.py:76(DrawHealthBar)
804 0.006 0.000 0.006 0.000 GFX_OSD.py:93(WeaponChangeRender)
1 0.000 0.000 0.000 0.000 GFX_Status.py:127(AddFX_Stars_Red)
1 0.000 0.000 0.000 0.000 GFX_Status.py:151(AddFX_CoinPickup)
804 0.008 0.000 0.008 0.000 GFX_Status.py:158(ReproduceFX_GenericBurst)
804 0.007 0.000 0.007 0.000 GFX_Status.py:181(ReproduceFX_GenericBurst2)
804 0.007 0.000 0.007 0.000 GFX_Status.py:204(ReproduceFX_GenericBurst_Red)
804 0.007 0.000 0.007 0.000 GFX_Status.py:227(ReproduceFX_GenericTrail)
804 0.007 0.000 0.007 0.000 GFX_Status.py:250(ReproduceFX_GenericTrail2)
804 0.008 0.000 0.008 0.000 GFX_Status.py:282(ReproduceFX_Shadow)
804 0.018 0.000 0.056 0.000 GFX_Status.py:305(ReproduceFX_Stars_Red)
804 0.008 0.000 0.008 0.000 GFX_Status.py:326(ReproduceFX_Stars_Blue)
804 0.007 0.000 0.007 0.000 GFX_Status.py:347(ReproduceFX_Stars_Yellow)
804 0.008 0.000 0.008 0.000 GFX_Status.py:368(ReproduceFX_Stars_White)
804 0.007 0.000 0.007 0.000 GFX_Status.py:389(ReproduceFX_Stars_Purple)
804 0.007 0.000 0.007 0.000 GFX_Status.py:410(ReproduceFX_Stars_Black)
804 0.010 0.000 0.025 0.000 GFX_Status.py:431(ReproduceFX_CoinPickup)
2 0.000 0.000 0.001 0.000 GFX_Status.py:456(AddFX)
804 0.004 0.000 0.004 0.000 GFX_Status.py:87(RenderAPnotifier)

9648 0.099 0.000 0.099 0.000 TriangleSolid.py:121(collision_with_rect)
804 0.004 0.000 0.004 0.000 buzz.py:138(rotateFrame)
804 0.023 0.000 0.346 0.000 buzz.py:143(move)
45 0.005 0.000 0.007 0.000 buzz.py:176(Jump)
9 0.000 0.000 0.002 0.000 buzz.py:190(startJump)
804 0.017 0.000 0.024 0.000 buzz.py:200(handleJump)
242 0.007 0.000 0.010 0.000 buzz.py:272(WalkRight_notBouncing)
449 0.014 0.000 0.020 0.000 buzz.py:288(WalkLeft_notBouncing)
112 0.003 0.000 0.004 0.000 buzz.py:305(Jetpack_NotUsed)
804 0.054 0.000 0.181 0.000 buzz.py:72(draw)
804 0.005 0.000 0.005 0.000 camera.py:11(set)
1608 0.015 0.000 0.021 0.000 debug.py:25(Start)
1608 0.041 0.000 0.049 0.000 debug.py:31(Stop)
804 0.023 0.000 6.410 0.008 debug.py:81(TestFunc)
945 0.004 0.000 0.004 0.000 default.py:47(collide)
804 0.007 0.000 0.007 0.000 dimwit.py:30(think)
155 0.001 0.000 0.001 0.000 dimwit.py:53(enemyToBuzz)
385 0.004 0.000 0.005 0.000 dimwit.py:69(collide)
804 0.006 0.000 0.006 0.000 event.py:38(update)
804 0.027 0.000 1.098 0.001 game.py:169(limitFramerate)
804 0.207 0.000 5.964 0.007 game.py:181(checkInput)
804 0.025 0.000 0.043 0.000 game.py:266(checkForConsole)
804 0.096 0.000 6.352 0.008 game.py:293(update)
1 0.000 0.000 0.000 0.000 game.py:315(exit)
71 0.001 0.000 0.001 0.000 game.py:323(CheckEvent)
804 0.080 0.000 28.544 0.036 game.py:66(loop)
804 0.370 0.000 14.980 0.019 game.py:90(draw)
804 0.023 0.000 0.033 0.000 germ.py:27(think)
164 0.001 0.000 0.001 0.000 germ.py:45(enemyToBuzz)
16985 3.555 0.000 4.222 0.000 input.py:296(MapMatch)
16985 0.685 0.000 5.672 0.000 input.py:65(KeyDown)
804 0.291 0.000 6.158 0.008 level.py:111(update)
804 0.380 0.000 8.646 0.011 level.py:82(draw)
1 0.023 0.023 28.585 28.585 main.py:31(main)
804 0.024 0.000 0.035 0.000 makochi_green.py:30(think)
804 0.014 0.000 0.071 0.000 makochi_green.py:40(draw)
804 0.021 0.000 0.269 0.000 makochi_green.py:48(move)
804 0.004 0.000 0.004 0.000 makochi_green.py:67(startJump)
328 0.001 0.000 0.001 0.000 makochi_green.py:71(enemyToBuzz)
804 0.010 0.000 0.015 0.000 makochi_green.py:77(handleJump)
1608 0.007 0.000 0.007 0.000 menu.py:20(isActive)
804 0.003 0.000 0.003 0.000 menu.py:35(update)
8844 0.118 0.000 1.001 0.000 npc.py:40(draw)
8844 0.177 0.000 3.368 0.000 npc.py:43(update)
2193 0.021 0.000 0.028 0.000 npc.py:54(enemyToBuzz)
4428 0.065 0.000 0.165 0.000 npc.py:67(collide)
8844 0.565 0.000 1.384 0.000 npc.py:73(checkForCollisions)
125424 1.146 0.000 1.146 0.000 object.py:26(collision_with_rect)
804 0.065 0.000 0.080 0.000 pickup.py:38(ItemCollectCheck)
2472 0.035 0.000 0.035 0.000 pickup.py:51(isVisible)
804 0.058 0.000 0.201 0.000 pickup.py:56(DrawItems)
804 0.038 0.000 0.452 0.001 player.py:325(update)
2 0.000 0.000 0.000 0.000 player.py:383(SetHP)
1610 0.010 0.000 0.010 0.000 player.py:390(GetHP)
39 0.000 0.000 0.000 0.000 player.py:670(TimerReset)
1608 0.019 0.000 0.027 0.000 player.py:673(TimerCheck)
8844 0.471 0.000 0.579 0.000 player.py:680(checkForCollisions)
1236 0.012 0.000 0.028 0.000 player.py:691(collide)
1 0.000 0.000 28.605 28.605 profile:0(main())
0 0.000 0.000 profile:0(profiler)
804 0.015 0.000 0.015 0.000 projectile.py:103(TrackBullets)
804 0.004 0.000 0.004 0.000 projectile.py:311(SendLevel)
3 0.000 0.000 0.000 0.000 random.py:147(randrange)
3 0.000 0.000 0.000 0.000 random.py:211(randint)
1 0.000 0.000 0.000 0.000 site.py:244(__call__)
14472 0.230 0.000 2.064 0.000 solid.py:135(draw)
5 0.000 0.000 0.000 0.000 sound.py:27(SoundFX)
2455 0.010 0.000 0.010 0.000 sprite.py:235(applyFriction)
156 0.001 0.000 0.001 0.000 sprite.py:250(reverseXVelocity)
3584 0.029 0.000 0.029 0.000 sprite.py:75(addVelocity)
5366 0.038 0.000 0.038 0.000 sprite.py:82(setVelocity)
803 0.003 0.000 0.003 0.000 sprite.py:91(get_speedx)
9648 1.671 0.000 2.916 0.000 sprite.py:99(updatePosition)
2412 0.012 0.000 0.012 0.000 test.py:137(rotateFrame)
2412 0.071 0.000 0.907 0.000 test.py:142(move)
3216 0.041 0.000 0.061 0.000 test.py:214(handleJump)
156 0.001 0.000 0.001 0.000 test.py:239(reverseDirection)
2412 0.143 0.000 0.507 0.000 test.py:80(draw)
804 0.004 0.000 0.004 0.000 testball.py:109(Local_applyFriction)
804 0.003 0.000 0.003 0.000 testball.py:24(think)
60 0.000 0.000 0.000 0.000 testball.py:27(enemyToBuzz)
804 0.026 0.000 0.083 0.000 testball.py:44(draw)
168 0.002 0.000 0.003 0.000 testball.py:45(collide)
804 0.044 0.000 0.384 0.000 testball.py:55(move)
804 0.011 0.000 0.017 0.000 testball.py:87(handleJump)
804 0.003 0.000 0.003 0.000 testbox.py:23(think)
804 0.015 0.000 0.029 0.000 testbox.py:40(draw)
849 0.010 0.000 0.021 0.000 testbox.py:44(collide)
804 0.024 0.000 0.258 0.000 testbox.py:47(move)
804 0.012 0.000 0.017 0.000 testbox.py:76(handleJump)
3216 0.021 0.000 0.021 0.000 transdoor.py:23(think)
396 0.002 0.000 0.002 0.000 transdoor.py:29(enemyToBuzz)
3216 0.044 0.000 0.135 0.000 transdoor.py:40(draw)
3216 0.068 0.000 0.984 0.000 transdoor.py:46(move)
734 0.005 0.000 0.005 0.000 transdoor.py:49(collide)
3216 0.012 0.000 0.012 0.000 transdoor.py:77(handleJump)
804 0.003 0.000 0.003 0.000 trap.py:22(think)
121 0.000 0.000 0.000 0.000 trap.py:28(enemyToBuzz)
218 0.057 0.000 0.057 0.000 trap.py:40(collide)
804 0.020 0.000 0.021 0.000 weapon.py:41(check_position)
3216 0.046 0.000 0.179 0.000 weapon.py:61(draw)
804 0.019 0.000 0.040 0.000 weaponRazzer.py:30(update)
804 0.004 0.000 0.004 0.000 zhaki.py:21(think)
969 0.003 0.000 0.003 0.000 zhaki.py:28(enemyToBuzz)
804 0.015 0.000 0.058 0.000 zhaki.py:40(draw)
1129 0.005 0.000 0.005 0.000 zhaki.py:41(collide)
804 0.022 0.000 0.280 0.000 zhaki.py:47(move)
804 0.011 0.000 0.018 0.000 zhaki.py:76(handleJump)

Share this post


Link to post
Share on other sites
The fill and flip functions seem to be soaking up a lot of time. Try pre-flipping for the latter.

What's the fill function being used for in this game? If you just want a flat colour, there are quicker ways of achieving the same goal. Pixel plotting isn't usually hardware-accelerated, whereas blitting is.

Share this post


Link to post
Share on other sites
Well with fill function we made sky and ground but that will be removed when we will have some nice backgrounds and programmed rooms in level editor (on that we are currently working)...running field (where player moves) is right now infinite in any way so that is why filling is there and no background...

Share this post


Link to post
Share on other sites
Right now we have around 35-40 fps on this configuration : Intel Pentium M , 1.73 GHz,2 GB RAM DDR and some integrated 32-bit graphic card.
That is still too slow,we would like to have around 60 fps on Intel Pentium 3 600 MHz , 128 MB RAM and some graphic card like GeForce 3 32 MB.
Is that even possible?

also we was examining dirty rect animation (explanation of it is more down) , but at end it tells :

There are two cases where this technique just won't work. The first is where the whole window or screen really is being updated every frame - think of a smooth-scrolling engine like an overhead real-time strategy game or a side-scroller. So what do you do in this case? Well, the short answer is - don't write this kind of game in pygame. The long answer is to scroll in steps of several pixels at a time; don't try to make scrolling perfectly smooth. Your player will appreciate a game that scrolls quickly, and won't notice the background jumping along too much.



So is there any other way to do it?? To speed up bliting in side scrolling game using pygame? Is it possible to blit with Python? Also how to keep frame rate stable???

Thanks in advance!!!!!!





The most common cause of inadequate frame rates in pygame programs results from misunderstanding the pygame.display.update() function. With pygame, merely drawing something to the display surface doesn't cause it to appear on the screen - you need to call pygame.display.update(). There are three ways of calling this function:

1. pygame.display.update() - This updates the whole window (or the whole screen for fullscreen displays).
2. pygame.display.flip() - This does the same thing, and will also do the right thing if you're using doublebuffered hardware acceleration, which you're not, so on to...
3. pygame.display.update(a rectangle or some list of rectangles) - This updates just the rectangular areas of the screen you specify.

Most people new to graphics programming use the first option - they update the whole screen every frame. The problem is that this is unacceptably slow for most people. Calling update() takes 35 milliseconds on my machine, which doesn't sound like much, until you realize that 1000 / 35 = 28 frames per second maximum. And that's with no game logic, no blits, no input, no AI, nothing. I'm just sitting there updating the screen, and 28 fps is my maximum framerate. Ugh.

The solution is called 'dirty rect animation'. Instead of updating the whole screen every frame, only the parts that changed since the last frame are updated. I do this by keeping track of those rectangles in a list, then calling update(the_dirty_rectangles) at the end of the frame. In detail for a moving sprite, I:

1. Blit a piece of the background over the sprite's current location, erasing it.
2. Append the sprite's current location rectangle to a list called dirty_rects.
3. Move the sprite.
4. Draw the sprite at it's new location.
5. Append the sprite's new location to my dirty_rects list.
6. Call display.update(dirty_rects)

The difference in speed is astonishing. Consider that Solarwolf has dozens of constantly moving sprites updating smoothly, and still has enough time left over to display a parallax starfield in the background, and update that too.



A final note - not every game requires high framerates. A strategic wargame could easily get by on just a few updates per second - in this case, the added complexity of dirty rect animation may not be necessary.





ncalls tottime percall cumtime percall filename:lineno(function)
3131 0.041 0.000 0.041 0.000 :0(append)
49185 11.323 0.000 11.323 0.000 :0(blit)
3875 0.019 0.000 0.019 0.000 :0(clock)
1 0.000 0.000 0.000 0.000 :0(close)
1842 0.017 0.000 0.017 0.000 :0(colliderect)
15 0.001 0.000 0.001 0.000 :0(convert)
1876 0.064 0.000 0.064 0.000 :0(convert_alpha)
591 0.159 0.000 0.162 0.000 :0(eval)
1874 0.047 0.000 0.047 0.000 :0(fill)
942 8.434 0.009 8.434 0.009 :0(flip)
938 0.210 0.000 0.210 0.000 :0(get)
937 0.006 0.000 0.006 0.000 :0(get_focused)
937 0.005 0.000 0.005 0.000 :0(get_fps)
8042 0.047 0.000 0.047 0.000 :0(get_height)
2112 0.021 0.000 0.021 0.000 :0(get_pos)
4685 0.067 0.000 0.067 0.000 :0(get_pressed)
2 0.000 0.000 0.000 0.000 :0(get_rect)
1921 0.012 0.000 0.012 0.000 :0(get_ticks)
8042 0.038 0.000 0.038 0.000 :0(get_width)
162 0.004 0.000 0.004 0.000 :0(index)
8 0.000 0.000 0.000 0.000 :0(len)
17 0.032 0.002 0.032 0.002 :0(load_extended)
162 0.085 0.001 0.085 0.001 :0(play)
3087 0.056 0.000 0.056 0.000 :0(pop)
937 0.014 0.000 0.014 0.000 :0(range)
5932 0.418 0.000 0.418 0.000 :0(remove)
937 0.122 0.000 0.122 0.000 :0(render)
527 0.111 0.000 0.111 0.000 :0(rotate)
591 0.012 0.000 0.012 0.000 :0(set_alpha)
1 0.019 0.019 0.019 0.019 :0(setprofile)
527 0.069 0.000 0.069 0.000 :0(smoothscale)
80 0.003 0.000 0.003 0.000 :0(sqrt)
937 1.130 0.001 1.130 0.001 :0(tick)
592/1 0.003 0.000 33.451 33.451 <string>:1(<module>)
937 0.062 0.000 0.170 0.000 GFX_OSD.py:76(DrawHealthBar)
937 0.008 0.000 0.008 0.000 GFX_OSD.py:93(WeaponChangeRender)
937 0.006 0.000 0.006 0.000 GFX_Status.py:101(RenderAPnotifier)
1 0.000 0.000 0.001 0.001 GFX_Status.py:111(AddFX_ForestMakochiDestroyed)
28 0.003 0.000 0.015 0.001 GFX_Status.py:119(AddFX_GenericBurst)
3 0.000 0.000 0.003 0.001 GFX_Status.py:127(AddFX_GenericBurst_Red)
1 0.000 0.000 0.000 0.000 GFX_Status.py:149(AddFX_Stars_Red)

1 0.000 0.000 0.000 0.000 GFX_Status.py:173(AddFX_CoinPickup)
937 0.019 0.000 0.065 0.000 GFX_Status.py:180(ReproduceFX_ForestMakochiDestroy)
937 0.016 0.000 0.016 0.000 GFX_Status.py:205(ReproduceFX_MinervaBounce)
937 0.105 0.000 0.432 0.000 GFX_Status.py:235(ReproduceFX_GenericBurst)
937 0.010 0.000 0.010 0.000 GFX_Status.py:258(ReproduceFX_GenericBurst2)
937 0.020 0.000 0.059 0.000 GFX_Status.py:281(ReproduceFX_GenericBurst_Red)
937 0.014 0.000 0.014 0.000 GFX_Status.py:304(ReproduceFX_GenericTrail)
937 0.013 0.000 0.013 0.000 GFX_Status.py:327(ReproduceFX_GenericTrail2)
937 0.018 0.000 0.018 0.000 GFX_Status.py:359(ReproduceFX_Shadow)
937 0.019 0.000 0.071 0.000 GFX_Status.py:382(ReproduceFX_Stars_Red)
937 0.013 0.000 0.013 0.000 GFX_Status.py:403(ReproduceFX_Stars_Blue)
937 0.010 0.000 0.010 0.000 GFX_Status.py:424(ReproduceFX_Stars_Yellow)
937 0.011 0.000 0.011 0.000 GFX_Status.py:445(ReproduceFX_Stars_White)
937 0.014 0.000 0.014 0.000 GFX_Status.py:466(ReproduceFX_Stars_Purple)
937 0.007 0.000 0.007 0.000 GFX_Status.py:487(ReproduceFX_Stars_Black)
937 0.014 0.000 0.031 0.000 GFX_Status.py:508(ReproduceFX_CoinPickup)
3 0.000 0.000 0.001 0.000 GFX_Status.py:533(AddFX)
6868 0.088 0.000 0.088 0.000 TriangleSolid.py:121(collision_with_rect)
1874 0.013 0.000 0.013 0.000 buzz.py:140(rotateFrame)
1874 0.067 0.000 1.201 0.001 buzz.py:145(move)
64 0.021 0.000 0.022 0.000 buzz.py:178(Jump)
7 0.000 0.000 0.000 0.000 buzz.py:192(startJump)
1874 0.051 0.000 0.068 0.000 buzz.py:202(handleJump)
141 0.001 0.000 0.001 0.000 buzz.py:225(reverseDirection)
434 0.004 0.000 0.004 0.000 buzz.py:283(WalkRight)
173 0.002 0.000 0.002 0.000 buzz.py:302(WalkLeft)
330 0.002 0.000 0.002 0.000 buzz.py:321(NoMoveCommands)
1874 0.375 0.000 0.826 0.000 buzz.py:72(draw)
937 0.010 0.000 0.010 0.000 camera.py:11(set)
1874 0.019 0.000 0.028 0.000 debug.py:25(Start)
1874 0.061 0.000 0.070 0.000 debug.py:31(Stop)
937 0.055 0.000 6.220 0.007 debug.py:81(TestFunc)
146 0.001 0.000 0.001 0.000 default.py:47(collide)
937 0.014 0.000 0.014 0.000 dimwit.py:30(think)
138 0.001 0.000 0.001 0.000 dimwit.py:53(enemyToBuzz)
138 0.002 0.000 0.006 0.000 dimwit.py:69(collide)
937 0.014 0.000 0.014 0.000 event.py:38(update)
937 0.496 0.001 24.846 0.027 game.py:104(draw)
937 0.039 0.000 1.224 0.001 game.py:186(limitFramerate)
937 0.121 0.000 0.294 0.000 game.py:198(checkInput)
937 0.033 0.000 0.079 0.000 game.py:318(checkForConsole)
937 0.258 0.000 6.121 0.007 game.py:345(update)
1 0.001 0.001 0.001 0.001 game.py:380(exit)
379 0.017 0.000 0.219 0.001 game.py:388(CheckEvent)
937 0.104 0.000 32.971 0.035 game.py:77(loop)
9854 0.091 0.000 0.091 0.000 input_koki.py:10(CheckEvent)
937 0.161 0.000 0.274 0.000 input_koki.py:101(Update)
24362 0.113 0.000 0.113 0.000 input_koki.py:20(Update)
379 0.076 0.000 0.168 0.000 input_koki.py:96(CheckEvent)
937 0.483 0.001 12.871 0.014 level.py:130(draw)
937 0.305 0.000 5.708 0.006 level.py:168(update)
2 0.000 0.000 0.002 0.001 level.py:265(insertSolid)
1 0.050 0.050 33.451 33.451 main.py:56(main)
3 0.003 0.001 0.006 0.002 makochi_green.py:105(shot)
309 0.007 0.000 0.021 0.000 makochi_green.py:40(draw)
309 0.008 0.000 0.160 0.001 makochi_green.py:48(move)
309 0.010 0.000 0.014 0.000 makochi_green.py:56(think)
309 0.002 0.000 0.002 0.000 makochi_green.py:67(startJump)
309 0.005 0.000 0.008 0.000 makochi_green.py:77(handleJump)
1874 0.013 0.000 0.013 0.000 menu.py:20(isActive)
937 0.003 0.000 0.003 0.000 menu.py:35(update)
5931 0.096 0.000 0.777 0.000 npc.py:40(draw)
5931 0.154 0.000 3.451 0.001 npc.py:43(update)
236 0.005 0.000 0.006 0.000 npc.py:54(enemyToBuzz)
27 0.000 0.000 0.007 0.000 npc.py:58(shot)
1 0.000 0.000 0.000 0.000 npc.py:62(destroy)
528 0.009 0.000 0.016 0.000 npc.py:67(collide)
5931 0.348 0.000 0.772 0.000 npc.py:73(checkForCollisions)
6 0.000 0.000 0.000 0.000 ntpath.py:116(splitdrive)
6 0.000 0.000 0.000 0.000 ntpath.py:51(isabs)
2 0.000 0.000 0.000 0.000 ntpath.py:59(join)
125058 1.433 0.000 1.433 0.000 object.py:26(collision_with_rect)
2 0.000 0.000 0.000 0.000 object.py:7(__init__)
937 0.074 0.000 0.091 0.000 pickup.py:38(ItemCollectCheck)
1841 0.075 0.000 0.075 0.000 pickup.py:51(isVisible)
937 0.048 0.000 0.242 0.000 pickup.py:56(DrawItems)
937 0.049 0.000 0.701 0.001 player.py:325(update)
3 0.000 0.000 0.000 0.000 player.py:383(SetHP)
1877 0.010 0.000 0.010 0.000 player.py:390(GetHP)
47 0.000 0.000 0.001 0.000 player.py:670(TimerReset)
1874 0.024 0.000 0.036 0.000 player.py:673(TimerCheck)
5931 0.274 0.000 0.294 0.000 player.py:680(checkForCollisions)
236 0.003 0.000 0.009 0.000 player.py:691(collide)
1 0.001 0.001 33.471 33.471 profile:0(main())
0 0.000 0.000 profile:0(profiler)
937 0.047 0.000 0.089 0.000 projectile.py:17(Update)
937 0.017 0.000 0.046 0.000 projectile.py:176(DrawPointer)
65 0.002 0.000 0.002 0.000 projectile.py:181(GetPercX)
65 0.000 0.000 0.000 0.000 projectile.py:190(GetPercY)
65 0.000 0.000 0.000 0.000 projectile.py:194(GetSQ)
119 0.005 0.000 0.030 0.000 projectile.py:198(FireBullet_Generic)
937 0.059 0.000 0.340 0.000 projectile.py:24(Draw)
937 0.254 0.000 1.852 0.002 projectile.py:289(TrackBullets)
15 0.001 0.000 0.034 0.002 projectile.py:33(AddProjectile)
15 0.001 0.000 0.033 0.002 projectile.py:46(__init__)
2459 0.612 0.000 1.014 0.000 projectile.py:531(CollidedWithSolid)
2431 0.236 0.000 0.342 0.000 projectile.py:536(CollidedWithNPC)

937 0.005 0.000 0.005 0.000 projectile.py:560(SendLevel)
71318 0.501 0.000 0.501 0.000 projectile.py:564(isInRect)
5676 0.042 0.000 0.042 0.000 projectile.py:59(Update)
5676 0.090 0.000 0.280 0.000 projectile.py:66(Draw)
1 0.000 0.000 0.000 0.000 site.py:244(__call__)
21800 0.446 0.000 4.809 0.000 solid.py:135(draw)
2 0.000 0.000 0.002 0.001 solid.py:25(__init__)
2 0.000 0.000 0.002 0.001 solid.py:30(__init__)
2 0.000 0.000 0.002 0.001 solid.py:41(moreInit)
2 0.000 0.000 0.002 0.001 solid.py:9(load_image)
162 0.004 0.000 0.093 0.001 sound.py:33(SoundFX)
1267 0.010 0.000 0.010 0.000 sprite.py:189(applyFriction)
141 0.002 0.000 0.002 0.000 sprite.py:204(reverseXVelocity)
1403 0.014 0.000 0.014 0.000 sprite.py:74(addVelocity)
2032 0.013 0.000 0.013 0.000 sprite.py:81(setVelocity)
6868 1.954 0.000 3.476 0.001 sprite.py:96(updatePosition)
2 0.000 0.000 0.000 0.000 sprite.py:97(__init__)
3748 0.019 0.000 0.019 0.000 transdoor.py:23(think)
98 0.000 0.000 0.000 0.000 transdoor.py:29(enemyToBuzz)
14 0.000 0.000 0.000 0.000 transdoor.py:32(shot)
3748 0.077 0.000 0.209 0.000 transdoor.py:40(draw)
3748 0.111 0.000 1.903 0.001 transdoor.py:46(move)
244 0.002 0.000 0.002 0.000 transdoor.py:49(collide)
3748 0.021 0.000 0.021 0.000 transdoor.py:77(handleJump)
937 0.020 0.000 0.020 0.000 weapon.py:41(check_position)
1874 0.034 0.000 0.063 0.000 weapon.py:61(draw)
937 0.018 0.000 0.038 0.000 weaponMinerva.py:24(update)
937 0.004 0.000 0.004 0.000 zhaki.py:21(think)
10 0.000 0.000 0.000 0.000 zhaki.py:31(shot)
937 0.021 0.000 0.034 0.000 zhaki.py:40(draw)
937 0.030 0.000 0.560 0.001 zhaki.py:47(move)
937 0.020 0.000 0.026 0.000 zhaki.py:76(handleJump)

Share this post


Link to post
Share on other sites
From what I understand SDL uses GDI functions to do its 2D drawing, blits and such which are very slow. I hear you can get better performance going through the OpenGL interfaces. There are many OpenGL 2D sprite tutorials which you can repurpose for your needs. That's really the only option, since your profile shows your bounded by the blit and update.

Good Luck!

-ddn

Share this post


Link to post
Share on other sites
Ok..so it is possible to connect Pygame with PyOpenGL...is there any good tutorial for it ? We would use PyOpenGL functions only for blitting sprites, nothing else, because there is no other problems except that.
Thanks in advance!

Share this post


Link to post
Share on other sites
There isn't a need to use another library than SDL, as SDL already has OpenGL support built in, you'll just need to access it. I beleive pyGame binds nearly the complete OpenGL interfaces to Python, so any examples you download off the net should work line for line in Python.

See for tutorials:

http://www.libsdl.org/opengl/index.php

[edit: Looks like pyGame doesn't expose any openGL interfaces at all. My first choice would be to extend pyGame and add in the openGL support within pyGame, possibly using the pyOpenGL as a starting point ( since they wrap all the interfaces for you ), or trying to intergrate pyOpenGL, problem is pyGame and SDL creates their own windows context and resources which might be duplicated within pyOpenGL.

I was just browsing pyGames src and it's really quite an old C based library. Doesn't take advantage of any of the 3d acceleration technological advances, even though it does use the SDL for the backend. It might be time to bring the surface class up to date with todays tech, it would get a massive improvement in performance.]


Good Luck!

-ddn

[Edited by - ddn3 on November 5, 2008 6:58:40 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by ddn3
[edit: Looks like pyGame doesn't expose any openGL interfaces at all. My first choice would be to extend pyGame and add in the openGL support within pyGame, possibly using the pyOpenGL as a starting point ( since they wrap all the interfaces for you ), or trying to intergrate pyOpenGL, problem is pyGame and SDL creates their own windows context and resources which might be duplicated within pyOpenGL.

Or just use Pyglet which gives you the convenience of SDL with the speed of OpenGL, rather than just giving you access to OpenGL and expecting you to code the rendering. It does what SDL and PyGame should have done years ago.

Share this post


Link to post
Share on other sites

This topic is 3323 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this