2 things:
1. Using a 2dimensional array for all the actors in the game and all their attributes is much easier to manage. When you search for objects in a loop, you can ask for any aspect of that object; as in units[i][health], units[i][damage], etc. etc. The array in Nova Epic is 1000 x 44, thus 44 attributes per object.
This allows you to clone stats, as well, for instance, you may have a rate at which the unit checks something; but you may need another rate for it to check something else (in the case of a battlecruiser, with lasers, missiles, and bullets, you need to track up to three targets and store three damages and three firing rates). But when using defines, you don't have to reorder your array every time you add an attribute. Just throw it in the next empty slot and define that slot number with a viable word
i. e. units[i][rate1], units[i][rate2], and so forth. You can use empty slots for timers as well.
2.
Bee-Ant wrote:5. How you control the actor?for instance move up :
Actor-DrawActor :
You are asking a question each frame that only needs to be asked one time. If you are selected, do this. It only needs to be known on a mousebutton up. Asking it every frame, from multiple actors, doesn't make sense in an rts game.
This is the value of a command like moveto; why assign directional velocity over and over again each frame, or ask the unit to decide if it's arrived yet ? just use moveto and movefinish to tell it what to do.
And with the targeting, the function should return the actor state, like this:
Unit>Draw Actor>
switch(units[me][state]){
case 0:
state=findtarget(target1); //looks for a target for weapon 1, returns 1 on success, 0 on failure
break;
case 1:
state=attacktarget(target1); //attack the target; returns 1 if target still alive, 0 if target was destroyed
break;
}
You can then set that script to run based on a counter (to match the unit's response rate) so that, most of the time, the only thing all your units are doing is checking to see if their timer is ready, and only once every couple seconds do they have to find a target, fire an arrow, or do anything else at all.
This is how you get 1000's of units battling at once.
Then apply this logic to the arrows; the arrow itself has a moveto and movefinish! we don't need a collision, just hurt stuff when its done moving. Arrows move much faster than units anyway, if the units a few pixels over when it hits, so what? there's 1000's of units in battle. No one will notice.
If you look at starcraft, this is exactly how they do their shots.