Sign in to follow this  
zabo

Need help speeding up my game (blitz3d)

Recommended Posts

zabo    101
So far my game is only 100 aliens and when you blow ALL OF THEM UP it replaces them 150 more (only once though)and a green plane. i need help speeding up my game cuz its lagging badly! i was thinking of putting the code into different programs and having one master program but i dont see that as the problem.... (cuz i only have about 100 lines of code) i was thinking that cuz when i fire a bullet it foats in space forever! how do i correct this? and do you have any tips on making the game go faster?(this is a blitz3d game) [Edited by - zabo on November 21, 2007 6:40:41 PM]

Share this post


Link to post
Share on other sites
bobwrit    100
Concidering yur using 3D graphics and how many items your creating, I don't think you can. sorry. also If your using a scalable window you can speed the game up by making it a fixed size.

Share this post


Link to post
Share on other sites
zabo    101
Quote:
Original post by bobwrit
Concidering yur using 3D graphics and how many items your creating, I don't think you can. sorry. also If your using a scalable window you can speed the game up by making it a fixed size.


i didnt think 200 max was to much items...... i once had a forest of over 1000 trees and it didn't lag...... so what can i do about the bullets floating in space so that they disappear after a certain distance and get erased from memory?

Share this post


Link to post
Share on other sites
zabo    101
Quote:
Original post by bobwrit
Concidering yur using 3D graphics and how many items your creating, I don't think you can. sorry. also If your using a scalable window you can speed the game up by making it a fixed size.


my screen size is 640 by 480 is that good or bad?

Share this post


Link to post
Share on other sites
bobwrit    100
Check your graphic() function, if you can resize the window it will hinder speed a lot. If it isn't that, it may be the randomization code or the bullets moving that may be the culprit. As for the bullets going on forever, try placing it so that if the bullets Z value goes beyond a certan value it destroys the bullet.

Share this post


Link to post
Share on other sites
zabo    101
whats a good screen size? also when im done putting in the bullet destruction code ill come back to ya(im gonna eat too) i think the bullets are definantly the prob cuz in the game you fire fully automatic weapons :) the only randomization code i have is putting the enemies at random positions. oh one more thought remember my problem with my spawning codes? i fixed so instead of using score#=score#+1 or b=b+1
i used this---->
if score#=100 then score#=score#+1

do you think that could cause any lagging?

Share this post


Link to post
Share on other sites
bobwrit    100
Quote:
Original post by zabo
whats a good screen size? also when im done putting in the bullet destruction code ill come back to ya(im gonna eat too) i think the bullets are definantly the prob cuz in the game you fire fully automatic weapons :) the only randomization code i have is putting the enemies at random positions. oh one more thought remember my problem with my spawning codes? i fixed so instead of using score#=score#+1 or b=b+1
i used this---->
if score#=100 then score#=score#+1

do you think that could cause any lagging?


No, the change shouldn't cause any lag, I think it'll be the bullets.
For size I typicaly use 800x600. so for the weapon either switch the keydown()/mousedown() function to keyhit()/mousehit() and it wont be automatic.

Share this post


Link to post
Share on other sites
zabo    101
i want it to be automatic..... hmmmm..... maybe its the way the bullets are made every time the mouse is down it creates a 3d bullet maybe i should switch to 2d? the game only starts to lag when the enemies are all dead and replaced with 100 more ......... shit this is bugging me also do you know a good code for destroying the bullets i tried entity distance and the bullets wont even show up...

Share this post


Link to post
Share on other sites
zabo    101
I found a way to speed up my game instead of making 100 aliens just make 100 copies! and use free entity to erase the old one.

Share this post


Link to post
Share on other sites
Dookie    290
I don't code in Blitz, but I do in Direct3D. Sounds like you have your slowdown problems figured out.

Here's a couple of suggestions:
- Make sure to delete entities that get shot or destroyed (you already found that one!)
- Assign a timer to each bullet that gets spawned. Delete the bullet when its timer expires.
OR
- Keep track of distance bullet travels. Delete the bullet when it reaches its max distance.

Another performance test is to count the number of entities that each gameloop iteration is processing. For example, let's say you're processing your aliens and bullets something like this:
rem * Loop through all game entities.  If an entity is in use,
rem * then we process its code.
for A = 0 to MAX_ENTS
if (ent[A].inUse == TRUE)
{
rem * This ent is in use. Increment entity counter...
EntCount = EntCount + 1;

rem * Move Aliens...
rem * Process Bullet/Alien Collisions...
rem * Process MyShip/Alien Collisions...
}
next A;
rem * Gameloop ended. Display how many entities were
rem * active during this gameloop iteration...
print EntCount

Using the above pseudocode, you can see exactly how many entities your game is processing. If there's ten aliens on the screen, then 'EntCount' should equal 11 (ten aliens, and your ship). If you fire twenty bullets, then your EntCount will increase to 31 (20 bullets, ten aliens, and your ship). When the bullets hit stuff, or when the bullets reach the ends of their lives and get deleted (via timer or distance tracking), then your EntCount should decrease... If EntCount keeps going up and never goes down, even when there's only a few things on the screen, then you know that not every destroyed alien or bullet entity is getting released in your game code.

TIP: If you want to do distance tracking for deleting stray bullets, simply keep track of how much each bullet moves per gameloop iteration.
TotalDistance = TotalDistance + ThisMovement
When TotalDistance is greater than the distance you want your bullet to go before getting automatically deleted, delete it!
if (TotalDistance > 1000) then DeleteBullet

Hope that helps, and good luck with your game!

Share this post


Link to post
Share on other sites

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