Goooood morning everyone. Zaoshang hao.
I’ve been building a very python heavy, random generating script for a 2D game I’ve been making and I need a lot of help optimising it because even on my i5 2320 (I believe) it lags in the logic sometimes, not all the time, but when levels are stretched out to 60 seconds (as they will be in the final version) some levels have logic spikes that just keep building, as if more and more objects with logic are being created and not removed. What I think might be the problem is that in my setup: Each bomber ship launches a bomb at random intervals (+1 random generation per logic tic), each bomb leaves a trail of specs that EACH generate 2 random integers (+2 random generations per logic tic per contrail object), each missile fired from the player does the same thing every 5 tics or so, and so on.
I remember a test being run by one of us here in the forums on loops vs per object logic. Being that, ONE script would loop through all objects with a property and affect them individually, instead of each object running it’s own script. Which I believe might be the solution to my problem.
Or perhaps, upon your own inspection, you can come up with far better solutions.
No matter what, I very much appreciate your help.
I will link to the .blend file so you may look at the logic and code. And from this file you may use any scripts and ideas regarding logic that you may fancy, however I request that the image files and sounds be reserved for myself. (Also bare in mind that I have changed “Player.py” to facilitate the idea of debugging, what happens to the level progression is purely for the purposes of fixing the game and does not represent the final system.)
Thankyou for your time, and your help.
// 1.6 mb
// 2 windows will open, however all you need will be in the first window
// Any criticisms welcome, optimisation in mind
Thankyou, xie xie, gracias, origato, merci, danke, kiitos.