Inheritance - Start using it!

It takes a long time to learn the ins and outs of ge.
Only recently have i begun to understand inheritance, and omg, i wish i'd known it from the start! This needs to be added to the wiki page (which is becoming a necessity more and more each day especially after this morning's bad spam post) and also to the inprogram tutorials.
INHERITANCE allows you to automate events for actors, it also automates the collision detection for those actors. So you don't have to write a 'collision>any side>playershot>' for each enemy anymore; just do it once!
This is SOOOOO simple!
Create an actor called enemy.
Give enemy actor 2 integer actor variables.
health
state
set state to 0 on createactor and health to whatever.
now on Collision>any side>playershot)
DO NOT PUT ACTUAL EFFECTS HERE! (No animpos/response stuff!!!!!!)
Setup your two variables instead!!!
Now add your first enemy. Lets say its green slime. On the inherit events from on the actor tab, choose enemy.
Now in green slime>draw Actor>
Now start the game, and shoot it! It responds to the shot, even though slime has no collision of its own, it inherits from enemy.
That's how you make games! (Now why did i have to use GE for three years before i learned this? Let's do the wiki, everybody!)
Now go forth, and make excellent games!!!!!!!!!!
Only recently have i begun to understand inheritance, and omg, i wish i'd known it from the start! This needs to be added to the wiki page (which is becoming a necessity more and more each day especially after this morning's bad spam post) and also to the inprogram tutorials.
INHERITANCE allows you to automate events for actors, it also automates the collision detection for those actors. So you don't have to write a 'collision>any side>playershot>' for each enemy anymore; just do it once!
This is SOOOOO simple!
Create an actor called enemy.
Give enemy actor 2 integer actor variables.
health
state
set state to 0 on createactor and health to whatever.
now on Collision>any side>playershot)
DO NOT PUT ACTUAL EFFECTS HERE! (No animpos/response stuff!!!!!!)
Setup your two variables instead!!!
- Code: Select all
{
state=1;
health-=collide.damage;
if(health<=0){
state=2;
}
Now add your first enemy. Lets say its green slime. On the inherit events from on the actor tab, choose enemy.
Now in green slime>draw Actor>
- Code: Select all
switch(state){
case 0:
//do your alives stuff here;
break;
case 1:
//do your getting hurt stuff here!, and a timer that resets state to 0.
break;
case 2:
//do your dying stuff here!
break;
}
Now start the game, and shoot it! It responds to the shot, even though slime has no collision of its own, it inherits from enemy.
That's how you make games! (Now why did i have to use GE for three years before i learned this? Let's do the wiki, everybody!)
Now go forth, and make excellent games!!!!!!!!!!