Step Event:
execute code:
///keypress code
if (keyboard_check(vk_left))
{
dir=player_state.left;
is_moving=true;
}
else
if (keyboard_check(vk_right))
{
dir=player_state.right;
is_moving=true;
}
else
if (keyboard_check(vk_up))
{
dir=player_state.up;
is_moving=true;
}
else
if (keyboard_check(vk_down))
{
dir=player_state.down;
is_moving=true;
}
else
{
is_moving=false;
}
execute code:
///movement
if is_moving
{
switch (dir)
{
case player_state.up:
if !position_meeting(x,y-4,obj_solid_base) y -= 4;
break;
case player_state.down:
if !position_meeting(x,y+4,obj_solid_base) y += 4;
break;
case player_state.left:
if !position_meeting(x-4,y,obj_solid_base) x -= 4;
break;
case player_state.right:
if !position_meeting(x+4,y,obj_solid_base) x += 4;
break;
}
}
depth=-y;
execute code:
///animation
if is_moving
{
switch (dir)
{
case player_state.up:
sprite_index=spr_walk_up;
break;
case player_state.down:
sprite_index=spr_walk_down;
break;
case player_state.left:
sprite_index=spr_walk_left;
break;
case player_state.right:
sprite_index=spr_walk_right;
break;
}
}
else
{
switch (dir)
{
case player_state.up:
sprite_index=spr_idle_up;
break;
case player_state.down:
sprite_index=spr_idle_down;
break;
case player_state.left:
sprite_index=spr_idle_left;
break;
case player_state.right:
sprite_index=spr_idle_right;
break;
}
}
execute code:
///dashing movement
dashing = keyboard_check(ord("D"));
if dashing_meter>1 && is_moving && dashing
{
if dir==player_state.left && !position_meeting(x-8,y,obj_solid_base) && !position_meeting(x-4,y,obj_solid_base)
{
effect_create_above(ef_star,x,y,1,c_red);
x-=8;
dashing_meter--;
}
if dir==player_state.right && !position_meeting(x+8,y,obj_solid_base) && !position_meeting(x+4,y,obj_solid_base)
{
effect_create_above(ef_star,x,y,1,c_red);
x+=8;
dashing_meter--;
}
if dir==player_state.up &&!position_meeting(x,y-8,obj_solid_base) && !position_meeting(x,y-4,obj_solid_base)
{
effect_create_above(ef_star,x,y,1,c_red);
y-=8;
dashing_meter--;
}
if dir==player_state.down && !position_meeting(x,y+8,obj_solid_base) && !position_meeting(x,y+4,obj_solid_base)
{
effect_create_above(ef_star,x,y,1,c_red);
y+=8;
dashing_meter--;
}
}
depth=-y;
Draw Event:
execute code:
draw_self();
//draw dash_meter
draw_set_colour(c_red);
draw_roundrect(x-51,y-76,x+51,y-69,false);
draw_set_colour(c_green);
draw_roundrect(x-50,y-75,x-50+dashing_meter,y-70,false);
Draw GUI Event:
execute code:
draw_text(50,50,"Hold Down D To Dash - Works When You Have Dash Meter HP");
Information about object: obj_cactus
Sprite: spr_cactus
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent: obj_elements_parent
Children:
Mask:
No Physics Object
Information about object: obj_flagSprite: spr_flag
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent: obj_elements_parent
Children:
Mask:
No Physics Object
Information about object: obj_mushroomSprite: spr_mushroom
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent: obj_elements_parent
Children:
Mask:
No Physics Object
Information about object: obj_elements_parentSprite:
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children
obj_cactus
obj_flag
obj_mushroom
Mask:
No Physics Object
Create Event:
execute code:
instance_create(x,y,obj_solid_base);
depth=-y;
Information about object: obj_solid_base
Sprite: spr_solid_base
Solid: false
Visible: false
Depth:
0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
No comments:
Post a Comment