Video game speed optimization (opinions wanted)
Posted on 2000-03-10
Okay, here's a long one. I'm working on a video game intended for the net. It will have a graphical client to display the placement of 45+ men on a field, amd the server will handle all calculations. It goes through a 45-person cycle to see what each guy is doing, once per round. The rounds are set so that he should run 1 foot per round, which would make it necessary to see him run 24 feet per second at a full bolt (meaning 24 cycles per second).
So far, even though not much AI has been added, the code seems to be running slowly. He (one of 45 in a cycle) is actually taking 45 seconds to run 30 feet at this time (or about 1.5 seconds per cycle). I'm running an AMD K6/2 400 w/64MB RAM on a nice fast ASUS 100MHz board. There are many loops and arrays (3D arrays at times), and the movement algorithms use some average trigonometry.
I've tried experimenting with the graphic optimizations, with a 0% improvement. See, even if 70% of the people aren't moving (therefore also not qualifying for any of my If statements, supposedly avoiding much code), they seem to be taking as much time as a character who is moving and thinking a lot. I'm using a timer control to try to get steady movement, but the interval is set to 5 milliseconds, which none of the cycles are qualifying for.
I guess I am not too familiar with what to expect from VB's speed, but it seems that many other similar applications are blowing away the speed of mine.
MY QUESTIONS: Since this is projected to run on a internet server, which should host many games simultaneously, will it automatically run better? Is there some way to build this code better (I've read many vague tutorials about common speed-wasting mistakes, and I don't have any in my code)? Does Visual C++ make a big difference? What are gamemakers doing to set this up, since they obviously don't have a lag anywhere NEAR this slow?
I don't think anybody will want to go into this at length, but what kind of experiences/opinions do you have? This seems slower by a long shot than my Atari Pac-Man game, circa 1981...
I know these are some difficult questions to answer, but I appreciate any ideas or theories you may be able to contribute.
Thanks in advance,