I mentioned using data arrays to create spreadshots in another thread. Here's the example:
Say you want a boss to fire this spread pattern:
Simple create a data array of nine integers, as long as the total number of waves of the shot. In this case it's
- Code: Select all
int fSpread[][]={{
0, 0, 0, 1, 0, 1, 0, 0, 0},{
0, 0, 1, 0, 1, 0, 1, 0, 0},{
0, 1, 0, 0, 1, 0, 0, 1, 0},{
0, 0, 0, 1, 0, 1, 0, 0, 0},{
0, 0, 0, 0, 1, 0, 0, 0, 0}};
int sWave=0;
Then write your firing loop, creating a shot at each position with a '1' in it.
- Code: Select all
void fSpreadShot(){
int j; int x1;
for(j=0; j<9; j++){
if(fSpread[sWave][j]==1){
x1=j*24;
CreateActor(shot etc, x1, y);
}
} //end j Loop
sWave++;
if(sWave==5){
sWave=0;
}
} //end fSpreadShot
Run this script at a regular interval and boom! The boss will fire spreadshots. You can add sine/cos values to the x and y to allow for the boss to fire them in a specific direction.
At any time, you can run this script with a different data array to make different spreadshots. If you make a [][][] array, you can store all your spreadshots in a big list. You can even use the first array of each array [][][thisone] to store the other values for the script, such as the interval, the type of shot or shot speed, etc. and simply start the 'sWave' on 1.
For extra control, 'sWave' variable in reverse, and write the data arrays the other direction. This way, when you create your data arrays, they will appear geometrically the same as the spread pattern does onscreen, if you catch my drift.
int happyface[][]={{
1, 1, 1,
0, 0, 0, 1, 1, 1},{
1, 1,
0, 1, 1, 1,
0, 1, 1},{
1,
0, 1,
0, 1,
0, 1,
0, 1},{
1,
0, 1, 1, 1, 1, 1,
0, 1},{
1,
0, 1,
0, 1,
0, 1,
0, 1},{
1, 1,
0, 1,
0, 1,
0, 1, 1},{
1, 1, 1,
0, 0, 0, 1, 1, 1}};