python coding with regards to speed..

i’ve tried/played some of the example games for BGE, and i kinda think that it’s slow… i also tried creating a super simple (without materials, just 2 flippers, a ball and nothing else) pinball game via logic bricks, and it’s slow too… will the use of python codes speed things up? thanks in advance…

Python code gets slow pretty fast if you have a lot of scripts running. This was one of the hurdles I faced in an old project of mine. I had dozens of scripts running all several times per second. It really became impractical before long, especially because the operations being performed in the scripts were very math intensive.

Say for example I have one car in my scene, and it runs maybe 4 scripts, but all of those scripts run at least 10 times per second, and there are 4 instances of the scripts running that are attatched to the wheels. This is fine if there’s just one car in the scene, but if I try to add several more, it slows down a lot. Mix that with many more objects that are script driven and it bogs down eventually.

This isn’t really a problem on newer computers though. I’m using a low end system, so the bogging is apparent, but running the same thing on a higher end computer it’s not a problem.

I think the real cause for it was because every object in my game was script driven by several scripts that communicated between eachother through primitive methods so they all sort of depended on each other. So if I had used logic bricks, It may not have been a problem, because you can’t do the things with logic bricks that you can do in a Python script.

Also, the execution of the scripts is kind of sketchy because if you have it hooked up to a sensor that fires 20 times per second, is the script going to execute 20 times per second? What if you’re getting 2 frames per second, is it going to execute only 2 times per frame? I dunno.

Anyway, I guess to answer your question, in my experience, and in general, logic bricks are faster, but they are not as powerful. You will need Python to do things that can’t be done in logic bricks. I may be wrong though…

Getting even more technical, if you’re using Python methods that aren’t Blender Game Engine specific, you may suffer some performance issues depending on the compexity of the method.

Another nussance of using Python scripts with the Game Engine is that if you ever want to do anything to the objcet that the script is running on, you need to do the whole GetController and GetOwner thing.

I’m done.

will the use of python codes speed things up? thanks in advance…
A shorter answer – no. Get a decent machine like maybe something made in the last 5 years with a decent video card in it from either nvidia or ati. Otherwise find some 2d game-maker somewhere. If you can’t make a ball with 2 flippers you have something severely outdated or maybe your using one of those crappy internal video cards. You need a gaming rig. I have a 3 year old computer with an old mx440 and it runs pretty good.

yes the BGE is fairly slow and is made worse if u have a crapy com, but things should be made alot faster once Ogre is integrated

thanks guys… i really can depend on you to answer my questions…

Sempron 2800+ (2.0GHz), 80Gig HD, 256MB DDR, 256MB GeForce FX 5200…

after what i’ve heard from you guys, i think the problem lies with my memory… maybe i will increase it to 1 Gig, but not in the near future… thanks again and more power to you all!

That should be faster, it’s basicly newer than my system.
Try GameLogic.setLogicTicRate(75.0) with an always sensor with the pulses turned off. Update your drivers. Check your nvidia settings and make sure synch is checked in all boxes. Also give the balls, or in that case the flippers, more force or velocity and see if they move faster. A ball that’s rolling down an inclined plane like a pinball table will not appear to move very fast on gravity alone. Giving it higher mass will make it keep it’s velocity longer, then find ways to increase the bounce speed.