function scr_floortex_setFloorLayers() { array_delete(layer_floor, 0, array_length(layer_floor)); if (argument_count > 0) { if (is_array(argument[0])) { for (var i = 0; i < array_length(argument[0]); i++) { var layid = layer_get_id(string(argument[0][i])); if (layer_exists(layid)) array_push(layer_floor, layid); } } else { for (var i = 0; i < argument_count; i++) { var layid = layer_get_id(string(argument[i])); if (layer_exists(layid)) array_push(layer_floor, layid); } } } } function scr_floortex_setWallLayers() { array_delete(layer_wall, 0, array_length(layer_wall)); if (argument_count > 0) { if (is_array(argument[0])) { for (var i = 0; i < array_length(argument[0]); i++) { var layid = layer_get_id(string(argument[0][i])); if (layer_exists(layid)) array_push(layer_wall, layid); } } else { for (var i = 0; i < argument_count; i++) { var layid = layer_get_id(string(argument[i])); if (layer_exists(layid)) array_push(layer_wall, layid); } } } } function scr_floortex_initialize() { if (variable_instance_exists(id, "init")) { } else { init = 1; x = xstart; y = ystart; init_spr = sprite_index; init_xscale = image_xscale; init_yscale = image_yscale; front = -4; back = -4; } draw_set_color(c_white); while (array_length(front_sprite) < frames) array_push(front_sprite, -4); while (array_length(back_sprite) < frames) array_push(back_sprite, -4); while (array_length(sprite) < frames) array_push(sprite, -4); boxTop = bbox_top; boxBottom = bbox_bottom; initHeight = sprite_height; initYscale = image_yscale; initBboxYdif = boxTop - boxBottom; var _sprite_index = sprite_index; var _sprite_height = sprite_height; var _tilesize = 40; var _w = sprite_width div _tilesize; var _h = sprite_height div _tilesize; var _yorigin = _sprite_height / 2; switch (_sprite_index) { case 745: _yorigin = 40; break; case 8002: _yorigin = _sprite_height - 40; break; case 5754: _yorigin = 0; break; case 5056: _yorigin = _sprite_height; break; } var _centerLine = instance_place(x, y, obj_plat_floortex_Yorigin); if (instance_exists(_centerLine)) _yorigin = _centerLine.y - bbox_top; if (surface_method) { surface_width = _w; surface_height = _h; surface_x = x; surface_y = bbox_top; } for (var _layer = 0; _layer < array_length(layer_floor); _layer++) { var lay_id = layer_floor[_layer]; if (layer_exists(lay_id)) layer_set_visible(lay_id, false); } for (var _layer = 0; _layer < array_length(layer_wall); _layer++) { var lay_id = layer_wall[_layer]; if (layer_exists(lay_id)) layer_set_visible(lay_id, false); } frame = 0; frame_time = 5; frame_timer = frame_time; y_plat = y; y_ow = y; var anchor_y = y; if (surface_method || sprite[0] == -4) { image_xscale = sprite_width; image_yscale = sprite_height; sprite_index = spr_pxwhite; y = boxTop + 0; anchor_y = y + _yorigin; y_ow = y; y_plat = anchor_y - (0.1 * _yorigin); } else if (sprite[0] != -4) { y_plat = (bbox_top + _yorigin) - (0.1 * _yorigin); var sw = sprite_width; var sh = sprite_height; sprite_index = sprite[0]; y = boxTop + sprite_get_yoffset(sprite[0]); image_xscale = 2; image_yscale = 2; y_ow = boxTop; if (round((sprite_width - sw) * 100) != 0 || round((sprite_height - sh) * 100) != 0) { blend = c_red; scr_debug_print("Mismatched-main at: x" + string(xstart) + " y" + string(ystart)); scr_debug_print(string(sprite_width) + ";" + string(sw)); scr_debug_print(string(sprite_height) + ";" + string(sh)); } anchor_y = y + _yorigin; } front_col = 16777215; back_col = 16777215; yscale_ow = image_yscale; yscale_plat = image_yscale * 0.1; var _list = ds_list_create(); var _num = collision_rectangle_list(bbox_left + 2, anchor_y - 1, bbox_right - 2, anchor_y + 1, obj_plat_floortex_Yplat, 0, 0, _list, 0); var _offset_obj = -4; for (var i = 0; i < _num; i++) { if (instance_exists(ds_list_find_value(_list, i))) { with (ds_list_find_value(_list, i)) { if (x == clamp(x, other.bbox_left, other.bbox_right) && y == clamp(y, anchor_y - 2, anchor_y + 2)) { _offset_obj = id; } else { } } } } if (_num == 0) { } if (instance_exists(_offset_obj)) y_plat -= (sign(_offset_obj.image_yscale) * abs(_offset_obj.sprite_height)); if (sprite[0] != -4) { y_plat_anchor = y_plat + (0.1 * (y - bbox_top)); } else { } image_speed = 0; bbox_bottom_ow = bbox_bottom; bbox_top_ow = bbox_top; image_yscale = yscale_plat; y = y_plat; bbox_bottom_plat = bbox_bottom; bbox_top_plat = bbox_top; y = y_ow; image_yscale = yscale_ow; y_ow_anchor = anchor_y; if (array_length(wall_layers) == 0) exit; ds_list_clear(_list); var _front = -4; _num = collision_line_list(x + 2, boxBottom + 20, bbox_right - 2, boxBottom + 20, obj_plat_floortex_FRONT, 0, 0, _list, 1); for (var i = 0; i < _num; i++) { var _obj = ds_list_find_value(_list, i); if (instance_exists(_obj)) { if (round(_obj.bbox_top) == round(bbox_bottom + 1)) _front = _obj.id; } } ds_list_destroy(_list); if (instance_exists(_front)) front = _front; if (instance_exists(front)) { with (front) { if (variable_instance_exists(id, "init")) { sprite_index = init_spr; image_xscale = init_xscale; image_yscale = init_yscale; } else { init = 1; init_spr = sprite_index; init_xscale = image_xscale; init_yscale = image_yscale; } floortex = other.id; other.front_col = blend; if (other.front_sprite[0] == -4) { visible = 0; } else { var sw = sprite_width; var sh = sprite_height; sprite_index = other.front_sprite[0]; image_xscale = 2; image_yscale = 2; other.front_width = sprite_width * 1; other.front_height = sprite_height * 1; other.front_x = x; other.front_starty = bbox_top; if (round((sprite_width - sw) * 100) != 0 || round((sprite_height - sh) * 100) != 0) { other.front_col = 255; scr_debug_print("Mismatched-front at: x" + string(xstart) + " y" + string(ystart)); scr_debug_print(string(sprite_width) + ";" + string(sw)); scr_debug_print(string(sprite_height) + ";" + string(sh)); } other.cull_buffer_left = max(other.cull_buffer_left, other.bbox_left - bbox_left); other.cull_buffer_right = max(other.cull_buffer_right, bbox_right - other.bbox_right); other.cull_buffer_bottom = max(other.cull_buffer_bottom, bbox_bottom - other.bbox_bottom); visible = 0; } } } var _back = collision_line(x + 2, boxTop - 20, bbox_right - 2, boxTop - 20, obj_plat_floortex_BACK, 0, 0); if (instance_exists(_back)) back = _back; if (instance_exists(back)) { with (back) { if (variable_instance_exists(id, "init")) { sprite_index = init_spr; image_xscale = init_xscale; image_yscale = init_yscale; } else { init = 1; init_spr = sprite_index; init_xscale = image_xscale; init_yscale = image_yscale; } floortex = other.id; other.back_col = blend; if (other.back_sprite[0] == -4) { visible = 0; } else { var sw = sprite_width; var sh = sprite_height; sprite_index = other.back_sprite[0]; image_xscale = 2; image_yscale = 2; if (round((sprite_width - sw) * 100) != 0 || round((sprite_height - sh) * 100) != 0) { other.back_col = 255; scr_debug_print("Mismatched-back at: x" + string(xstart) + " y" + string(ystart)); scr_debug_print(string(sprite_width) + ";" + string(sw)); scr_debug_print(string(sprite_height) + ";" + string(sh)); } other.back_width = sprite_width; other.back_height = sprite_height; other.back_x = x; other.back_starty = bbox_top; other.cull_buffer_left = max(other.cull_buffer_left, other.bbox_left - bbox_left); other.cull_buffer_right = max(other.cull_buffer_right, bbox_right - other.bbox_right); other.cull_buffer_top = max(other.cull_buffer_top, other.bbox_top - bbox_top); visible = 0; } } } } function scr_floortex_generate() { if (variable_instance_exists(id, "init")) { sprite_index = init_spr; image_xscale = init_xscale; image_yscale = init_yscale; x = xstart; y = ystart; } else { init = 1; x = xstart; y = ystart; init_spr = sprite_index; init_xscale = image_xscale; init_yscale = image_yscale; front = -4; back = -4; } draw_set_color(c_white); boxTop = bbox_top; boxBottom = bbox_bottom; initHeight = sprite_height; initYscale = image_yscale; initBboxYdif = boxTop - boxBottom; var _sprite_index = sprite_index; var _sprite_height = sprite_height; var _tilesize = 40; var _w = sprite_width div _tilesize; var _h = sprite_height div _tilesize; if (surface_method) { surface_width = _w; surface_height = _h; surface_x = x; surface_y = bbox_top; for (var _layer = 0; _layer < array_length(layer_floor); _layer++) { var lay_id = layer_floor[_layer]; if (layer_exists(lay_id)) layer_set_visible(lay_id, false); } for (var _layer = 0; _layer < array_length(layer_wall); _layer++) { var lay_id = layer_wall[_layer]; if (layer_exists(lay_id)) layer_set_visible(lay_id, false); } } frame = 0; frame_time = 5; frame_timer = frame_time; for (var i = 0; i < frames; i++) { front_sprite[i] = -4; sprite[i] = -4; back_sprite[i] = -4; } front_col = 16777215; back_col = 16777215; var _sw = round(sprite_width); var _sh = round(sprite_height); var temp_surface = surface_create(_sw, _sh); var _yorigin = _sprite_height / 2; switch (_sprite_index) { case 745: _yorigin = 40; break; case 8002: _yorigin = _sprite_height - 40; break; case 5754: _yorigin = 0; break; case 5056: _yorigin = _sprite_height; break; } var _centerLine = instance_place(x, y, obj_plat_floortex_Yorigin); if (instance_exists(_centerLine)) _yorigin = _centerLine.y - bbox_top; if (_yorigin < (_sprite_height / 2)) align_mode = -1; else if (_yorigin > (_sprite_height / 2)) align_mode = 1; for (var _frame = 0; _frame < frames; _frame++) { sprite[_frame] = -4; if (!surface_method) { surface_set_target(temp_surface); draw_clear_alpha(c_black, 0); gpu_set_blendmode_ext(bm_one, bm_inv_src_alpha); for (var i = 0; i < _w; i++) { for (var j = 0; j < _h; j++) { var _x = x + (i * _tilesize); var _y = bbox_top + (j * _tilesize); if (_y >= room_height) _y = room_height - _tilesize; if (_y < 0) _y = 0; for (var _layer = 0; _layer < array_length(layer_floor); _layer++) { var lay_id = layer_floor[_layer]; if (layer_exists(lay_id)) { layer_set_visible(lay_id, false); var map_id = scr_layer_tilemap_get_id_fixed(lay_id); var _tx = tilemap_get_cell_x_at_pixel(map_id, _x, _y); var _ty = tilemap_get_cell_y_at_pixel(map_id, _x, _y); var _tiledata = tilemap_get(map_id, _tx, _ty); if (_tiledata > 0) { skip_main_export = false; var _tileset = tilemap_get_tileset(map_id); draw_tile(_tileset, _tiledata, _frame, i * _tilesize, j * _tilesize); } } } } } gpu_set_blendmode(bm_normal); surface_reset_target(); var small_surface = surface_create(0.5 * _sw, 0.5 * _sh); surface_set_target(small_surface); gpu_set_blendenable(false); draw_clear_alpha(c_black, 0); draw_surface_stretched(temp_surface, 0, 0, 0.5 * _sw, 0.5 * _sh); gpu_set_blendenable(true); surface_reset_target(); surface_free(temp_surface); temp_surface = small_surface; } sprite[_frame] = sprite_create_from_surface(temp_surface, 0, 0, _sw * 0.5, _sh * 0.5, 0, 0, 0, _yorigin * 0.5); sprite_set_bbox_mode(sprite[_frame], 1); } surface_free(temp_surface); sprite_index = sprite[0]; y = boxTop + (sprite_get_yoffset(sprite[0]) * 2); image_xscale = 2; image_yscale = 2; yscale_ow = image_yscale; yscale_plat = image_yscale * 0.1; y_plat = y; y_ow = y; var _list = ds_list_create(); var _num = collision_rectangle_list(bbox_left + 2, y - 1, bbox_right - 2, y + 1, obj_plat_floortex_Yplat, 0, 0, _list, 0); var _offset_obj = -4; for (var i = 0; i < _num; i++) { if (instance_exists(ds_list_find_value(_list, i))) { with (ds_list_find_value(_list, i)) { if (x == clamp(x, other.bbox_left, other.bbox_right) && y == clamp(y, other.y - 2, other.y + 2)) _offset_obj = id; } } } if (instance_exists(_offset_obj)) y_plat = _offset_obj.y - (sign(_offset_obj.image_yscale) * abs(_offset_obj.sprite_height)); image_speed = 0; bbox_bottom_ow = bbox_bottom; bbox_top_ow = bbox_top; image_yscale = yscale_plat; y = y_plat; bbox_bottom_plat = bbox_bottom; bbox_top_plat = bbox_top; y = y_ow; image_yscale = yscale_ow; y_plat_anchor = y_plat; y_ow_anchor = y_ow; if (array_length(wall_layers) == 0) exit; var _wall_maps = []; if (array_length(layer_wall) > 0) { for (var i = 0; i < array_length(layer_wall); i++) { var _lay_id = layer_wall[i]; if (layer_exists(_lay_id)) { layer_set_visible(_lay_id, false); array_push(_wall_maps, scr_layer_tilemap_get_id_fixed(_lay_id)); } } } ds_list_clear(_list); var _front = -4; _num = collision_line_list(x + 2, bbox_bottom + 20, bbox_right - 2, bbox_bottom + 20, obj_plat_floortex_FRONT, 0, 0, _list, 1); for (var i = 0; i < _num; i++) { var _obj = ds_list_find_value(_list, i); if (instance_exists(_obj)) { if (round(_obj.bbox_top) == round(bbox_bottom + 1)) _front = _obj.id; } } ds_list_destroy(_list); if (instance_exists(_front)) front = _front; if (instance_exists(front)) { with (front) { if (variable_instance_exists(id, "init")) { sprite_index = init_spr; image_xscale = init_xscale; image_yscale = init_yscale; } else { init = 1; init_spr = sprite_index; init_xscale = image_xscale; init_yscale = image_yscale; } floortex = other.id; other.front_col = blend; _tilesize = 40; _w = sprite_width div _tilesize; _h = sprite_height div _tilesize; _sw = round(sprite_width); _sh = round(sprite_height); temp_surface = surface_create(_sw, _sh); for (var _frame = 0; _frame < other.frames; _frame++) { other.front_sprite[_frame] = -4; if (!(other.surface_method && other.draw_all_surfaces)) { surface_set_target(temp_surface); draw_clear_alpha(c_black, 0); gpu_set_blendmode_ext_sepalpha(bm_one, bm_inv_src_alpha, bm_one, bm_one); for (var i = 0; i < _w; i++) { for (var j = 0; j < _h; j++) { var _x = x + (i * _tilesize); var _y = bbox_top + (j * _tilesize); if (_y >= room_height) _y = room_height - _tilesize; if (_y < 0) _y = 0; var _len = array_length(_wall_maps); for (var m = 0; m < _len; m++) { var map_id = _wall_maps[m]; var _tx = tilemap_get_cell_x_at_pixel(map_id, _x, _y); var _ty = tilemap_get_cell_y_at_pixel(map_id, _x, _y); var _tiledata = tilemap_get(map_id, _tx, _ty); if (_tiledata > 0) { other.skip_front_export = false; var _tileset = tilemap_get_tileset(map_id); draw_tile(_tileset, _tiledata, _frame, i * _tilesize, j * _tilesize); } } } } gpu_set_blendmode(bm_normal); shader_replace_simple_reset_hook(); surface_reset_target(); var small_surface = surface_create(0.5 * _sw, 0.5 * _sh); surface_set_target(small_surface); gpu_set_blendenable(false); draw_clear_alpha(c_black, 0); draw_surface_stretched(temp_surface, 0, 0, 0.5 * _sw, 0.5 * _sh); gpu_set_blendenable(true); surface_reset_target(); surface_free(temp_surface); temp_surface = small_surface; } other.front_sprite[_frame] = sprite_create_from_surface(temp_surface, 0, 0, _sw * 0.5, _sh * 0.5, 0, 0, 0, 0); sprite_set_bbox_mode(other.front_sprite[_frame], 1); } surface_free(temp_surface); sprite_index = other.front_sprite[0]; image_xscale = 2; image_yscale = 2; other.front_width = sprite_width * 1; other.front_height = sprite_height * 1; other.front_x = x; other.front_starty = bbox_top; other.cull_buffer_left = max(other.cull_buffer_left, other.bbox_left - bbox_left); other.cull_buffer_right = max(other.cull_buffer_right, bbox_right - other.bbox_right); other.cull_buffer_bottom = max(other.cull_buffer_bottom, bbox_bottom - other.bbox_bottom); visible = 0; } } var _back = collision_line(x + 2, bbox_top - 20, bbox_right - 2, bbox_top - 20, obj_plat_floortex_BACK, 0, 0); if (instance_exists(_back)) back = _back; if (instance_exists(back)) { with (back) { if (variable_instance_exists(id, "init")) { sprite_index = init_spr; image_xscale = init_xscale; image_yscale = init_yscale; } else { init = 1; init_spr = sprite_index; init_xscale = image_xscale; init_yscale = image_yscale; } floortex = other.id; other.back_col = blend; _tilesize = 40; _w = sprite_width div _tilesize; _h = sprite_height div _tilesize; _sw = round(sprite_width); _sh = round(sprite_height); temp_surface = surface_create(_sw, sprite_height); for (var _frame = 0; _frame < other.frames; _frame++) { other.back_sprite[_frame] = -4; if (!(other.surface_method && other.draw_all_surfaces)) { surface_set_target(temp_surface); draw_clear_alpha(c_black, 0); for (var i = 0; i < _w; i++) { for (var j = 0; j < _h; j++) { var _x = x + (i * _tilesize); var _y = bbox_top + (j * _tilesize); if (_y >= room_height) _y = room_height - _tilesize; if (_y < 0) _y = 0; var _len = array_length(_wall_maps); for (var m = 0; m < _len; m++) { var map_id = _wall_maps[m]; var _tx = tilemap_get_cell_x_at_pixel(map_id, _x, _y); var _ty = tilemap_get_cell_y_at_pixel(map_id, _x, _y); var _tiledata = tilemap_get(map_id, _tx, _ty); if (_tiledata > 0) { other.skip_back_export = false; var _tileset = tilemap_get_tileset(map_id); draw_tile(_tileset, _tiledata, _frame, i * _tilesize, j * _tilesize); } } } } surface_reset_target(); var small_surface = surface_create(0.5 * _sw, 0.5 * _sh); surface_set_target(small_surface); gpu_set_blendenable(false); draw_clear_alpha(c_black, 0); draw_surface_stretched(temp_surface, 0, 0, 0.5 * _sw, 0.5 * _sh); gpu_set_blendenable(true); surface_reset_target(); surface_free(temp_surface); temp_surface = small_surface; } other.back_sprite[_frame] = sprite_create_from_surface(temp_surface, 0, 0, _sw * 0.5, _sh * 0.5, 0, 0, 0, 0); sprite_set_bbox_mode(other.back_sprite[_frame], 1); } surface_free(temp_surface); sprite_index = other.back_sprite[0]; image_xscale = 2; image_yscale = 2; other.back_width = sprite_width; other.back_height = sprite_height; other.back_x = x; other.back_starty = bbox_top; other.cull_buffer_left = max(other.cull_buffer_left, other.bbox_left - bbox_left); other.cull_buffer_right = max(other.cull_buffer_right, bbox_right - other.bbox_right); other.cull_buffer_top = max(other.cull_buffer_top, other.bbox_top - bbox_top); visible = 0; } } }