Okay, I realize some of you fan game designers don't use Game Maker, so I'll share the code too.
#define sakura_start
variable0 = variable3;
variable1 = variable0 << 4;
variable2 = 2;
switch variable0 //a switch is like a bunch of IFs
{
case 0: x = $30; break;
case 1: x = $F0; break;
case 2: x = $50; break;
case 3: x = $D0; break;
case 4: x = $70; break;
case 5: x = $B0; break;
case 6: x = $90; break;
case 7: x = $E0; break;
}
y = 0;
//If a view port is used, the coordinates need to be adjusted
if view_enabled
{
x += view_xview;
y = view_yview;
}
visible = 1;
This next code gets called every step.
#define sakura_fall
//The first part deals with a view port being used, otherwise it uses the other part.
if view_enabled
{
if x<view_xview || x>view_xview+view_wview
visible = 0;
if y<view_yview || y>view_yview+$F0
visible = 0;
}
else
{
if x<0 || x>room_width
visible = 0;
if y<0 || y>$F0
visible = 0;
}
//The $F0 should be changed based on the height of your rooms.
if sprite_index == -1 //Check if no sprite is assigned to the petal.
{
variable1 -= 1;
if variable1 > 0
exit;
sprite_index = spr_sakura;
}
else
{
if !visible
sakura_start();
variable2 -= 1;
if !variable2
{
variable0 = variable0 + 1 & 7;
switch variable0
{
case 0: case 6: variable2 = 2; break;
case 1: case 2: case 4: case 5: case 7: variable = 4; break;
case 3: variable2 = 8; break;
}
}
image_index = (variable0 & 3)+1>>2;
switch variable0
{
case 0: case 1: case 7: hspeed = -2; break;
case 2: case 6: hspeed = -1; break;
case 3: case 5: hspeed = 0; break;
case 4: hspeed = 1; break;
}
vspeed = 1 + (variable0 > 0);
}
The petals need to be created and run sakura_start using the following.
var X;
for (X = 0; X<8; X+=1)
with instance_create(0,0,obj_sakura)
{
variable3 = X;
sakura_start();
}