Hey! I'm an amateur flash developer, and I've been working on a heavily actionscript reliant game for the past few months. I've pretty much completed the game engine so far, and the end product is quite amusing. However, I'm running into a few problems at this stage of development, and would really appreciate some help.
These problems mainly pertain to the game pretty much slogging down into a mind-numbingly slow framerate in heated combat.
First let me talk about the structure of the game.
The game is basically a top-down space dogfighting simulation entitled - The Echo Path: Progenesis (relates to a book I'm trying to write, but thats mostly just backstory)
You can play the latest version of the engine at: www.feel-the-burn.co..ersonal/fighter.html
The controls are:
ARROW KEYS - Movement
SPACE - Fire Primary (projectile) Weapon
CTRL - Launch tracking beacon (hit an enemy and wait for a lockon, only one enemy can be tracked at a time)
Z - Toggle Primary Weapon
X - Toggle Secondary Weapon
C - Fire Secondary (Missile) Weapon (Note that Huntress and Starburst missiles require a lockon)
B - EMP burst - Destroys all nearby enemy missiles
TAB - Toggle on/off automatic shield regeneration (consumes power)
To spawn entities, click on one of the gold boxes situated on the top left hand corner of the screen. The buttons spawn, in respective order:
Enemies: Intercepter, Bomber, Hunter, Destroyer, Cruiser, Carrier (launches 5 intercepters)
Allies: Seraphim Fighter, Gun Turrent, Seraphim Carrier (has 2 gun turrents)
The bottom two buttons test the objective system and clean up all entities in play respectively.
Try spawning a fleet of enemies and allies and observe the AI code in action.
After experimenting with this game, I find that if I have anything more than four or five entities in play at once, I experience a slowdown in the frame rate. I'm not sure what might be causing it, but some suggestions are:
My Code Structure:
Basically how my game works is that entities are duplicated from a large bank of movie clips that are placed on the stage out of view. Each of these movie clips has large amount of code, including loops checking for collisions with projectile movie clips, code pertaining to an array() with details of all ally and enemy units in play for tracking. However, I can't think of how to reduce this code without comprimising the game engine.
Graphics:
Theres is minimal animation in this game, most movement is actionscript based, so I doubt if it's a graphical issue.
Exhaust Trails:
In order to make an exhaust trail effect for the ships and missiles, I duplicateMovieClip a fading gradiented circle that is positioned at the rear of each fighter and missile. This of course creates many movie clips each frame. I've thought of using draw tools to make a cleaner trail, but I have no idea how to do that.
Relative Positioning:
In order to keep my fighter at the center of the screen, everything else except for the fighter moves when the engine thrust is on. This is accomplished by everything having a relativemove() function that adds/subtracts to the clips x and y values according to the direction and supposed velocity of your ship.
Are there any suggestions that anyone can give me to help me optimise the code for better performance? Are there any programs that will help optimise the code?
If anyone is kind enough to take a look at the code and the .fla file, or help in any manner please contact me at sunderx@gmail.com.