reducing lag in a bgt game?

Hello everyone.
I've come a long way with a game I'm working on, but am noticing it lags, quite a lot with lots of objects of a class on screen.
I have an item system which only loops through the items every time the player takes a step.
For the enemies and AI, I have it loop through while the game lives.
With anything less than 40 enemies, it is fine. But any more than 40 or sometimes even 50, it starts to lag and audio gets choppy.
In the old days of messing around with bgt I used to loop through a board of enemies, like demonstrated in the bgt windows attack example.
Now I have an array of enemies I loop through, and I only (at least I think I do) loop through the list of existing enemies.
I call wait pretty often in my while loops, and even in my check enemies or whatever I need to check functions.
I've not yet tried the garbage collection thing, as my game really doesn't have any real point where I can let the bgt en gine stop and take a rest.
I understand this is quite a broad subject and depends quite a bit on code (mine is quite awful I admit) and will be willing to work with someone in private.
If any of you bgt guys or any of you in general have any ideas, throw them at me and I will try them and see if the results have improved.
I'll try and submit sudo code for what my game is and what it does.
For those of you who have played sammy center, there is a game in there called wall breaker. Your trying to survive while enemies are attempting to break down the structure your surviving in.
Mine is more or less the same thing, except mine has some slight changes which I will do my best to list here, but not give the game away entirely.
When the player first starts out, the game places them on a random place of the lower left corner of the map. Anywhere between 60 and 150 items are generated, depending on your specs, and dropped on the map, ready to be picked up.
No enemies are spawned on the map until a minute or so later.
There are some AI, which I loop through in a while statement, which is the main one I use for player and all other functions while the game is still going.
The AI is responsible for helping the player collecting items, and walks, generally, once every 650 to 950 ms.
There are usually no more than 3, and they do actually die off, some right away, others several minutes later. I remove them from the array when they do die off so it's one less enemy to loop through when it comes time.
The items I only loop through when the player moves, which the game could sort of care less how many are on screen I usually keep no more than 150 on screen.
The enemies though I think are where the bottleneck is.
Unfortunately I've tried using the bgt profiler and the results given are not really what I was looking for unless I'm just not understanding the result.
Anyway, back to what I w as saying.
After roughly 1 minute passes and this goes until you die, this time also decrements each time enemies spawn, some enemies will spawn on the map. I believe it's 1 to 5 enemies per spawn.
They will last, anywhere from 1 to 5 minutes, and attack your structure, this variable usually varies from enemy to enemy, 3000 to 15000 ms.
The lag really becomes apparent about 7 to 12 minutes into the game and if you don't have that great a pc, where there are a lot of enemies on screen.
I could in theory make enemies live considerably shorter lives, and make them do more damage to keep up with there current damage in total to your structure, if that's what I need to do to minimize lag on as many machines as possible.
Currently I've found the game runs fine on the following specs, this is kind of the minimum specs I guess.
Probably something no less than an Intel core i5 running at 2 ghz with only 1 to 2 gb ram, hyperthreading recommend ed.
I've tested on an old laptop with an AMD CPU clocked probably somewhere around 1.85 ghz, 2 gb ram, and it runs, fair enough until about 7 to 12 minutes in to the game.
I hope this was good enough and if you have any ideas, throw them here and I'll try and see what I can do.
Thanks!

_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Omar Alvarado via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : sneak via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : sneak via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Omar Alvarado via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : lukas via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Omar Alvarado via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : lukas via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : lukas via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Trajectory via Audiogames-reflector

Reply via email to