Apr 2, 2013

Think my "state machine" style is obsolete in this day-and-age? Here's a code I typed up on the fly for someone to simulate a boss battle somewhat reminiscent of Dracula's first form. It's just the movement code, which is all that really matters anyway:

switch alarm[0]
{
case 0:
image_xscale=sign(player.x-x);
sprite_index=boss_arms_up;
alarm[1]=0;
alarm[0]++;
break;
 
case 1:
alarm[1] ++;
visible = alarm[1] & 1;
if alarm[1] == 30
alarm[0]++;
break;
 
case 2:
visible = 0;
x = view_xview+choose(24,48,64,96,112,132,164,180,208,232);
alarm[1] = 16;
alarm[0]++;
break;
 
case 3:
alarm[1]--;
image_xscale = sign(player.x-x);
alarm[0]+=!alarm[1];
break;
 
case 4:
alarm[1]++;
visible = alarm[1] & 1;
if alarm[1] == 20
alarm[0]++;
break;
 
case 5:
visible = 1;
with (instance_create(x+8*image_xscale,y,obj_FireWave))
hspeed = sign(player.x-x) * 2;
alarm[1] = 10;
alarm[0] ++
break;
 
case 6:
alarm[1]--;
if !alarm[1]
{
sprite_index = boss_arms_down;
alarm[0]++;
}
break;
 
case 7:
alarm[1] = 10;
alarm[0]++;
break;
 
case 8:
alarm[1]--;
if !alarm[1]
alarm[0]=0;
break;
}

No comments:

Post a Comment

©TheouAegis Productions™. Powered by Blogger.