【GAMEMAKER】Boss Battle

 Information about object: obj_pirate

Sprite: spr_pirate_idle
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

slot=4;
alarm[0]=global.game_speed;
alarm[1]=room_speed*5; //scatter bombs
alarm[2]=room_speed*8; //throw sword
alarm[3]=room_speed*10; //jump up
dir=choose("left","right");
Alarm Event for alarm 0:
execute code:

///drop a bomb / fruit & increase speed
global.game_speed--;
if global.game_speed<2 global.game_speed=2;
alarm[0]=global.game_speed;
drop=choose("bomb","fruit","fruit");
if drop=="bomb"
{
var bomb=instance_create(slot*64,120,obj_bomb);
bomb.direction=270;
bomb.speed=2;
//audio_play_sound(choose(snd_ar_1,snd_ar_2),1,false);
}
if drop=="fruit"
{
var fruit=instance_create(slot*64,120,obj_fruit);
fruit.direction=270;
fruit.speed=2;
//audio_play_sound(snd_bonus_coming,1,false);
}
execute code:

///reset alarm
alarm[0]=global.game_speed;
execute code:

///move
//weigh it to move away from edge
if slot==11 dir="left";
if slot==1 dir="right";
//choose next direction - wieghed to move in same direction
dir=choose("left","right",dir,dir);
if dir=="left"
{
image_xscale=-1;
slot--;

}
if dir=="right"
{
image_xscale=1;
slot++;
}
//keep in range
if slot<1 slot=1;
if slot>11 slot=11;


Alarm Event for alarm 1:
execute code:

///send bomb scatter
alarm[1]=room_speed*5;

var loop;
for (loop = 210; loop < 350; loop += 15)
{
//audio_play_sound(choose(snd_ar_3,snd_ar_4),1,false);
var bomb=instance_create(x,y,obj_scatter_bomb);
bomb.direction=loop;
bomb.speed=3;
}


Alarm Event for alarm 2:
execute code:

alarm[2]=room_speed*8; //throw sword
var sword=instance_create(x,y,obj_enemy_sword);
sword.direction=point_direction(x,y,obj_player.x,obj_player.y);
sword.speed=5;
Alarm Event for alarm 3:
execute code:

///jump up
sprite_index=spr_pirate_jump;
image_speed=0.5;
image_index=0;
alarm[3]=room_speed*10;
Step Event:
execute code:

///move to position slot
move_towards_point(64*slot,y,4);
//stop
if x==64*slot
{
dir="idle";
speed=0;
}

execute code:

///sprite control
if sprite_index==spr_pirate_jump && image_index>=15
{
sprite_index=spr_pirate_idle;
image_index=0;
image_speed=1;
}
Collision Event with object obj_player_sword:
execute code:

if sprite_index==spr_pirate_jump
{
global.enemyhp-=5;
//audio_play_sound(choose(snd_pirate_ouch_1,snd_pirate_ouch_2),1,false);
}
with (other) instance_destroy();
Information about object: obj_player_sword
Sprite: spr_sword_player
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

motion_set(180,1);
ang=0;//initial angle
sw=0;//for sine wave
move_angle=40;

Step Event:
execute code:

///rotate && check if outside room
sw += pi/30;//for sine wave - ie speed
angle=sin(sw) * move_angle;//for sine wave
image_angle=angle+225;

if y<0 instance_destroy();
Information about object: obj_bomb
Sprite: spr_bomb
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Step Event:
execute code:

if y>room_height instance_destroy();
Information about object: obj_player
Sprite: spr_player_left
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

slot=4;
idle=0;
left=1;
right=2
dir=left;
can_shoot=true;
Alarm Event for alarm 0:
execute code:

can_shoot=true;
Step Event:
execute code:

///movement && shoot
if keyboard_check_pressed(vk_left) && slot>1
{
slot--;
dir=left;
move_towards_point(64*slot,y,4);
}
if keyboard_check_pressed(vk_right) && slot<11
{
slot++;
dir=right;
move_towards_point(64*slot,y,4);
}

