pyrometal wrote:
-(1) either you make a new "create actor" script in the bear actor which resets the health value from 1 to 5 and hope that the later script is executed last so the hp value is overwritten to 5 (error prone + inefficient, if the opposite happens, hp will still be 1);
I wouldn't use that method.
pyrometal wrote:- or (3), you don't use inheritance and copy/paste a modified version of what you needed inside the template.
The purpose of the inheritance is twofold; One purpose is to make editing easier (not having to update scripts at several locations to change a game aspect). So i would avoid duplicating script whenever possible. The draw actor does not inherit as long as you have a separate draw actor for each enemy; which of course you would, because you want them to act uniquely and individually.
pyrometal wrote:- or (2), you create cumbersome actor type checking within the template actor to see which type of enemy is being created and set hp accordingly (inefficient);
This method would be simplest, if you remove the 'cumbersome' part.
1. Spawner creates enemies specifying the animation. The enemy will continue with this animation, as it is a complete spritesheet and is animated using variables in draw actor.
2. Enemy>CreateActor>
- Code: Select all
health=ehealth;
speed=espeed;
animpos=type;
3. The spawner (there is only one for the whole game) simply switches its variable 'monstertype' and sets the appropriate evariables when the monsterswitch rolls around. (so the cumbersome type checking only happens <20 times in one level).
pyrometal wrote: ...but it will cause almost every event to set some kind of flag to be used inside of the draw actor event, which may end up being more effort than simply having copy/pasted code in the first place
Enemies have very different draw actor scripts. They all use the same set of actor variables, which makes scripting them easier each time. I want the enemies to pop, and be unique!
The draw actor variable timeline makes a lot of sense. Its just like making a movie! Look at it this way:
Cycle start -----100fms -------130fms ------------------------- 320 fms
-----------------VarA Event
----------------------------------VarB Event
----------------------------------------------------------------------VarC Event
- Code: Select all
checkvar++;
if(checkvar==10){
vara++;
if(vara==100){
vara=0;
//perform action;
varb++;
if(varb==130){
vara=101;//now the vara event is disabled
varb=0;
//do this;
}
varc++;
if(varc==320){
vara=0;//turn vara back on
//perform action;
varc=0;
}
checkvar=0;
}
The entire script is only being run every 10th frame. I used a common factor of all the 'flag times' that i set.
This is actually very simple code, especially considering that there are only going to be 20 of these actors on screen at maximum, and only about 4 for the majority of the game.
Objects like bullets and fx are more numerous, but have even smaller scripts.
spark>draw actor>
- Code: Select all
transp+=.03;
if(transp==1){
DestroyActor("Event Actor");
}
The other purpose of inheritance is to simplify the computations. It is better to have an actor with a specific set of rules that acts on them; You don't want it making unecessary decisions on the fly.
So what a spawning script is , really, is taking the stored rules of the game, and outputting the slimmest possible object and inserting it into the game. If the game is calling for ninjas, we make ninjas. The ninjas do not know about samurai, they only know how to do ninja stuff.
When i make a shot, it simply uses creator.espread as its angle and creator.espeed as its speed. Referring to creator is one of the nice features of GE; its another way to use inheritance.
The final result of this is that i can inherit the basic behaviours so i don't have to rescript them each time; what i script each time is unique behaviour.
This results in the ability to take image directly out of graphics software, into ge, and immediately see your new enemy unit in action, which speeds up the creation process my many orders of magnitude.
There are many ways to success; as a design-oriented person, i look to create a space needle.
That is, if you wanted to set a guinness book of world records building height record, you don't need to build the massive world trade center type buildings. You can build a space needle building, and be competetive with only a tiny fraction of the resources. So tweaking the game and polishing it can make even the crappiest script shine.
Speed is of the essence. Without speed you won't be able to polish something to make it truly an EXPERIENCE for the end user. A GIFT to the user. Like a musician would.