Stonesword games
Member
My destructible terrain keeps shrinking to 1/4 its size and goes to the bottom left of where it was originally. Note: I'm a novice and got this code from a tutorial 
Heres the code
Create event:
HIT = false
damage_x = 0;
damage_y = 0;
Leftclick event:
var _mx = mouse_x - x;
var _my = mouse_y - y;
damage_x = _mx;
damage_y = _my;
HIT = true;
Draw Begin event:
if (HIT) {
var _temp_surf = surface_create(sprite_width, sprite_height);
surface_set_target(_temp_surf);
draw_sprite(sprite_index, 0, 0, 0);
gpu_set_blendmode(bm_subtract);
draw_set_color(c_black);
draw_circle(damage_x, damage_y, 12, false);
gpu_set_blendmode(bm_normal);
sprite_index = sprite_create_from_surface(_temp_surf, 0, 0, sprite_width, sprite_height, false, false, 0, 0);
surface_reset_target();
surface_free(_temp_surf);
sprite_collision_mask(sprite_index, false, 0, 0, 0, 0, 0, 0, 0)
HIT = false
}
Heres the code
Create event:
HIT = false
damage_x = 0;
damage_y = 0;
Leftclick event:
var _mx = mouse_x - x;
var _my = mouse_y - y;
damage_x = _mx;
damage_y = _my;
HIT = true;
Draw Begin event:
if (HIT) {
var _temp_surf = surface_create(sprite_width, sprite_height);
surface_set_target(_temp_surf);
draw_sprite(sprite_index, 0, 0, 0);
gpu_set_blendmode(bm_subtract);
draw_set_color(c_black);
draw_circle(damage_x, damage_y, 12, false);
gpu_set_blendmode(bm_normal);
sprite_index = sprite_create_from_surface(_temp_surf, 0, 0, sprite_width, sprite_height, false, false, 0, 0);
surface_reset_target();
surface_free(_temp_surf);
sprite_collision_mask(sprite_index, false, 0, 0, 0, 0, 0, 0, 0)
HIT = false
}