C-Dawg
01-16-2007, 12:43 AM
Here's a little code that spawns some enemies, once, when a combo on the screen becomes walkable. Of what use is such code?
You should ask Gemini Man.
http://users.sephiroth.ws/C-Dawg/zelda031.bmp
// ================================================== =====
// BUBBLE_SPAWNER = Spawns enemies at a particular X,Y coordinate when
// that coordinate becomes walkable. Spawns only once.
// D0 - The X coordinate to spawn.
// D1 - The Y coordinate to spawn.
// D2 - The enemy type to spawn.
// D3 - The number of enemies to spawn.
// ================================================== ====
ffc script bubble_spawner{
void run(int spawn_x, int spawn_y, int enemy_type, int num_enemies){
while(!canMove(spawn_x, spawn_y)){
Waitframe();
} // end of while loop
while(num_enemies >= 1){
npc spawnee = Screen->CreateNPC(enemy_type);
spawnee->X = spawn_x;
spawnee->Y = spawn_y;
num_enemies--;
} // end of while loop
} // end of void run
// ===================================
// Collision detection function
// ===================================
bool canMove(int x, int y){
// x=23, y=130
// Obviously in range...
if(x<0 || x>255 || y<0 || y>175)
return false;
int mask=1111b;
// x % 16 = 7, so
// mask = 1111 & 0011 = 0011
if(x%16<8)
mask&=0011b;
else
mask&=1100b;
// y % 16 = 2, so
// mask = 0011 & 0101 = 0001
if(y%16<8)
mask&=0101b;
else
mask&=1010b;
// All but the top-right quarter of the combo is solid, so ComboS = 1011
// mask & ComboS = 0001 & 1011 = 0001
// The result wasn't 0, so return false
return ((Screen->ComboS[ComboAt(x, y)]&mask)==0);
}// end of canMove
} // end of FFC script
You should ask Gemini Man.
http://users.sephiroth.ws/C-Dawg/zelda031.bmp
// ================================================== =====
// BUBBLE_SPAWNER = Spawns enemies at a particular X,Y coordinate when
// that coordinate becomes walkable. Spawns only once.
// D0 - The X coordinate to spawn.
// D1 - The Y coordinate to spawn.
// D2 - The enemy type to spawn.
// D3 - The number of enemies to spawn.
// ================================================== ====
ffc script bubble_spawner{
void run(int spawn_x, int spawn_y, int enemy_type, int num_enemies){
while(!canMove(spawn_x, spawn_y)){
Waitframe();
} // end of while loop
while(num_enemies >= 1){
npc spawnee = Screen->CreateNPC(enemy_type);
spawnee->X = spawn_x;
spawnee->Y = spawn_y;
num_enemies--;
} // end of while loop
} // end of void run
// ===================================
// Collision detection function
// ===================================
bool canMove(int x, int y){
// x=23, y=130
// Obviously in range...
if(x<0 || x>255 || y<0 || y>175)
return false;
int mask=1111b;
// x % 16 = 7, so
// mask = 1111 & 0011 = 0011
if(x%16<8)
mask&=0011b;
else
mask&=1100b;
// y % 16 = 2, so
// mask = 0011 & 0101 = 0001
if(y%16<8)
mask&=0101b;
else
mask&=1010b;
// All but the top-right quarter of the combo is solid, so ComboS = 1011
// mask & ComboS = 0001 & 1011 = 0001
// The result wasn't 0, so return false
return ((Screen->ComboS[ComboAt(x, y)]&mask)==0);
}// end of canMove
} // end of FFC script