Page 1 of 2
Help to optimize
Posted: Thu Oct 16, 2003 11:26 am
by lethalpolux
I search optimisations... what the best things to do to keep fps in a 2D shoot them up game.. if anyone as some tricks or rules to get a good framerate everywhere...
I've replace some goto's with break command ( new in 3.80 ) and i've win 4-6 fps...

my game is in 800x600, and i want to keep a good framerate on some machines.
I use a lot of sprite3D.. is there some optimisations to it..?
Posted: Thu Oct 16, 2003 11:34 am
by lethalpolux
I've forgot that my game turn perfectly on my PIV 2Ghz with GF4Ti but with a 1,5 and GF4 MX, ( on 32bits mode, and all graphics options selected ) at few moments ( when it was a LOT of sprites on screen ), the framerate slow down at 48/50 fps and restart to 60 after...
Posted: Thu Oct 23, 2003 10:15 am
by Johan_Haegg
Sprite3DQuality() can be used, but its ugly...
its hard to optimize a code if you cant look at it.
Hope you are using something so you move at the same speed in 2fps as in 75fps.
Posted: Thu Oct 23, 2003 9:23 pm
by Blade
Johan_Haegg wrote:Sprite3DQuality() can be used, but its ugly...
its hard to optimize a code if you cant look at it.
Actual videocards have no speed difference with quality ON or OFF, some even are optimized for quality ON!

(tested on a OpenGL 3D engine I made 2 years ago...)
The best optimization isn't on the graphic side (3D sprites are simply too fast!), but how you manage collisions, animation events and all those nice stuff a game requires...

Posted: Fri Oct 24, 2003 10:05 am
by lethalpolux
Thanx! How to manage with the good way collisions for example?..
in my game, i made ( for example ):
dim enemix.w(10)
dim enemiy.w(10)
global playerx.w,playery.w
...shortcut...
for i=1 to 10
if spritepixelcollision(1,playerx,playery,2,enemix(i),enemiy(i)=1
kaboum!
endif
next i
it's a good way?
Posted: Fri Oct 24, 2003 10:46 am
by Fred
I would use linked list for ennemy colision, because once an enemy is destroyed, it's removed from the list and the remaining checks are lower to do. Would influence on heavy loaded screen tough, for 10 ennemies, it won't hurt at all.
Posted: Fri Oct 24, 2003 11:29 am
by chris_b
If you are testing for many sprite collisions then you might speed things up a bit by only using the slower spritepixelcollision if spritecollision is true:
Code: Select all
if spritecollision(1,playerx,playery,2,enemix(i),enemiy(i))=1
if spritepixelcollision(1,playerx,playery,2,enemix(i),enemiy(i))=1
kaboum!
endif
endif
Posted: Fri Oct 24, 2003 11:33 am
by lethalpolux
Linked list? how did it work?
Posted: Fri Oct 24, 2003 1:28 pm
by Fred
chris_b: SpritePixelCollision() of course check the bounding box before doing pixel perfect collision so checking SpriteCollision() is useless. I will add this to the doc, thanks for the remark.
polux: Look in the Waponez II example. Basically, you have a linked list with all the displayed sprites and when you kill one, you do a 'DeleteElement()'. When you want to display all remaining sprites, you use ForEach..
Posted: Fri Oct 24, 2003 1:58 pm
by lethalpolux
Good! thanx! i will test this tonight...
Thanx Chris_b, i change all my spritepixelcollision too!

Posted: Fri Oct 24, 2003 2:30 pm
by freedimension
lethalpolux wrote:Good! thanx! i will test this tonight...
Thanx Chris_b, i change all my spritepixelcollision too!

NOOOooo, don't do this, read Freds answer instead.
Posted: Fri Oct 24, 2003 2:47 pm
by lethalpolux
OOOUps! sorry... i've not understand... ( me and my poor english )
Thankx a lot Freedimension...

Posted: Fri Oct 24, 2003 2:54 pm
by freedimension
Posted: Fri Oct 24, 2003 6:52 pm
by lethalpolux
I know Ogre speaking... not english...
arumboid, ristur tapour rakada tatopi... Grrr!
Posted: Sat Oct 25, 2003 4:10 am
by chris_b
Fred wrote:SpritePixelCollision() of course check the bounding box before doing pixel perfect collision so checking SpriteCollision() is useless. I will add this to the doc, thanks for the remark.
Thanks for pointing this out. I guess I should have tested my theory before posting it
