if (inv_visible) { var _inv_y_span = obj_camera.height - inv_slot_size * inv_height; var _cor_x = (obj_camera.width - inv_slot_size * inv_width) / 2; var _cor_y = -obj_camera.y_offset + _inv_y_span / 2 - 64; var _inv_x = x - obj_camera.x + _cor_x; var _inv_y = y - obj_camera.y + _cor_y; if (mouse_check_button_pressed(mb_left)) { var _gmx = floor((mouse_x + obj_camera.width / 2 - obj_camera.x - _inv_x) / inv_slot_size); var _gmy = floor((mouse_y + obj_camera.height / 2 - obj_camera.y - _inv_y) / inv_slot_size); if (median(_gmx, 0, inv_width) == _gmx && median(_gmy, 0, inv_height) == _gmy) { var _drop = inv[# _gmx, _gmy]; if (_drop) { inv[# _gmx, _gmy] = 0; inv_filled--; textbox_add("Dropped " + ore_name[_drop], -1, true); } } } draw_set_alpha(.84); for (var _y = 0; _y < inv_height; _y++) { for (var _x = 0; _x < inv_width; _x++) { draw_set_color(_y * inv_width + _x < inv_slots ? $471a24 : $240b87); draw_rectangle(_inv_x + inv_slot_size * _x + 1, _inv_y + inv_slot_size * _y + 1, _inv_x + inv_slot_size * (_x+1) - 2, _inv_y + inv_slot_size * (_y+1) - 2, false); var _cell = inv[# _x, _y]; if (_cell > 0) { draw_sprite(ore_sprite[_cell], 0, _inv_x + inv_slot_size * _x, _inv_y + inv_slot_size * _y); } } } var _xoff = 4; var _size = 32; var _w = _size * 2.4; var _i = 0; for (var i = 0; i < item_count; i++) _i += item[i] && 1; if (_i) { draw_rectangle(_inv_x + inv_width * inv_slot_size + 1, _inv_y + 1, _inv_x + inv_width * inv_slot_size + _w, _inv_y + _i * _size - 1, false); } draw_set_alpha(1); draw_set_color(c_white); draw_set_halign(fa_right); draw_set_valign(fa_middle) var _i = 0; for (var i = 0; i < item_count; i++) { if (item_sprite[i] + 1 && item[i]) { var _x = _inv_x + inv_width * inv_slot_size + _xoff; var _y = _inv_y + _i++ * _size; draw_sprite(item_sprite[i], 0, _x, _y); draw_sprite(spr_x, 0, _x + _size + 3, _y + _size / 2); draw_text(_x + _w * .9, _y + _size / 2, string(item[i])); } } draw_set_halign(fa_left); draw_set_valign(fa_top);} if (!surface_exists(gui_surf)) gui_surf = surface_create(obj_camera.width, obj_camera.height); surface_set_target(gui_surf); draw_clear_alpha(hit_timer > 0 ? c_red : c_white, hit_timer / hit_time); var _hullpx, _shrink; var _y = 2; var _x = 2; var _fh = string_height("OUADBynbasdnio/") + 2; if (hull > 0) { _hullpx = ((hull - 2.4) / (hull_max - 2.4)) * 19; _shrink = min(hull, 3) / 3; if (_shrink == 1) draw_sprite_ext(spr_hull_bar, 1, _x, _y, _shrink, _shrink, 0, c_white, 1); if (_shrink == 1) draw_sprite_ext(spr_hull_bar, 2, _x, _y + 28, 1, -(hull / hull_max) * .7, 0, c_white, 1); draw_sprite_ext(spr_hull_bar, 3, _x + (1 - _shrink) * 16, _y + (1 - _shrink) * 28 - _hullpx + (1 - _shrink), _shrink, _shrink, 0, c_white, 1); } draw_sprite(spr_hull_bar, 0, _x, _y); _x += 30; if (fuel > 0) { _hullpx = ((fuel - 2.4) / (fuel_max - 2.4)) * 19; _shrink = min(fuel, 3) / 3; if (_shrink == 1) draw_sprite_ext(spr_fuel_bar, 1, _x, _y, _shrink, _shrink, 0, c_white, 1); if (_shrink == 1) draw_sprite_ext(spr_fuel_bar, 2, _x, _y + 28, 1, -(fuel / fuel_max) * .7, 0, c_white, 1); draw_sprite_ext(spr_fuel_bar, 3, _x + (1 - _shrink) * 16, _y + (1 - _shrink) * 28 - _hullpx + (1 - _shrink), _shrink, _shrink, 0, c_white, 1); } draw_sprite(spr_fuel_bar, 0, _x, _y); _x = 2; _y += 32; draw_text(_x, _y, "Depth: " + string(-ceil(y / 6.4)) + "ft"); _y += _fh; draw_text(_x, _y, "$ " + string(money)); _y += _fh; surface_reset_target(); draw_surface_ext(gui_surf, 0, 0, 1, 1, 0, c_white, sprite_index == spr_explosion ? 1 - image_index / image_number : 1); if (state == state_player_death) var _xoff = obj_camera.width - 32 - (obj_camera.x / (chunk_width * grid_size)) * 4;var _yoff = 18 - (obj_camera.y / (chunk_width * grid_size)) * 4; var _lcc = ds_list_size(loaded_chunks); for (var i = 0; i < _lcc; i++) { var _chunk = loaded_chunks[| i]; draw_sprite(sprite56, _chunk[? "modified"], _xoff + _chunk[? "x"] * 4, _yoff + _chunk[? "y"] * 4);}/*draw_sprite(sprite56, 1, _xoff + floor(obj_camera.x / (chunk_width * grid_size)) * 4, _yoff + floor(obj_camera.y / (chunk_width * grid_size)) * 4);*/draw_sprite_ext(sprite56, 0, _xoff + (obj_camera.x / (chunk_width * grid_size)) * 4 - .5, _yoff + (obj_camera.y / (chunk_width * grid_size)) * 4 - .5, .25, .25, 0, c_aqua, 1);var _cam_right = floor(obj_camera.x + obj_camera.width / 2);var _cam_top = floor(obj_camera.y - obj_camera.height / 2);var _cam_left = floor(obj_camera.x - obj_camera.width / 2);var _cam_bottom = floor(obj_camera.y + obj_camera.height / 2); var _chunk_right = floor(_cam_right / (chunk_width * grid_size));var _chunk_top = floor(_cam_top / (chunk_height * grid_size)); var _chunk_left = floor(_cam_left / (chunk_width * grid_size)); var _chunk_bottom = floor(_cam_bottom / (chunk_height * grid_size)); if (!surface_exists(surface)) surface = surface_create(obj_camera.width, obj_camera.height);surface_set_target(surface);draw_clear_alpha(c_white, 0);for (var _y = _chunk_top; _y <= _chunk_bottom; _y++) { if (_y < 0) continue; for (var _x = _chunk_left; _x <= _chunk_right; _x++) { var _chunk = world_get_chunk(_x, _y); var _rmx = _x * chunk_width * grid_size; var _rmy = _y * chunk_height * grid_size; draw_chunk(_chunk, grid_size, _x * chunk_width * grid_size, _y * chunk_height * grid_size, max(floor((_cam_left - _rmx) / grid_size), 0), max(floor((_cam_top - _rmy) / (grid_size)), 0), min(floor((_cam_right - _rmx) / (grid_size)) + 1, chunk_width), min(floor((_cam_bottom - _rmy) / (grid_size)) + 1, chunk_height)); } } surface_reset_target(); draw_surface(surface, obj_camera.x - obj_camera.width / 2, obj_camera.y - obj_camera.height / 2);var _lcc = ds_list_size(loaded_chunks);if (_lcc >= chunk_minload) { var _cam_right = obj_camera.x + obj_camera.width / 2; var _cam_top = obj_camera.y - obj_camera.height / 2; var _cam_left = obj_camera.x - obj_camera.width / 2; var _cam_bottom = obj_camera.y + obj_camera.height / 2; _cam_right = ceil(_cam_right / (chunk_width * grid_size)); _cam_top = floor(_cam_top / (chunk_height * grid_size)); _cam_left = floor(_cam_left / (chunk_width * grid_size)); _cam_bottom = ceil(_cam_bottom / (chunk_height * grid_size)); for (var i = 0; i < _lcc; i++) { var _chunk = loaded_chunks[| i]; var _x = _chunk[? "x"]; var _y = _chunk[? "y"]; if ((_lcc >= chunk_maxload && (_x < _cam_left || _y < _cam_top || _x > _cam_right || _y > _cam_bottom)) || _x < _cam_left - 1 || _y < _cam_top - 1 || _x > _cam_right + 1 || _y > _cam_bottom + 1) { chunk_save(_chunk); ds_list_delete(loaded_chunks, i--); _lcc--; } } } alarm[0] = chunk_update_interval;if (!instance_exists(obj_world)) { console_log("End Drill State:", 2); state_end_player_drill(state_player_move); exit; } var _grid_size = obj_world.grid_size;var _yoff = _grid_size/2.2; if (!drilling) { var _x = floor((x + lengthdir_x(_grid_size / 2, drill_dir)) / _grid_size) * _grid_size + _grid_size / 2; var _y = floor((y - 12 + lengthdir_y(_grid_size / 2, drill_dir)) / _grid_size) * _grid_size + _grid_size / 2; drill_dir = point_direction(x, y - _yoff, _x, _y); drill_grid_x = _x / _grid_size; drill_grid_y = _y / _grid_size; if (drill_spd * (1 - (y / room_height) < (7 / room_speed)) || world_grid_get(floor(drill_grid_x), floor(drill_grid_y)) <= 0) { state_end_player_drill(state_player_move); exit; } drilling = true;} /* if (drill_grid_x < 0 || drill_grid_y < 0 || drill_grid_x > _grid_width || drill_grid_y > _grid_height) { state_end_player_drill(state_player_move); exit; } */ x += lengthdir_x(drill_spd * (1 - (y / room_height)), drill_dir);y += lengthdir_y(drill_spd * (1 - (y / room_height)), drill_dir);var _dist = point_distance(x, y, drill_grid_x * _grid_size, drill_grid_y * _grid_size + _yoff); if (_dist % (32 / 4) < 1) { with (instance_create_layer(x, floor(y) - 13, "Effects", obj_drill_hole)) { image_angle = random(360); image_xscale = random(.3) + .7; image_yscale = random(.3) + .7; destroy = DHD.DRILL; } } if (_dist <= drill_spd) { var _cell = world_grid_get(floor(drill_grid_x), floor(drill_grid_y)) - 1; if (_cell > 0) { var _did = (!inv_add(_cell)) var _name = string_lower(obj_world.ore_name[_cell - 1]); if (_did || inv_filled >= inv_slots) { textbox_add("Inventory Full!" + (_did ? " Destroyed " : " +1 ") + _name); } else { textbox_add("+1 " + _name); } } world_grid_set(floor(drill_grid_x), floor(drill_grid_y), 0); //chunk_save(world_get_chunk(floor(drill_grid_x) div obj_world.chunk_width, floor(drill_grid_y) div obj_world.chunk_height)); state_end_player_drill(state_player_move); exit; } drill++; /// @func state_player_movevar _dir = point_direction(0, 0, key_xaxis, key_yaxis);var _grav = (grav - yvel) * fric;yvel += _grav;if (key_xaxis != 0 || key_yaxis != 0) { xvel += (xacc + lengthdir_x(spd, _dir) - xvel) * fric; var _min = 8; if (key_yaxis < 0) yvel += (yacc + lengthdir_y(spd + _grav / fric, _dir) - yvel) / (_min + inv_filled * 5 / room_speed) * _min * fric; if (key_xaxis != 0) image_xscale_target = sign(key_xaxis); // Change module if (key_yaxis > 0 && module_active != MODULE.DRILL_Y) { module_prev = module_active; module_active = MODULE.DRILL_Y; module_interp = 0; } else if (key_yaxis < 0 && module_active != MODULE.PROPELLER) { module_prev = module_active; module_active = MODULE.PROPELLER; module_interp = 0; } } else { xvel -= xvel * fric; } if (key_yaxis == 0 && module_active != MODULE.DRILL_X) { module_prev = module_active; module_active = MODULE.DRILL_X; module_interp = 0; } image_speed = abs(xvel);var _prev_xvel = xvel; var _prev_yvel = yvel; /* var _cam_right = ceil(obj_camera.x + obj_camera.width / 2);var _cam_top = floor(obj_camera.y - obj_camera.height / 2); var _cam_left = floor(obj_camera.x - obj_camera.width / 2); var _cam_bottom = ceil(obj_camera.y + obj_camera.height / 2);_cam_right = ceil(_cam_right div (chunk_width * grid_size));_cam_top = floor(_cam_top div (chunk_height * grid_size)); _cam_left = floor(_cam_left div (chunk_width * grid_size));_cam_bottom = ceil(_cam_bottom div (chunk_height * grid_size)); /* if (!noclip && instance_exists(obj_world) && world_meeting(x + xvel, y)) { var _sgn = sign(xvel); while (!world_meeting(x + _sgn, y)) { x += _sgn; } xacc = -xvel * fric / 8; xvel = 0; } x += xvel; if (!noclip && instance_exists(obj_world) && world_meeting(x, y + yvel)) { var _sgn = sign(yvel); while (!world_meeting(x, y + _sgn)) { y += _sgn; } yacc = -yvel * fric; yvel = 0; } y += yvel;if (yvel == 0) { xvel -= xvel * fric * 2; }if (xvel == 0 && key_xaxis != 0 && key_yaxis == 0 && yvel == 0) || (yvel == 0 && key_yaxis > 0 && key_xaxis == 0) { if (!state_wait && angle_difference(dir_last, _dir) < 28) { if (drill < drill_boundary) { drill++; } else { drill = 0; drill_dir = _dir; drill_start_x = x; drill_start_y = y; xvel = 0; yvel = 0; state = state_player_drill; } } else drill = 0;} else drill = 0;dir_last = _dir; if (yvel == 0 && _prev_yvel != 0) { var _dis = _prev_yvel - yvel; if (_dis > 200 / room_speed) { hit_timer = hit_time; hull -= _dis * 4; } } if (place_meeting(x, y, par_store) && magnitude(xvel, yvel) < 160 / room_speed) { var _shop = instance_place(x, y, par_store); if (_shop != shop_entered) { shop_entered = _shop; camera_xoffset = _shop.x - x; camera_yoffset = _shop.y - y; draw_menu = _shop.object_index; _shop.customer = id; state = state_player_shop; xvel = 0; yvel = 0; } } else shop_entered = noone;