//keep in range
if slot<1 slot=1;
if slot>11 slot=11;

//stop
if x==64*slot
{
dir=idle;
speed=0;
}


//make a sword
if keyboard_check_pressed(vk_up) && can_shoot
{
can_shoot=false;
alarm[0]=room_speed;
var sword=instance_create(x,y,obj_player_sword);
sword.direction=90;
sword.speed=5;
}
execute code:

///animation
if dir=left sprite_index=spr_player_left;
if dir=right sprite_index=spr_player_right;
Collision Event with object obj_bomb:
execute code:

global.p1hp-=1;
//audio_play_sound(choose(snd_laugh_1,snd_laugh_2),1,false);
with(other) instance_destroy();

Collision Event with object obj_fruit:
execute code:

global.enemyhp-=1;
//audio_play_sound(snd_bonus,1,false);
with(other) instance_destroy();

Collision Event with object obj_scatter_bomb:
execute code:

global.p1hp-=1;
//audio_play_sound(choose(snd_ouch,snd_ouch_2,snd_ouch_3),1,false);
with(other) instance_destroy();
Collision Event with object obj_enemy_sword:
execute code:

global.p1hp-=5;
//audio_play_sound(snd_ouch_4,1,false);
with (other) instance_destroy();
Information about object: obj_fruit
Sprite: spr_fruit
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

irandom(image_number-1);
image_speed=0;
Step Event:
execute code:

if y>room_height instance_destroy();
Information about object: obj_scatter_bomb
Sprite: spr_bomb_mini
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Step Event:
execute code:

///destroy off screen
if y>room_height instance_destroy();
Information about object: obj_enemy_sword
Sprite: spr_sword_enemy
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

motion_set(180,1);
ang=0;//initial angle
sw=0;//for sine wave
move_angle=40;

Step Event:
execute code:

///rotate && check if outside room
sw += pi/30;//for sine wave - ie speed
angle= sin(sw) * move_angle;//for sine wave
image_angle=angle+45;

if y>room_height instance_destroy();
Information about object: obj_hud
Sprite:
Solid: false
Visible: true
Depth: 20
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Step Event:
execute code:

if global.p1hp<0
{
global.message="Enemy Wins"; // for gameover screen
room_goto(room_game_over);
}
if global.enemyhp<0
{
global.message="Player Wins"; // for gameover screen
room_goto(room_game_over);
}
Draw Event:
execute code:

draw_rectangle_colour(0, 0, room_width, room_height, c_blue, c_blue, c_white, c_white, false);
Draw GUI Event:
execute code:

///draw hp
//hp player
draw_rectangle_colour(334,10,334-(global.p1hp*2),30,c_green,c_red,c_red,c_green,false);
draw_set_colour(c_red);
draw_rectangle(334,10,334-200,30,true);
//draw enemy
draw_rectangle_colour(434,10,434+(global.enemyhp*2),30,c_red,c_green,c_green,c_red,false);
draw_set_colour(c_red);
draw_rectangle(434,10,434+200,30,true);

//draw text
draw_set_font(font_mini);
draw_set_colour(c_black);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_text(234,20,"Player HP");
draw_text(534,20,"Enemy HP");

draw_text(room_width/2,620,"Arrow Keys To Move And Fire - Shoot Enemy (when jumping)#Collect Fruit - Avoid Bombs");

Information about object: obj_splash
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

///set up
global.p1hp=100;
global.enemyhp=100;
global.game_speed=150;
room_goto(room_game);

Keyboard Event for <Left> Key:
execute code:

global.p1hp-=1;
Keyboard Event for <Right> Key:
execute code:

global.p1hp+=1;
Information about object: obj_game_over
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

alarm[0]=room_speed*5;
Alarm Event for alarm 0:
execute code:

game_restart();
Draw Event:
execute code:

draw_text(200,200,global.message);

No comments:

My New Favorite Music Genre Is Polish Noir

These 10 artists create music that is mystical, melancholy, magical, and more. ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏    ...

Contact Form

Name

Email *

Message *