Help to optimize

Advanced game related topics
lethalpolux
Enthusiast
Enthusiast
Posts: 171
Joined: Sun Jun 08, 2003 10:50 pm
Location: France
Contact:

Help to optimize

Post 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..?
Pol.
Intel Core2Duo 6600 - 3Gb DDR2 - Geforce8800Gts - Vista Home Premium 32bits
lethalpolux
Enthusiast
Enthusiast
Posts: 171
Joined: Sun Jun 08, 2003 10:50 pm
Location: France
Contact:

Post 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...
Pol.
Intel Core2Duo 6600 - 3Gb DDR2 - Geforce8800Gts - Vista Home Premium 32bits
Johan_Haegg
User
User
Posts: 60
Joined: Wed Apr 30, 2003 2:25 pm
Location: Västerås
Contact:

Post 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.
Blade
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Aug 06, 2003 2:49 pm
Location: Venice - Italy, Japan when possible.
Contact:

Post 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... :wink:
lethalpolux
Enthusiast
Enthusiast
Posts: 171
Joined: Sun Jun 08, 2003 10:50 pm
Location: France
Contact:

Post 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?
Pol.
Intel Core2Duo 6600 - 3Gb DDR2 - Geforce8800Gts - Vista Home Premium 32bits
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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.
chris_b
Enthusiast
Enthusiast
Posts: 103
Joined: Sun Apr 27, 2003 1:54 am

Post 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
lethalpolux
Enthusiast
Enthusiast
Posts: 171
Joined: Sun Jun 08, 2003 10:50 pm
Location: France
Contact:

Post by lethalpolux »

Linked list? how did it work?
Pol.
Intel Core2Duo 6600 - 3Gb DDR2 - Geforce8800Gts - Vista Home Premium 32bits
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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..
lethalpolux
Enthusiast
Enthusiast
Posts: 171
Joined: Sun Jun 08, 2003 10:50 pm
Location: France
Contact:

Post by lethalpolux »

Good! thanx! i will test this tonight...
Thanx Chris_b, i change all my spritepixelcollision too! :D
Pol.
Intel Core2Duo 6600 - 3Gb DDR2 - Geforce8800Gts - Vista Home Premium 32bits
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post by freedimension »

lethalpolux wrote:Good! thanx! i will test this tonight...
Thanx Chris_b, i change all my spritepixelcollision too! :D
NOOOooo, don't do this, read Freds answer instead.
lethalpolux
Enthusiast
Enthusiast
Posts: 171
Joined: Sun Jun 08, 2003 10:50 pm
Location: France
Contact:

Post by lethalpolux »

OOOUps! sorry... i've not understand... ( me and my poor english )
Thankx a lot Freedimension... :wink:
Pol.
Intel Core2Duo 6600 - 3Gb DDR2 - Geforce8800Gts - Vista Home Premium 32bits
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post by freedimension »

lethalpolux wrote:OOOUps! sorry... i've not understand... ( me and my poor english )
Now, from such a stupid looking ogre (orc, or what the h...) like you I didn't expect much more. It's you shown in the image to the left, isn't it? :D
Just to be sure: :D :) :lol: :wink: :wink: :wink:
lethalpolux
Enthusiast
Enthusiast
Posts: 171
Joined: Sun Jun 08, 2003 10:50 pm
Location: France
Contact:

Post by lethalpolux »

I know Ogre speaking... not english...
arumboid, ristur tapour rakada tatopi... Grrr!
Pol.
Intel Core2Duo 6600 - 3Gb DDR2 - Geforce8800Gts - Vista Home Premium 32bits
chris_b
Enthusiast
Enthusiast
Posts: 103
Joined: Sun Apr 27, 2003 1:54 am

Post 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 :oops:
Post Reply