Here's my shooting formation for vertical space shooters; This takes your player's powerup level, a variable called 'power'(global, integer), and creates spread shots from it.
To use this, your shot must have this in its CreateActor>ScriptEditor:
- Code: Select all
- directional_velocity = 12; // or whatever you want your shotspeed to be
 angle = myburstangle; //sets angle based on the variable "myburstangle" (global, integer)
- Code: Select all
- void spreadshot(){ // creates function
 switch (power){
 case 1: //if power level is 1
 myburstangle = 90; //sets angle for the shot
 CreateActor("myshot", "doublegold", "no parent", "no path", 0, -15, false);
 //change the names to match your shot's name and animation names, and the x/y position to match
 //your ship. Notice how my animation names are descriptive of what that shot does...sidelaser etc.
 break;
 case 2:
 myburstangle = 90;
 CreateActor("myshot", "doublegold", "no parent", "no path", 0, -15, false);
 myburstangle = 60;
 CreateActor("myshot", "30goldr", "no parent", "no path", 0, -15, false);
 myburstangle = 120;
 CreateActor("myshot", "30goldl", "no parent", "no path", 0, -15, false);
 break;
 case 3:
 myburstangle = 90;
 CreateActor("myshot", "doublegold", "no parent", "no path", 10, -15, false);
 myburstangle = 90;
 CreateActor("myshot", "doublegold", "no parent", "no path", -10, -15, false);
 myburstangle = 60;
 CreateActor("myshot", "30goldr", "no parent", "no path", 0, -15, false);
 myburstangle = 120;
 CreateActor("myshot", "30goldl", "no parent", "no path", 0, -15, false);
 myburstangle = 45;
 CreateActor("myshot", "45laserr", "no parent", "no path", 0, -15, false);
 myburstangle = 135;
 CreateActor("myshot", "45laserl", "no parent", "no path", 0, -15, false);
 break;
 case 4:
 myburstangle = 90;
 CreateActor("myshot", "doublegold", "no parent", "no path", 10, -15, false);
 myburstangle = 90;
 CreateActor("myshot", "doublegold", "no parent", "no path", -10, -15, false);
 myburstangle = 60;
 CreateActor("myshot", "30goldr", "no parent", "no path", 0, -15, false);
 myburstangle = 120;
 CreateActor("myshot", "30goldl", "no parent", "no path", 0, -15, false);
 myburstangle = 45;
 CreateActor("myshot", "45laserr", "no parent", "no path", 0, -15, false);
 myburstangle = 135;
 CreateActor("myshot", "45laserl", "no parent", "no path", 0, -15, false);
 myburstangle = 0;
 CreateActor("myshot", "sidelaserr", "no parent", "no path", 10, 0, false);
 myburstangle = 180;
 CreateActor("myshot", "sidelaserl", "no parent", "no path", -10, 0, false);
 break;
 
 }
 
 
 }
Now in player 1's 'keydown', all you have to add is this:
- Code: Select all
- spreadshot();
Make sure player 1's power is set on collision with powerup; and reset on DestroyActor;
Hope this helps!