【GAMEMAKER】 MINER destroy sprite or object

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

global.toolspeed = 1
Step Event:
execute code:

//movement code
dx = (keyboard_check(vk_right) - keyboard_check(vk_left)) * 4;
dy = (keyboard_check(vk_down) - keyboard_check(vk_up)) * 4;
if place_free(x + dx, y + dy)//check if direction clear
{
    x += dx;//move 
    y += dy;
}

//create a block

if mouse_check_button_pressed(mb_right) && !position_meeting(mouse_x, mouse_y, obj_block)
&& !position_meeting(mouse_x, mouse_y, obj_hero)//check if positon empty
{
    instance_create(32 * (mouse_x div 32), 32 * (mouse_y div 32), obj_stone);//create stone
}


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

dury = 10;//strength
durc = 0;
Step Event:
execute code:

if mouse_check_button(mb_left) && position_meeting(mouse_x,mouse_y,id)
{
    if (dury == 0) exit;
    durc += global.toolspeed / dury;
    if (durc > 1) instance_destroy();
}
if mouse_check_button_released(mb_left)
{
    durc = 0;
}
Mouse Event for Mouse Leave:
execute code:

durc = 0
Draw Event:
execute code:

draw_sprite(sprite_index, image_index, x, y)
// cracking-texture
if (durc > 0)
{
    draw_sprite(spr_damage, floor(10 * durc), x, y);
}

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

event_inherited()
dury = 20

No comments:

When Bad People Make Good Art

I offer six guidelines on cancel culture ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏...

Contact Form

Name

Email *

Message *