C-Dawg
11-25-2007, 09:07 PM
I'm getting to the point where Zodiac is starting to creak under the strain of so many scripts running at once, even on my P3 3ghz. Here's the situation that seems to be causing the problem:
10 or so FFCs are running a script that, each frame, runs through 10 or so if statements to determine what sort of creature it's supposed to be acting as. Then another 10 - 20 ifs depending on what it finds, and writing to the FFC's X, Y, data, and the ghosted enemy's X and Y.
At the same time, another script is checking, for every enemy on the screen, whether it is within eight pixels of a custom weapon, or on a line with certain beam-based weapons.
I can get slowdown in two situations:
1. Where there are upwards of 20ish enemies on the screen at once; and
2. Where I use 20ish or more FFCs running the custom SHMUP script mentioned above.
I'm a bare amateur when it comes to coding. I could optimize my code, but it would be harder to read, and harder for me to add to over time by just adding another if statement to make a new enemy or item. I could split my scripts to minimize problems but I'd lose generality. I'm sure people smarter than me have dealt with these sorts of problems before, and have some solutions for them.
Any suggestions on what to do? Or any compiler optimizations in the pipe that will correct for my ham-handed programming?
10 or so FFCs are running a script that, each frame, runs through 10 or so if statements to determine what sort of creature it's supposed to be acting as. Then another 10 - 20 ifs depending on what it finds, and writing to the FFC's X, Y, data, and the ghosted enemy's X and Y.
At the same time, another script is checking, for every enemy on the screen, whether it is within eight pixels of a custom weapon, or on a line with certain beam-based weapons.
I can get slowdown in two situations:
1. Where there are upwards of 20ish enemies on the screen at once; and
2. Where I use 20ish or more FFCs running the custom SHMUP script mentioned above.
I'm a bare amateur when it comes to coding. I could optimize my code, but it would be harder to read, and harder for me to add to over time by just adding another if statement to make a new enemy or item. I could split my scripts to minimize problems but I'd lose generality. I'm sure people smarter than me have dealt with these sorts of problems before, and have some solutions for them.
Any suggestions on what to do? Or any compiler optimizations in the pipe that will correct for my ham-handed programming?