gamemaker gorilla, worms, angry bird type game

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

//set initial values
strength=0;
angle=0;
global.player=1;//set player to go first
Alarm Event for alarm 0:
execute code:

global.player=2;//allow next player to go
Step Event:
execute code:

if global.player==1//check if players go
{
    strength=distance_to_point(mouse_x,mouse_y)/50;//calculate strength based on distance to mouse
    angle=point_direction(x,y,mouse_x,mouse_y);//get the angle
    if mouse_check_button_released(mb_left)//do this when mouse released
    {
        bullet=instance_create(x,y,obj_bullet_1);//create a bullet and assign
        bullet.speed=strength;//set its speed
        bullet.direction=angle;//set direction
        global.player=0;//prevent shooting
        alarm[0]=room_speed*2;//start an alarm
        
    }
}

Draw Event:
execute code:

draw_self();
if global.player==1// do this if players go
{
    draw_text(x,y-40,"strength="+string(strength));
    draw_text(x,y-80,"angle="+string(angle));
    draw_line(x,y,mouse_x,mouse_y);
}

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

//set initial values
strength=0;
angle=0;

Alarm Event for alarm 0:
execute code:

global.player=1;//allow next player to go
Step Event:
execute code:

if global.player==2//check if players go
{
    strength=distance_to_point(mouse_x,mouse_y)/50;//calculate strength based on distance to mouse
    angle=point_direction(x,y,mouse_x,mouse_y);//get the angle
    if mouse_check_button_released(mb_left)//do this when mouse released
    {
        bullet=instance_create(x,y,obj_bullet_2);//create a bullet and assign
        bullet.speed=strength;//set its speed
        bullet.direction=angle;//set direction
        global.player=0;//prevent shooting
        alarm[0]=room_speed*2;//start an alarm
        
    }
}
Draw Event:
execute code:

draw_self();
if global.player==2// do this if players go
{
    draw_text(x,y-40,"strength="+string(strength));
    draw_text(x,y-80,"angle="+string(angle));
    draw_line(x,y,mouse_x,mouse_y);
}
Information about object: obj_bullet_1
Sprite: spr_bullet Solid: false Visible: true Depth: 0 Persistent: false Parent: Children: Mask:
No Physics Object
Step Event:
execute code:

vspeed=vspeed+0.02;//apply gravity effect
Collision Event with object obj_player_2:
execute code:

show_message("player 1 wins");
game_restart();
Information about object: obj_bullet_2
Sprite: spr_bullet Solid: false Visible: true Depth: 0 Persistent: false Parent: Children: Mask:
No Physics Object
Step Event:
execute code:

vspeed=vspeed+0.02;//apply gravity effect
Collision Event with object obj_player_1:
execute code:

show_message("player 2 wins");
game_restart();




No comments:

Top 3 UX Design Articles of 2024 to Remember

Based on most subscriptions ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­...

Contact Form

Name

Email *

Message *