【GAMEMAKER】Multiple Location

 Information about object: obj_player

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

///set up
enum player_state {
    idle,
    up,
    down,
    left,
    right
    }

dir=player_state.down;
is_moving=false;
image_speed=0.5;
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:
        y -= 4;
        break;

        case player_state.down:
        y += 4;
        break;

        case player_state.left:
        x -= 4;
        break;
   
        case player_state.right:
        x += 4;
        break;
    }
}
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:
        player_state=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;
    }
}

Collision Event with object obj_church_enter:
execute code:

y+=150;//move away from door to prevent looping 
room_goto(room_church);


Collision Event with object obj_church_leave:
execute code:

y+=150;//move away from door to prevent looping
room_goto(room_main_level);
Collision Event with object obj_chest:
execute code:

global.gold++;
with (other) instance_destroy();
Draw Event:
execute code:

draw_self();
draw_text(x,y-100,global.gold);
Information about object: obj_church_enter
Sprite: spr_door
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object

Information about object: obj_church_leave
Sprite: spr_door
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Information about object: obj_church
Sprite: spr_church
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object

Information about object: obj_chest
Sprite: spr_chest
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
global.gold=0; room_goto(room_main_level);



No comments:

Renowned Water Expert Reynold Aquino Offers Exclusive Water Softener Discounts

Los Angeles, California - November 21, 2024 - World-renowned water expert Reynold Aquino is excited to announce exclusive discounts on prem...

Contact Form

Name

Email *

Message *