├── Array 2D 3D ├── array_2d_foreach.gml ├── array_2d_foreach_adjacent.gml ├── array_2d_foreach_area.gml ├── array_2d_get.gml ├── array_2d_init.gml ├── array_2d_is_in_bounds.gml ├── array_2d_set.gml ├── array_2d_set_area.gml ├── array_3d_foreach.gml ├── array_3d_foreach_adjacent.gml ├── array_3d_foreach_area.gml ├── array_3d_get.gml ├── array_3d_init.gml ├── array_3d_is_in_bounds.gml └── array_3d_set.gml ├── Camera and Views ├── camera_matrix_get_properties.gml ├── camera_set_view_pos_subpixel.gml └── display_write_all_specs.gml ├── Collision Checking ├── collision_line_point.gml └── collision_line_width.gml ├── Hooks ├── dependencies │ ├── approach.gml │ ├── draw_rectangle_sprite.gml │ ├── shdMotionBlur │ │ ├── shdMotionBlur.fsh │ │ ├── shdMotionBlur.vsh │ │ └── shdMotionBlur.yy │ ├── shdRadialBlur │ │ ├── shdRadialBlur.fsh │ │ ├── shdRadialBlur.vsh │ │ └── shdRadialBlur.yy │ └── sin_oscillate.gml ├── use_blur.gml ├── use_controls.gml ├── use_ez3d_cam.gml ├── use_flash.gml ├── use_pause.gml ├── use_screen_flash.gml └── use_shake.gml ├── Macro Sets └── scrViewMacros.gml ├── Services ├── srvDisplay.gml ├── srvEvent.gml ├── srvJukebox.gml ├── srvPause.gml └── srvSaveData.gml ├── Systems and Examples ├── Camera Click Drag and Zoom.yyz ├── Diablo Inventory.yyz ├── Distribute N Rectangles In Rectangle.yyz ├── NoiseGeneration.yymps ├── PixelPerfectScalingWithGraphicBorderAndFunctionalGui.yyz ├── ScalingShadersDemo.yyz ├── SequenceAnchorPointsTest.yyz ├── SoftShadowSurfaceBlending.yyz ├── VeryBasicMasking.yyz ├── Visible Pausing.yymps ├── VisiblePausing.yyz └── resolution_picker.yyz ├── _Maybe Not that great ├── DS Scripts │ ├── ds_grid_add_row.gml │ ├── ds_grid_change_orientation.gml │ ├── ds_grid_crop.gml │ ├── ds_grid_delete_row.gml │ ├── ds_grid_draw.gml │ ├── ds_grid_floodfill.gml │ ├── ds_grid_get_adjacent_count.gml │ ├── ds_grid_in_bounds.gml │ ├── ds_grid_insert_row.gml │ ├── ds_grid_is_in_bounds.gml │ ├── ds_grid_replace_value.gml │ ├── ds_grid_sort_row.gml │ ├── ds_grid_value_row.gml │ ├── ds_list_add_list.gml │ ├── ds_list_append.gml │ ├── ds_list_count_value.gml │ ├── ds_list_create_number_list.gml │ ├── ds_list_delete_value.gml │ └── ds_list_value_exists.gml ├── TwerpFriends │ ├── arc.gml │ ├── bias.gml │ ├── blink.gml │ ├── cubic_bezier.gml │ ├── interpolate.gml │ ├── solve_cubic.gml │ ├── solve_quadratic.gml │ ├── twerp.gml │ ├── twerp_random.gml │ ├── twerp_random_distributed.gml │ ├── twerp_random_range.gml │ └── value_bounce_between.gml ├── Vec2 and Dependant Scripts │ ├── vec2.gml │ ├── vec2_add.gml │ ├── vec2_dir.gml │ ├── vec2_equals.gml │ ├── vec2_from_length_dir.gml │ ├── vec2_length.gml │ ├── vec2_length_approach.gml │ ├── vec2_normalize.gml │ ├── vec2_scale.gml │ ├── vec2_set_length.gml │ ├── vec2_subtract.gml │ ├── vec2_sum.gml │ ├── vec2_truncate.gml │ └── vec2_zero.gml ├── display_get_best_fit.gml ├── draw_line_sprite.gml ├── draw_rectangle_sprite.gml ├── draw_sprite_ext_alpha.gml ├── draw_text_transformed_gpu.gml ├── instance_place_array.gml └── instance_position_array.gml ├── _Need To Be Upgraded ├── Collision Point Line to Rectangle │ ├── collision_point_line_to_rectangle.gml │ ├── line_intersect_point.gml │ └── lines_intersect.gml ├── angle_normalize.gml ├── chance.gml ├── circular_sum_noise.gml ├── ilengthdir_x.gml ├── ilengthdir_y.gml ├── is_even.gml ├── merge_color_multi.gml ├── merge_color_rainbow.gml ├── minutes.gml ├── mouse_is_in_window.gml ├── seconds.gml ├── target_chain.gml └── tileset_get_tile_index.gml ├── angle_clamp.gml ├── angle_rotate_towards.gml ├── angle_rotate_towards_smooth.gml ├── animation_end.gml ├── animcurve_lerp.gml ├── approach.gml ├── approach_smooth.gml ├── audio_play_sound_spaced.gml ├── ceil_n.gml ├── cos_oscillate.gml ├── draw_cone.gml ├── draw_self_ext.gml ├── draw_set_text_alignment.gml ├── draw_sprite_from_center.gml ├── draw_sprite_solid_color.gml ├── draw_surface_ext_origin.gml ├── floor_n.gml ├── grid_pos_to_number.gml ├── gtfo.gml ├── how_far_out.gml ├── instance_create.gml ├── is_between.gml ├── is_or.gml ├── key_to_string.gml ├── lerp_clamped.gml ├── matrix_build_rotation.gml ├── matrix_build_scale.gml ├── matrix_build_translation.gml ├── matrix_combine.gml ├── merge_structs.gml ├── mod2.gml ├── mouse_get_position_accurate.gml ├── number_to_grid_pos.gml ├── point_rotate.gml ├── position_between.gml ├── room_to_gui_x.gml ├── room_to_gui_y.gml ├── round_n.gml ├── seconds_to_timestamp.gml ├── sin_oscillate.gml ├── sprite_is_on_frame.gml ├── sprite_swap.gml ├── steps_to_microseconds.gml ├── with_tag.gml └── wrap.gml /Array 2D 3D/array_2d_foreach.gml: -------------------------------------------------------------------------------- 1 | function array_2d_foreach(_arr, _func){ 2 | var _width = array_length(_arr); 3 | var _height = array_length(_arr[0]); 4 | 5 | for(var _x = 0; _x < _width; _x++){ 6 | for(var _y = 0; _y < _height; _y++){ 7 | _func(_arr[_x][_y], _arr, [_x, _y]); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Array 2D 3D/array_2d_foreach_adjacent.gml: -------------------------------------------------------------------------------- 1 | ///@func array_2d_foreach_adjacent(array, position, function, [skipCenter = true], [dist = 1], [cardinalOnly = true]) 2 | function array_2d_foreach_adjacent(_arr, _pos, _func, _skipCenter = true, _dist = 1, _cardnialOnly = true){ 3 | var _xC = _pos[X] 4 | var _yC = _pos[Y] 5 | 6 | for(var _x = _xC - _dist; _x <= _xC + _dist; _x++){ 7 | for(var _y = _yC - _dist; _y <= _yC + _dist; _y++){ 8 | if(!array_2d_is_in_bounds(_arr, [_x, _y])) continue; 9 | //if(_skipCenter && _x == _xC && _y == _yC && _z == _zC) continue; 10 | //if(_cardnialOnly && abs(_x) + abs(_y) + abs(_z) > 1) continue; //TODO: This don't work with a distance more than 1. Does it need to? Maybe? 11 | var _val = _arr[_x][_y]; 12 | _func(_val, _arr, [_x, _y]); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Array 2D 3D/array_2d_foreach_area.gml: -------------------------------------------------------------------------------- 1 | function array_2d_foreach_area(_arr, _pos, _area, _func){ 2 | var _x1 = _pos[X] 3 | var _y1 = _pos[Y] 4 | for(var _x = _x1; _x < _x1 + _area[X]; _x++){ 5 | for(var _y = _y1; _y < _y1 + _area[Y]; _y++){ 6 | if(!array_2d_is_in_bounds(_arr, [_x, _y])) continue; 7 | _func(_arr[_x][_y], _arr, [_x, _y]); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /Array 2D 3D/array_2d_get.gml: -------------------------------------------------------------------------------- 1 | function array_2d_get(_arr, _pos){ 2 | if(!array_2d_is_in_bounds(_arr, _pos)) return EMPTY; 3 | 4 | return _arr[_pos[X]][_pos[Y]]; 5 | } -------------------------------------------------------------------------------- /Array 2D 3D/array_2d_init.gml: -------------------------------------------------------------------------------- 1 | function array_2d_init(_width, _height, _value, _clone=false){ 2 | var _arr = []; 3 | for(var _x = 0; _x < _width; _x++){ 4 | for(var _y = 0; _y < _height; _y++){ 5 | _arr[_x][_y] = _clone ? variable_clone(_value) : _value; 6 | } 7 | } 8 | return _arr; 9 | } -------------------------------------------------------------------------------- /Array 2D 3D/array_2d_is_in_bounds.gml: -------------------------------------------------------------------------------- 1 | function array_2d_is_in_bounds(_arr, _pos){ 2 | return _pos[X] >= 0 && _pos[X] < array_length(_arr) && 3 | _pos[Y] >= 0 && _pos[Y] < array_length(_arr[0]) 4 | } 5 | -------------------------------------------------------------------------------- /Array 2D 3D/array_2d_set.gml: -------------------------------------------------------------------------------- 1 | function array_2d_set(_arr, _pos, _val){ 2 | if(!array_2d_is_in_bounds(_arr, _pos)) throw("Attempted to set OOB value for 2D Array"); 3 | _arr[_pos[X]][_pos[Y]] = _val; 4 | } -------------------------------------------------------------------------------- /Array 2D 3D/array_2d_set_area.gml: -------------------------------------------------------------------------------- 1 | function array_2d_set_area(_arr, _pos, _w, _h, _val){ 2 | for(var _x = _pos[X]; _x < _pos[X]+_w; _x++){ 3 | for(var _y = _pos[Y]; _y < _pos[Y]+_h; _y++){ 4 | if(!array_2d_is_in_bounds(_arr, [_x, _y])) continue; 5 | _arr[_x][_y] = _val; 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Array 2D 3D/array_3d_foreach.gml: -------------------------------------------------------------------------------- 1 | function array_3d_foreach(_arr, _func){ 2 | var _width = array_length(_arr); 3 | var _height = array_length(_arr[0]); 4 | var _depth = array_length(_arr[0][0]); 5 | 6 | for(var _x = 0; _x < _width; _x++){ 7 | for(var _y = 0; _y < _height; _y++){ 8 | for(var _z = 0; _z < _depth; _z++){ 9 | _func(_arr[_x][_y][_z], _arr, [_x, _y, _z]); 10 | } 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Array 2D 3D/array_3d_foreach_adjacent.gml: -------------------------------------------------------------------------------- 1 | ///@func array_3d_foreach_adjacent(array, position, function, [skipCenter = true], [dist = 1], [cardinalOnly = true]) 2 | function array_3d_foreach_adjacent(_arr, _pos, _func, _skipCenter = true, _dist = 1, _cardnialOnly = true){ 3 | var _xC = _pos[X] 4 | var _yC = _pos[Y] 5 | var _zC = _pos[Z] 6 | 7 | for(var _x = _xC - _dist; _x <= _xC + _dist; _x++){ 8 | for(var _y = _yC - _dist; _y <= _yC + _dist; _y++){ 9 | for(var _z = _zC - _dist; _z <= _zC + _dist; _z++){ 10 | if(!array_3d_is_in_bounds(_arr, [_x, _y, _z])) continue; 11 | //if(_skipCenter && _x == _xC && _y == _yC && _z == _zC) continue; 12 | //if(_cardnialOnly && abs(_x) + abs(_y) + abs(_z) > 1) continue; //TODO: This don't work with a distance more than 1. Does it need to? Maybe? 13 | var _val = _arr[_x][_y][_z]; 14 | _func(_val, _arr, [_x, _y, _z]); 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Array 2D 3D/array_3d_foreach_area.gml: -------------------------------------------------------------------------------- 1 | function array_3d_foreach_area(_arr, _pos, _area, _func){ 2 | var _x1 = _pos[X] 3 | var _y1 = _pos[Y] 4 | var _z1 = _pos[Z] 5 | for(var _x = _x1; _x < _x1 + _area[X]; _x++){ 6 | for(var _y = _y1; _y < _y1 + _area[Y]; _y++){ 7 | for(var _z = _z1; _z < _z1 + _area[Z]; _z++){ 8 | if(!array_3d_is_in_bounds(_arr, [_x, _y, _z])) continue; 9 | _func(_arr[_x][_y][_z], _arr, [_x, _y, _z]); 10 | } 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Array 2D 3D/array_3d_get.gml: -------------------------------------------------------------------------------- 1 | function array_3d_get(_arr, _pos){ 2 | if(!array_3d_is_in_bounds(_arr, _pos)) return EMPTY; 3 | 4 | return _arr[_pos[X]][_pos[Y]][_pos[Z]]; 5 | } -------------------------------------------------------------------------------- /Array 2D 3D/array_3d_init.gml: -------------------------------------------------------------------------------- 1 | function array_3d_init(_width, _height, _depth, _value, _clone=false){ 2 | var _arr = []; 3 | for(var _x = 0; _x < _width; _x++){ 4 | for(var _y = 0; _y < _height; _y++){ 5 | for(var _z = 0; _z < _depth; _z++){ 6 | _arr[_x][_y][_z] = _clone ? variable_clone(_value) : _value; 7 | } 8 | } 9 | } 10 | return _arr; 11 | } -------------------------------------------------------------------------------- /Array 2D 3D/array_3d_is_in_bounds.gml: -------------------------------------------------------------------------------- 1 | function array_3d_is_in_bounds(_arr, _pos){ 2 | return _pos[X] >= 0 && _pos[X] < array_length(_arr) && 3 | _pos[Y] >= 0 && _pos[Y] < array_length(_arr[0]) && 4 | _pos[Z] >= 0 && _pos[Z] < array_length(_arr[0][0]) 5 | } 6 | -------------------------------------------------------------------------------- /Array 2D 3D/array_3d_set.gml: -------------------------------------------------------------------------------- 1 | function array_3d_set(_arr, _pos, _val){ 2 | if(!array_3d_is_in_bounds(_arr, _pos)) throw("Attempted to set OOB value for 3D Array"); 3 | _arr[_pos[X]][_pos[Y]][_pos[Z]] = _val; 4 | } -------------------------------------------------------------------------------- /Camera and Views/camera_matrix_get_properties.gml: -------------------------------------------------------------------------------- 1 | /// @description camera_matrix_get_properties 2 | /// @param camera 3 | 4 | /*returns an array with the following information 5 | 0 = Width 6 | 1 = Height 7 | 2 = Center X 8 | 3 = Center Y 9 | 4 = Left Bound 10 | 5 = Top Bound 11 | */ 12 | 13 | var _view_mtx = camera_get_view_mat( argument0 ); 14 | var _proj_mtx = camera_get_proj_mat( argument0 ); 15 | var _return; 16 | _return[0] = 2/_proj_mtx[0]; 17 | _return[1] = 2/_proj_mtx[5]; 18 | _return[2] = -_view_mtx[12]; 19 | _return[3] = -_view_mtx[13]; 20 | _return[4] = _return[2] - _return[0]/2; 21 | _return[5] = _return[3] -_return[1]/2; 22 | 23 | return _return; -------------------------------------------------------------------------------- /Camera and Views/camera_set_view_pos_subpixel.gml: -------------------------------------------------------------------------------- 1 | ///@func camera_set_view_pos_subpixel(cam,x,y) 2 | function camera_set_view_pos_subpixel(_cam, _x, _y) { 3 | var _sw = surface_get_width(application_surface), 4 | _vw = camera_get_view_width(_cam), 5 | _ratio = _vw/_sw; 6 | 7 | _x = round(_x/_ratio)*_ratio; 8 | _y = round(_y/_ratio)*_ratio; 9 | 10 | camera_set_view_pos(_cam,_x,_y); 11 | } -------------------------------------------------------------------------------- /Camera and Views/display_write_all_specs.gml: -------------------------------------------------------------------------------- 1 | /// @func display_write_all_specs([x],[y], [scale]); 2 | function display_write_all_specs(_x = 5, _y = 5, _scale = 1){ 3 | var _dispW = display_get_width(), _dispH = display_get_height(), 4 | _winW = window_get_width(), _winH = window_get_height(), 5 | _appW = surface_get_width(application_surface), _appH = surface_get_height(application_surface), 6 | _guiW = display_get_gui_width(), _guiH = display_get_gui_height(); 7 | 8 | var _str = ""; 9 | 10 | var _dispRes = $"{_dispW} x {_dispH}"; 11 | var _dispAspect = $"{_dispW / _dispH}"; 12 | 13 | _str += $"Display: {_dispRes} - {_dispAspect}\n"; 14 | 15 | var _winRes = $"{_winW} x {_winH}"; 16 | var _winAspect = $"{_winW / _winH}"; 17 | 18 | _str += $"Window: {_winRes} - {_winAspect}\n"; 19 | 20 | var _appRes = $"{_appW} x { _appH}"; 21 | var _appAspect = $"{_appW / _appH}"; 22 | var _appScale = _winW / _appW == _winH / _appH ? $"{_winW / _appW}" : $"({_winW / _appW} : {_winH / _appH})"; 23 | 24 | _str += $"App Surface: {_appRes} - {_appAspect} - {_appScale}X\n"; 25 | 26 | var _guiRes = $"{_guiW} x { _guiH}"; 27 | var _guiAspect = $"{_guiW / _guiH}"; 28 | var _guiScale = _appW / _guiW == _appH / _guiH ? $"{_appW / _guiW}" : $"({_appW / _guiW} : {_appH / _guiH})"; 29 | 30 | _str += $"GUI: {_guiRes} - {_guiAspect} - {_guiScale}X\n"; 31 | 32 | for(var _i = 0; _i < 8 && view_enabled; _i++){ 33 | if(!view_visible[_i]) continue; 34 | 35 | var _viewW = camera_get_view_width(view_camera[_i]), _viewH = camera_get_view_height(view_camera[_i]); 36 | var _viewRes = $"{_viewW} x {_viewH}" 37 | var _viewAspect = $"{_viewW / _viewH}" 38 | var _viewScale = _appW / _viewW == _appH / _viewH ? $"{_appW / _viewW}" : $"({_appW / _viewW} : {_appH / _viewH})"; 39 | var _viewPos = $" @{camera_get_view_x(view_camera[_i])}, {camera_get_view_y(view_camera[_i])}" 40 | _str += $"View {_i}: {_viewRes} - {_viewAspect} - {_viewScale}X\n"; 41 | _str += _viewPos +"\n" 42 | } 43 | draw_text_transformed(_x,_y,_str, _scale, _scale, 0); 44 | } -------------------------------------------------------------------------------- /Collision Checking/collision_line_point.gml: -------------------------------------------------------------------------------- 1 | /// @func collision_line_point(x1, y1, x2, y2, obj, prec, notme) 2 | //By YellowAfterLife 3 | function collision_line_point(x1, y1, x2, y2, obj, prec, notme){ 4 | var rr, rx, ry; 5 | rr = collision_line(x1, y1, x2, y2, obj, prec, notme); 6 | rx = x2; 7 | ry = y2; 8 | if (rr != noone) { 9 | var p0 = 0; 10 | var p1 = 1; 11 | repeat (ceil(log2(point_distance(x1, y1, x2, y2))) + 1) { 12 | var np = p0 + (p1 - p0) * 0.5; 13 | var nx = x1 + (x2 - x1) * np; 14 | var ny = y1 + (y2 - y1) * np; 15 | var px = x1 + (x2 - x1) * p0; 16 | var py = y1 + (y2 - y1) * p0; 17 | var nr = collision_line(px, py, nx, ny, obj, prec, notme); 18 | if (nr != noone) { 19 | rr = nr; 20 | rx = nx; 21 | ry = ny; 22 | p1 = np; 23 | } else p0 = np; 24 | } 25 | } 26 | var r; 27 | r[0] = rr; 28 | r[1] = rx; 29 | r[2] = ry; 30 | return r; 31 | } -------------------------------------------------------------------------------- /Collision Checking/collision_line_width.gml: -------------------------------------------------------------------------------- 1 | ///@func collision_line_width(x1, y1, x2, y2, width,object) 2 | function collision_line_width(_x1, _y1, _x2, _y2, _w, _obj){ 3 | if(!instance_exists(obj_sensor)) //Requires an object with a sprite that is greater than 32x32 tall with a middle left origin called obj_sensor. Or whatever. 4 | instance_create_depth(0,0,0,obj_sensor); 5 | obj_sensor.x=_x1; 6 | obj_sensor.y=_y1; 7 | obj_sensor.image_angle = point_direction(_x1,_y1,_x2,_y2); 8 | obj_sensor.image_xscale = point_distance(_x1,_y1,_x2,_y2) / sprite_get_width(obj_sensor.sprite_index); 9 | obj_sensor.image_yscale = _w / sprite_get_height(obj_sensor.sprite_index); 10 | 11 | return place_meeting(_obj.x,_obj.y,obj_sensor); 12 | } -------------------------------------------------------------------------------- /Hooks/dependencies/approach.gml: -------------------------------------------------------------------------------- 1 | ///@func approach(start, end, shift) 2 | function approach(_start, _end, _shift){ 3 | if (_start < _end) 4 | return min(_start + _shift, _end); 5 | else 6 | return max(_start - _shift, _end); 7 | } -------------------------------------------------------------------------------- /Hooks/dependencies/draw_rectangle_sprite.gml: -------------------------------------------------------------------------------- 1 | ///@func draw_rectangle_sprite(pixel_sprite,x1, y1, x2, y2, outline, color, alpha); 2 | function draw_rectangle_sprite(_pixel, _x1, _y1, _x2, _y2, _outline, _color = draw_get_color(), _alpha = draw_get_alpha()) { 3 | if(_outline) { 4 | draw_sprite_ext(_pixel,0, _x1+1, _y1, _x2-_x1-2, 1, 0, _color,_alpha); //top 5 | draw_sprite_ext(_pixel,0, _x1, _y2-1, _x2-_x1, 1, 0, _color,_alpha); //bottom 6 | draw_sprite_ext(_pixel,0, _x1, _y1, 1, _y2-_y1-1, 0, _color,_alpha); //left 7 | draw_sprite_ext(_pixel,0, _x2-1,_y1, 1, _y2-_y1-1, 0, _color,_alpha); //rirght 8 | } else { 9 | draw_sprite_ext(_pixel,0,_x1,_y1,_x2-_x1,_y2-_y1,0,_color,_alpha); 10 | } 11 | } -------------------------------------------------------------------------------- /Hooks/dependencies/shdMotionBlur/shdMotionBlur.fsh: -------------------------------------------------------------------------------- 1 | varying vec2 v_vTexcoord; 2 | varying vec4 v_vColour; 3 | uniform vec2 pos; 4 | const int Quality = 16; 5 | 6 | void main() 7 | { 8 | vec4 Color; 9 | for( float i=0.0;i<1.0;i+=1.0/float(Quality) ) 10 | { 11 | Color += texture2D( gm_BaseTexture, v_vTexcoord+vec2(pos.x,pos.y)*i); 12 | } 13 | Color /= float(Quality); 14 | gl_FragColor = Color * v_vColour; 15 | } -------------------------------------------------------------------------------- /Hooks/dependencies/shdMotionBlur/shdMotionBlur.vsh: -------------------------------------------------------------------------------- 1 | // 2 | // Simple passthrough vertex shader 3 | // 4 | attribute vec3 in_Position; // (x,y,z) 5 | //attribute vec3 in_Normal; // (x,y,z) unused in this shader. 6 | attribute vec4 in_Colour; // (r,g,b,a) 7 | attribute vec2 in_TextureCoord; // (u,v) 8 | 9 | varying vec2 v_vTexcoord; 10 | varying vec4 v_vColour; 11 | 12 | void main() 13 | { 14 | vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0); 15 | gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos; 16 | 17 | v_vColour = in_Colour; 18 | v_vTexcoord = in_TextureCoord; 19 | } 20 | -------------------------------------------------------------------------------- /Hooks/dependencies/shdMotionBlur/shdMotionBlur.yy: -------------------------------------------------------------------------------- 1 | { 2 | "type": 1, 3 | "parent": { 4 | "name": "Shaders", 5 | "path": "folders/Shaders.yy", 6 | }, 7 | "resourceVersion": "1.0", 8 | "name": "shdMotionBlur", 9 | "tags": [], 10 | "resourceType": "GMShader", 11 | } -------------------------------------------------------------------------------- /Hooks/dependencies/shdRadialBlur/shdRadialBlur.fsh: -------------------------------------------------------------------------------- 1 | varying vec2 v_vTexcoord; 2 | varying vec4 v_vColour; 3 | uniform float u_fIntensity; 4 | const int Quality = 16; 5 | 6 | void main() { 7 | vec4 Color; 8 | float v; 9 | for( float i = 0.0; i < 1.0; i += 1.0 / float(Quality) ) { 10 | v = 1. - u_fIntensity + i * u_fIntensity; 11 | Color += texture2D(gm_BaseTexture, (v_vTexcoord * v) + 0.5 - (0.5 * v)); 12 | } 13 | Color /= float(Quality); 14 | gl_FragColor = Color * v_vColour; 15 | } -------------------------------------------------------------------------------- /Hooks/dependencies/shdRadialBlur/shdRadialBlur.vsh: -------------------------------------------------------------------------------- 1 | // 2 | // Simple passthrough vertex shader 3 | // 4 | attribute vec3 in_Position; // (x,y,z) 5 | //attribute vec3 in_Normal; // (x,y,z) unused in this shader. 6 | attribute vec4 in_Colour; // (r,g,b,a) 7 | attribute vec2 in_TextureCoord; // (u,v) 8 | 9 | varying vec2 v_vTexcoord; 10 | varying vec4 v_vColour; 11 | 12 | void main() 13 | { 14 | vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0); 15 | gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos; 16 | 17 | v_vColour = in_Colour; 18 | v_vTexcoord = in_TextureCoord; 19 | } 20 | -------------------------------------------------------------------------------- /Hooks/dependencies/shdRadialBlur/shdRadialBlur.yy: -------------------------------------------------------------------------------- 1 | { 2 | "type": 1, 3 | "parent": { 4 | "name": "Shaders", 5 | "path": "folders/Shaders.yy", 6 | }, 7 | "resourceVersion": "1.0", 8 | "name": "shdRadialBlur", 9 | "tags": [], 10 | "resourceType": "GMShader", 11 | } -------------------------------------------------------------------------------- /Hooks/dependencies/sin_oscillate.gml: -------------------------------------------------------------------------------- 1 | /// @func sin_oscillate(min,max,duration,[position in microseconds]) 2 | function sin_oscillate(_min, _max, _duration, _pos = get_timer()) { 3 | if(_duration == 0) _duration = math_get_epsilon(); 4 | return((_max-_min)/2 * dsin(360 * 0.000001 * _pos /_duration) + (_max+_min)/2); 5 | } -------------------------------------------------------------------------------- /Hooks/use_blur.gml: -------------------------------------------------------------------------------- 1 | ///@func use_blur() 2 | ///@dependencies: shdRadialBlur, shdMotionBlur, twerp 3 | function use_blur(){ 4 | return { 5 | uIntensity: shader_get_uniform(shdRadialBlur, "u_fIntensity"), 6 | uPosition: shader_get_uniform(shdMotionBlur, "pos"), 7 | intensity: 0, 8 | shader: shdRadialBlur, 9 | start: 0, 10 | length: 1, 11 | timer: 0, 12 | dir: 0, 13 | 14 | startRadial: function(_amount, _length){ 15 | shader = shdRadialBlur; 16 | start = _amount; 17 | length = _length; 18 | timer = 0; 19 | }, 20 | 21 | startMotion: function(_amount, _length, _dir) { 22 | shader = shdMotionBlur; 23 | start = _amount; 24 | length = _length; 25 | dir = _dir; 26 | timer = 0; 27 | }, 28 | 29 | setShader: function(){ 30 | intensity = twerp(TwerpType.inout_elastic,start , 0, timer / length); 31 | 32 | if(timer < length) 33 | timer++ 34 | var _x = lengthdir_x(intensity, dir); 35 | var _y = lengthdir_y(intensity, dir); 36 | 37 | shader_set(shader); 38 | 39 | if (shader == shdRadialBlur) 40 | shader_set_uniform_f(uIntensity, intensity); 41 | else 42 | shader_set_uniform_f(uPosition, _x, _y); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Hooks/use_controls.gml: -------------------------------------------------------------------------------- 1 | ///@func use_controls() 2 | ///@dependecies: none 3 | function use_controls(){ 4 | return new Controls(); 5 | } 6 | 7 | function Controls() constructor { 8 | left = new Button(vk_left); 9 | right = new Button(vk_right); 10 | up = new Button(vk_up); 11 | down = new Button(vk_down); 12 | 13 | action = new Button(vk_space); 14 | confirm = new Button(vk_space); 15 | cancel = new Button(vk_escape); 16 | 17 | option1 = new Button(ord("Z")); 18 | option2 = new Button(ord("X")); 19 | 20 | ///Update this list with all buttons defined above. 21 | list = [left, right, up, down, action, confirm, cancel, option1, option2]; 22 | 23 | update = function() { 24 | for(var _i = 0; _i < array_length(list); _i++) { 25 | list[_i].update(); 26 | } 27 | } 28 | 29 | zero = function(){ 30 | for(var _i = 0; _i < array_length(list); _i++) { 31 | list[_i].reset(); 32 | } 33 | } 34 | 35 | getHori = function() { 36 | return right.held - left.held; 37 | } 38 | getVert = function() { 39 | return down.held - up.held; 40 | } 41 | } 42 | 43 | function Button(_key) constructor { 44 | key = _key; 45 | doubleTapGap = 10; 46 | reset = function() { 47 | pressed = false; 48 | doubleTapped = false; 49 | released = false; 50 | releasedTimer = 0; 51 | held = false; 52 | heldTimer = 0; 53 | } 54 | reset(); 55 | 56 | update = function(){ 57 | pressed = keyboard_check_pressed(key); 58 | released = keyboard_check_released(key); 59 | if(released) 60 | releasedTimer = 0; 61 | else 62 | releasedTimer++; 63 | 64 | //This may seem out of order, but it allows you to 65 | //check how long a button was held after it was released. 66 | heldTimer = held ? heldTimer + 1 : 0; 67 | held = keyboard_check(key); 68 | 69 | //Double Tap 70 | doubleTapped = pressed && releasedTimer < doubleTapGap; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Hooks/use_ez3d_cam.gml: -------------------------------------------------------------------------------- 1 | ///@func use_ez3d_cam([mode = EZ3DCam.mode_first_person) 2 | ///@dependencies: none 3 | function use_ez3d_cam(_mode = EZ3DCam.mode_first_person) { 4 | cam = { 5 | cleanup: function(){ 6 | if(surface != undefined && surface_exists(surface)) 7 | surface_free(surface); 8 | }, 9 | 10 | draw: function(){ 11 | var _cam = view_camera[0]; 12 | var _vw = camera_get_view_width(_cam); 13 | var _ortho_view_mat = camera_get_view_mat(_cam); 14 | var _ortho_proj_mat = camera_get_proj_mat(_cam); 15 | var _surf_width = getWidth(); 16 | var _surf_height = getHeight(); 17 | var _scale = _vw/_surf_width; 18 | 19 | rebuildCameraMatrix(); 20 | 21 | if(!surface_exists(surface)) 22 | surface = surface_create(_surf_width, _surf_height); 23 | surface_set_target(surface); 24 | draw_clear_alpha(surfaceBgColor, surfaceBgAlpha); 25 | 26 | camera_set_view_mat(_cam, viewMatrix); 27 | camera_set_proj_mat(_cam, progMatrix); 28 | camera_apply(_cam); 29 | 30 | //Draw Skybox 31 | with(skyboxId) { 32 | event_perform(ev_draw,0); 33 | } 34 | 35 | gpu_set_ztestenable(true); 36 | gpu_set_alphatestenable(true); 37 | gpu_set_alphatestref(10); 38 | gpu_set_zwriteenable(true); 39 | 40 | for(var _i=0; _i< array_length(instanceRegistry); _i++) { 41 | with(instanceRegistry[ _i]) { 42 | if(id == other.skyboxId) continue; 43 | event_perform(ev_draw,0); 44 | } 45 | } 46 | gpu_set_fog(false,0,0,0); 47 | 48 | gpu_set_blendmode(bm_add) 49 | gpu_set_zwriteenable(false) 50 | for(var _i=0; _i< array_length(effectRegistry); _i++) { 51 | with(effectRegistry[ _i]) { 52 | event_perform(ev_draw,0); 53 | } 54 | } 55 | gpu_set_blendmode(bm_normal); 56 | gpu_set_zwriteenable(true) 57 | 58 | surface_reset_target(); 59 | 60 | gpu_set_ztestenable(false); 61 | gpu_set_zwriteenable(false); 62 | gpu_set_alphatestenable(false); 63 | matrix_set(matrix_world,matrix_build_identity()); 64 | 65 | _ortho_proj_mat[5] = abs(_ortho_proj_mat[5]); //Why? Because GM is kinda dumb. 66 | camera_set_view_mat(_cam, _ortho_view_mat); 67 | camera_set_proj_mat(_cam, _ortho_proj_mat); 68 | camera_set_view_size(_cam, prevViewWidth, prevViewHeight); 69 | camera_apply(_cam); 70 | 71 | //Finally, draw the 3D 72 | if(shouldDrawSurface) 73 | draw_surface_ext(surface,camera_get_view_x(_cam),camera_get_view_y(_cam),_scale,_scale,0,c_white,1); 74 | 75 | timer++; 76 | }, 77 | 78 | prevViewWidth: 0, 79 | prevViewHeight: 0, 80 | mode: EZ3DCam.mode_first_person, 81 | width: undefined, 82 | height: undefined, 83 | surface: noone, 84 | shouldDrawSurface: true, 85 | surfaceBgColor: c_black, 86 | surfaceBgAlpha: 0, 87 | target: V_ZERO, 88 | position: V_ZERO, 89 | direction: V_ZERO, 90 | directionRight: V_ZERO, 91 | directionUp: V_ZERO, 92 | up: matrix_build_translation([0, 0, 1]), 93 | distance: 1, 94 | angleMatrix: matrix_build_identity(), 95 | angleQuat: quaternion_create(), 96 | roll: 0, 97 | yaw: 0, 98 | pitch: 0, 99 | rotationMode: EZ3DCam.rotation_local, 100 | hasMoved: true, 101 | progMatrix: [], 102 | viewMatrix: [], 103 | zFar: 10000, 104 | fov: 45, 105 | 106 | instanceRegistry: [], 107 | effectRegistry: [], 108 | skyboxId: noone, 109 | changeDistanceFromTarget: function(_dif) { 110 | if (mode != EZ3DCam.mode_third_person || distance == distance + _dif) exit; 111 | distance += _dif; 112 | hasMoved = true; 113 | }, 114 | 115 | changeFov: function(_dif) { 116 | if (fov == fov + _dif) exit; 117 | fov = clamp(fov + _dif, 1, 179); 118 | hasMoved = true; 119 | }, 120 | 121 | changeOrientation: function(_difArray) { 122 | setOrientation([yaw + _difArray[0], 123 | pitch + _difArray[1], 124 | roll + _difArray[2] 125 | ]); 126 | }, 127 | 128 | changePosition: function(_difArray) { 129 | setPosition([position[V_X] + _difArray[V_X], 130 | position[V_Y] + _difArray[V_Y], 131 | position[V_Z] + _difArray[V_Z] 132 | ]); 133 | }, 134 | 135 | changeTargetPosition: function(_difArray) { 136 | setTargetPosition([target[V_X] + _difArray[V_X], 137 | target[V_Y] + _difArray[V_Y], 138 | target[V_Z] + _difArray[V_Z] 139 | ]); 140 | }, 141 | 142 | drawSurface: function(_x, _y, _xScale = 1, _yScale = 1, _angle = 0, _col = c_white, _alpha = 1) { 143 | if (surface == undefined || !surface_exists(surface)) return; 144 | draw_surface_ext(surface, _x, _y, _xScale, _yScale, _angle, _col, _alpha); 145 | }, 146 | 147 | getDistanceToPoint: function(_posArray) { 148 | var _pos = _posArray, 149 | _x = _pos[V_X], 150 | _y = _pos[V_Y], 151 | _z = _pos[V_Z], 152 | _cx = position[V_X], 153 | _cy = position[V_Y], 154 | _cz = position[V_Z]; 155 | return point_distance_3d(_x, _y, _z, _cx, _cy, _cz); 156 | }, 157 | getDirection: function() {return direction;}, 158 | getDirectionRight: function() {return directionRight;}, 159 | getDirectionUp: function() {return directionUp;}, 160 | getFov: function() {return fov;}, 161 | getHeight: function() {return height == undefined ? camera_get_view_height(view_camera[0]) : height;}, 162 | getMode: function() {return mode;}, 163 | getOrientation: function() {return [yaw, pitch, roll];}, 164 | getPitch: function() {return pitch;}, 165 | getPosition: function() {return position;}, 166 | getRoll: function() {return roll;}, 167 | getRotationMode: function() {return rotationMode;}, 168 | getTargetPosition: function() {return target;}, 169 | getWidth: function() {return width == undefined ? camera_get_view_width(view_camera[0]) : width;}, 170 | getYaw: function() {return yaw;}, 171 | 172 | registerInstance: function(_id) { 173 | _id.visible = false; 174 | array_push(instanceRegistry, _id); 175 | }, 176 | 177 | registerSkybox: function(_id) { 178 | _id.visible = false; 179 | skyboxId = _id; 180 | }, 181 | 182 | registerEffect: function(_id) { 183 | _id.visible = false; 184 | array_push(effectRegistry, _id); 185 | }, 186 | 187 | setDistanceFromTarget: function(_dist) { 188 | if (mode != EZ3DCam.mode_third_person || distance == _dist) exit; 189 | distance = _dist; 190 | hasMoved = true; 191 | }, 192 | 193 | setFov: function(_fov) { 194 | if (fov == _fov) exit; 195 | fov = clamp(_fov, 1, 179); 196 | hasMoved = true; 197 | }, 198 | 199 | setMode: function(_mode) { 200 | if (_mode == mode) exit; 201 | mode = _mode; 202 | hasMoved = true; 203 | }, 204 | 205 | setOrientation: function(_array) { 206 | if (yaw != _array[0]) { 207 | hasMoved = true; 208 | yaw = _array[0]; 209 | } 210 | if (pitch != _array[1]) { 211 | hasMoved = true; 212 | pitch = _array[1]; 213 | } 214 | if (roll != _array[2]) { 215 | hasMoved = true; 216 | roll = _array[2]; 217 | } 218 | }, 219 | 220 | setPosition: function(_pos) { 221 | if (array_equals(position, _pos)) exit; 222 | hasMoved = true; 223 | position = _pos; 224 | distance = getDistanceToPoint(target); 225 | }, 226 | 227 | setRenderTarget: function(_width = -1, _height = 1, _surfaceBgCol = c_black, _surfaceBgAlpha, _autoDrawEnabled = true) { 228 | width = _width == -1 ? undefined : _width; 229 | height = _height == -1 ? undefined : _height; 230 | surfaceBgColor = _surfaceBgCol; 231 | surfaceBgAlpha = _surfaceBgAlpha; 232 | shouldDrawSurface = _autoDrawEnabled; 233 | }, 234 | 235 | setRotationMode: function(_mode = EZ3DCam.rotation_local) { 236 | rotationMode = _mode; 237 | }, 238 | 239 | setSize: function(_width, _height) { 240 | if (width == _width && height == _height) exit; 241 | width = _width; 242 | height = _height; 243 | surface_free(surface); 244 | }, 245 | 246 | setTargetPosition: function(_posArray) { 247 | if (array_equals(target, _posArray)) exit; 248 | hasMoved = true; 249 | target = _posArray; 250 | if (mode == EZ3DCam.mode_track_target) 251 | distance = getDistanceToPoint(target); 252 | }, 253 | 254 | setZFar: function(_dist = 10000) { 255 | if (zFar == _dist) exit; 256 | zFar = max(_dist, 1); 257 | hasMoved = true; 258 | }, 259 | 260 | getZFar: function() { 261 | return zFar; 262 | }, 263 | 264 | deregisterInstance: function(_id) { 265 | for(var _i = 0; _i < array_length(instanceRegistry) _i++) { 266 | if(instanceRegistry[_i] == _id) { 267 | array_delete(instanceRegistry,_i,1); 268 | break; 269 | } 270 | } 271 | }, 272 | 273 | deregisterEffect: function(_id) { 274 | for(var _i = 0; _i < array_length(effectRegistry) _i++) { 275 | if(effectRegistry[_i] == _id) { 276 | array_delete(effectRegistry,_i,1); 277 | break; 278 | } 279 | } 280 | }, 281 | 282 | rebuildCameraMatrix: function() { 283 | /// @description Rebuild Camera Matrix 284 | prevViewWidth = camera_get_view_width(view_camera[0]); 285 | prevViewHeight = camera_get_view_height(view_camera[0]); 286 | if (width != undefined && height != undefined) 287 | camera_set_view_size(view_camera[0], width, height); 288 | 289 | var _vw = camera_get_view_width(view_camera[0]); 290 | var _vh = camera_get_view_height(view_camera[0]); 291 | 292 | switch (mode) { 293 | case EZ3DCam.mode_first_person: 294 | if (!hasMoved) break; 295 | if (rotationMode == EZ3DCam.rotation_local) { 296 | angleQuat = quaternion_create(); 297 | angleQuat = quaternion_rotate_worldz(angleQuat, yaw); 298 | angleQuat = quaternion_rotate_localz(angleQuat, pitch); 299 | angleQuat = quaternion_rotate_localx(angleQuat, roll); 300 | } else { 301 | var _pitch = quaternion_create(), 302 | _yaw = quaternion_create(), 303 | _roll = quaternion_create(); 304 | _pitch = quaternion_rotate_localz(_pitch, pitch); 305 | _yaw = quaternion_rotate_localy(_yaw, yaw); 306 | _roll = quaternion_rotate_localx(_roll, roll); 307 | pitch = 0; 308 | yaw = 0; 309 | roll = 0; 310 | angleQuat = quaternion_combine(angleQuat, _pitch, _yaw, _roll); 311 | } 312 | angleMatrix = quaternion_matrix(angleQuat); 313 | direction = matrix_to_vec3(matrix_combine(matrix_build_translation([1, 0, 0]), angleMatrix)); 314 | direction = vec3_normalize(direction); 315 | directionRight = matrix_to_vec3(matrix_combine(matrix_build_translation([0, -1, 0]), angleMatrix)); 316 | directionUp = matrix_to_vec3(matrix_combine(matrix_build_translation([0, 0, 1]), angleMatrix)); 317 | target = vec3_add(direction, position); 318 | break; 319 | 320 | case EZ3DCam.mode_third_person: 321 | if (rotationMode == EZ3DCam.rotation_local) { 322 | angleQuat = quaternion_create(); 323 | angleQuat = quaternion_rotate_worldz(angleQuat, yaw); 324 | angleQuat = quaternion_rotate_localz(angleQuat, pitch); 325 | angleQuat = quaternion_rotate_localx(angleQuat, roll); 326 | } else { 327 | var _pitch = quaternion_create(), 328 | _yaw = quaternion_create(), 329 | _roll = quaternion_create(); 330 | _pitch = quaternion_rotate_localz(_pitch, pitch); 331 | _yaw = quaternion_rotate_localy(_yaw, yaw); 332 | _roll = quaternion_rotate_localx(_roll, -roll); 333 | pitch = 0; 334 | yaw = 0; 335 | roll = 0; 336 | angleQuat = quaternion_combine(angleQuat, _pitch, _yaw, _roll); 337 | } 338 | angleMatrix = quaternion_matrix(angleQuat); 339 | var _matrix = matrix_combine(matrix_build_translation([distance, 0, 0]), angleMatrix, matrix_build_translation(target)); 340 | position = [_matrix[M_X], _matrix[M_Y], _matrix[M_Z]]; 341 | direction = matrix_to_vec3(matrix_combine(matrix_build_translation([-1, 0, 0]), angleMatrix)); 342 | directionRight = matrix_to_vec3(matrix_combine(matrix_build_translation([0, 1, 0]), angleMatrix)); 343 | directionUp = matrix_to_vec3(matrix_combine(matrix_build_translation([0, 0, 1]), angleMatrix)); 344 | break; 345 | 346 | case EZ3DCam.mode_track_target: 347 | //calculate camera properties 348 | var _tar = target; 349 | var _pos = position; 350 | distance = point_distance_vec3(_tar, _pos) 351 | yaw = -point_direction(_pos[V_X], _pos[V_Y], _tar[V_X], _tar[V_Y]); 352 | var _ratio = (_pos[V_Z] - _tar[V_Z]) / distance; 353 | pitch = radtodeg(arcsin(_ratio)); 354 | var _angle = quaternion_create(); 355 | _angle = quaternion_rotate_worldz(_angle, yaw); 356 | _angle = quaternion_rotate_localz(_angle, pitch); 357 | 358 | _angle = quaternion_rotate_localx(_angle, roll); 359 | angleQuat = _angle; 360 | angleMatrix = quaternion_matrix(_angle); 361 | direction = matrix_to_vec3(matrix_combine(matrix_build_translation([1, 0, 0]), angleMatrix)); 362 | directionRight = matrix_to_vec3(matrix_combine(matrix_build_translation([0, -1, 0]), angleMatrix)); 363 | directionUp = matrix_to_vec3(matrix_combine(matrix_build_translation([0, 0, 1]), angleMatrix)); 364 | break; 365 | } 366 | 367 | var _up = matrix_combine(matrix_build_translation(up), angleMatrix), 368 | _aspect = _vw / _vh, 369 | _pos = position; 370 | 371 | viewMatrix = matrix_build_lookat(_pos[V_X], _pos[V_Y], _pos[V_Z], 372 | _pos[V_X] + direction[V_X], _pos[V_Y] + direction[V_Y], _pos[V_Z] + direction[V_Z], 373 | _up[M_X], _up[M_Y], _up[M_Z]); 374 | progMatrix = matrix_build_projection_perspective_fov(fov, _aspect, 1, zFar); 375 | }, 376 | timer: 0 377 | } 378 | 379 | //Standard vertex format. Feel free to replace with your own if necessary 380 | vertex_format_begin() 381 | vertex_format_add_position_3d(); 382 | vertex_format_add_normal(); 383 | vertex_format_add_colour(); 384 | vertex_format_add_texcoord(); 385 | cam.vertexFormat = vertex_format_end(); 386 | 387 | if(_mode != EZ3DCam.mode_first_person) 388 | cam.setMode(_mode); 389 | 390 | return cam; 391 | } 392 | 393 | #region Matrix Extension Functions 394 | 395 | ///@func matrix_build_translation([x,y,z]) 396 | function matrix_build_translation(_posXYZ) { 397 | if(array_length(_posXYZ) == 3) 398 | return matrix_build(_posXYZ[V_X],_posXYZ[V_Y],_posXYZ[V_Z],0,0,0,1,1,1); 399 | 400 | return matrix_build(_posXYZ[M_X],_posXYZ[M_Y],_posXYZ[M_Z],0,0,0,1,1,1); 401 | } 402 | 403 | ///@func matrix_build_rotation(rotation[x,y,z]) 404 | function matrix_build_rotation(_rotationXYZ) { 405 | if(array_length(_rotationXYZ) == 3) 406 | return matrix_build(0,0,0,_rotationXYZ[V_X],_rotationXYZ[V_Y],_rotationXYZ[V_Z],1,1,1); 407 | 408 | return matrix_build(0,0,0,_rotationXYZ[M_X],_rotationXYZ[M_Y],_rotationXYZ[M_Z],1,1,1); 409 | } 410 | 411 | ///@func matrix_build_scale(scale[x,y,z]) 412 | function matrix_build_scale(_scaleXYZ) { 413 | if(array_length(_scaleXYZ) == 3) 414 | return matrix_build(0,0,0,0,0,0,_scaleXYZ[V_X],_scaleXYZ[V_Y],_scaleXYZ[V_Z]); 415 | 416 | return matrix_build(0,0,0,0,0,0,_scaleXYZ[M_X],_scaleXYZ[M_Y],_scaleXYZ[M_Z]); 417 | } 418 | 419 | ///@func matrix_build_srt(scale[x,y,z], rotation[x,y,z], translation[x,y,z]) 420 | function matrix_build_srt(_scaleXYZ, _rotationXYZ, _translationXYZ) { 421 | return matrix_combine(matrix_build_scale(_scaleXYZ), 422 | matrix_build_rotation(_rotationXYZ), 423 | matrix_build_translation(_translationXYZ)); 424 | } 425 | 426 | ///@func matrix_combine(matrix1, matrix2, matrix3...) 427 | function matrix_combine() { 428 | var _m = matrix_multiply(argument[0],argument[1]) 429 | for(var _i=2; _i 519 | ///@param 520 | function quaternion_combine() { 521 | var _q = quaternion_multiply(argument[0],argument[1]) 522 | for(var _i=2; _i 0); 16 | if(_prev == 1 && __iTimer == 0) 17 | __iEnd(); 18 | return getIsPaused(); 19 | }, 20 | 21 | set: function(_amount) { 22 | __iTimer = _amount; 23 | if(_amount > 0 || _amount == -1) { 24 | __iStart(); 25 | } else if(__iIsPaused) { 26 | __iEnd(); 27 | } 28 | }, 29 | 30 | __iStart: function() { 31 | __iIsPaused = true; 32 | if(__iPrevImageSpeed == undefined) 33 | __iPrevImageSpeed = __iOwner.image_speed; 34 | __iOwner.image_speed = 0; 35 | }, 36 | 37 | __iEnd: function() { 38 | __iIsPaused = false; 39 | __iOwner.image_speed = __iPrevImageSpeed; 40 | __iPrevImageSpeed = undefined; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /Hooks/use_screen_flash.gml: -------------------------------------------------------------------------------- 1 | ///@func use_screen_flash() 2 | ///@dependencies: draw_rectangle_sprite 3 | function use_screen_flash(){ 4 | return { 5 | color: c_white, 6 | timer: 0, 7 | length: 0, 8 | 9 | set: function(_col, _len) { 10 | color = _col; 11 | timer = 0; 12 | length = _len; 13 | }, 14 | 15 | draw: function() { 16 | if(timer >= length) return; 17 | var _alpha = 1 - (timer / length); 18 | draw_rectangle_sprite(sprPixel, 0, 0, GUI_W, GUI_H, false, color, _alpha); 19 | timer++; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /Hooks/use_shake.gml: -------------------------------------------------------------------------------- 1 | ///@func use_shake() 2 | ///@dependencies: approach, sin_oscillate 3 | function use_shake(){ 4 | return { 5 | dir: 0, 6 | frequency: .1, 7 | amp: 0, 8 | falloff: 1, 9 | startTime: get_timer(), 10 | 11 | ///@func screenShake(dir,amp,[falloff], [frequency]) 12 | start: function(_dir, _amp, _falloff = 1, _frequency = .1) { 13 | dir = _dir; 14 | frequency = _frequency; 15 | amp = _amp; 16 | falloff = _falloff; 17 | startTime = get_timer(); 18 | }, 19 | 20 | update: function(){ 21 | if(amp == 0) return {x: 0, y: 0}; 22 | var _amp = sin_oscillate(-amp, amp, frequency) 23 | var _x = lengthdir_x(_amp, dir); 24 | var _y = lengthdir_y(_amp, dir); 25 | amp = approach(amp, 0, falloff); 26 | return {x: _x, y: _y} 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Macro Sets/scrViewMacros.gml: -------------------------------------------------------------------------------- 1 | #macro DISP_W display_get_width() 2 | #macro DISP_H display_get_height() 3 | #macro WIN_W window_get_width() 4 | #macro WIN_H window_get_height() 5 | 6 | #macro VIEW view_camera[0] 7 | #macro VIEW_X camera_get_view_x(VIEW) 8 | #macro VIEW_Y camera_get_view_y(VIEW) 9 | #macro VIEW_W camera_get_view_width(VIEW) 10 | #macro VIEW_H camera_get_view_height(VIEW) 11 | #macro VIEW_R (VIEW_X + VIEW_W) 12 | #macro VIEW_B (VIEW_Y + VIEW_H) 13 | #macro VIEW_CENTER_X (VIEW_X + VIEW_W/2) 14 | #macro VIEW_CENTER_Y (VIEW_Y + VIEW_H/2) 15 | 16 | #macro GUI_W display_get_gui_width() 17 | #macro GUI_H display_get_gui_height() -------------------------------------------------------------------------------- /Services/srvDisplay.gml: -------------------------------------------------------------------------------- 1 | ///PRE-ALPHA 2 | ///CONCEPT ONLY. UNTESTED 3 | global.display = { 4 | window: { 5 | width: DISP_W, 6 | height: DISP_H, 7 | refresh: call_later(5, time_source_units_frames, function(){ 8 | if(DISP_W == DISP_W_PREV && DISP_H == DISP_H_PREV) return; 9 | 10 | DISP_W_PREV= DISP_W; 11 | DISP_H_PREV = DISP_H; 12 | 13 | show_message("Window resized"); 14 | }, true) 15 | } 16 | } 17 | 18 | #macro DISP_W display_get_width() 19 | #macro DISP_H display_get_height() 20 | #macro WIN_W window_get_width() 21 | #macro WIN_H window_get_height() 22 | 23 | #macro VIEW view_camera[0] 24 | #macro VIEW_X camera_get_view_x(VIEW) 25 | #macro VIEW_Y camera_get_view_y(VIEW) 26 | #macro VIEW_W camera_get_view_width(VIEW) 27 | #macro VIEW_H camera_get_view_height(VIEW) 28 | #macro VIEW_R (VIEW_X + VIEW_W) 29 | #macro VIEW_B (VIEW_Y + VIEW_H) 30 | #macro VIEW_CENTER_X (VIEW_X + VIEW_W/2) 31 | #macro VIEW_CENTER_Y (VIEW_Y + VIEW_H/2) 32 | 33 | #macro GUI_W display_get_gui_width() 34 | #macro GUI_H display_get_gui_height() 35 | 36 | #macro DISP_W_PREV global.display.window.width 37 | #macro DISP_H_PREV global.display.window.height -------------------------------------------------------------------------------- /Services/srvEvent.gml: -------------------------------------------------------------------------------- 1 | #macro EVENTS global.events 2 | global.events = {}; 3 | 4 | ///@func event_add_listener(EventListener) 5 | function event_add_listener(_listener) { 6 | var _list = EVENTS[$ _listener]; 7 | if(_list == undefined) { 8 | _list = []; 9 | EVENTS[$ _listener.type] = _list; 10 | } 11 | array_push(_list, _listener); 12 | array_sort(_list, function(_a, _b){return _a.priority < _b.priority}); 13 | 14 | return _listener; 15 | } 16 | 17 | ///@func event_remove_listener(existing EventListerner instance) 18 | function event_remove_listener(_listener) { 19 | var _list = EVENTS[$ _listener.type]; 20 | for(var _i = 0; _i < array_length(_list); _i++) { 21 | if(_list[_i] != _listener) continue; 22 | 23 | array_delete(_list, _i, 1); 24 | return; 25 | } 26 | } 27 | 28 | ///@func event_raise(EventType, [data = undefined]) 29 | function event_raise(_type, _data = undefined) { 30 | var _list = EVENTS[$ _type]; 31 | for(var _i = 0; _i < array_length(_list); _i++) { 32 | var _listener = _list[_i]; 33 | var _instExists = instance_exists(_listener.owner); 34 | if(_instExists) 35 | _listener.callback(_data); 36 | if(!_instExists || _listener.onlyOnce) { 37 | array_delete(_list, _i, 1); 38 | _i--; 39 | } 40 | } 41 | } 42 | 43 | ///@func EventListener(callback, _type, [onlyOnce = false], [priority = 0], [owner = other.id]) 44 | function EventListener(_callback, _type, _onlyOnce = false, _priority = 0, _owner = other.id) constructor { 45 | type = _type; 46 | owner = _owner; 47 | callback = _callback; 48 | onlyOnce = _onlyOnce; 49 | priority = _priority; 50 | } 51 | 52 | function EventGameLoaded(_callback): EventListener(_callback, EventGameLoaded) constructor{} 53 | function EventLocationChanged(_callback): EventListener(_callback, EventGameLoaded) constructor{} 54 | function EventLanderReturned(_callback): EventListener(_callback, EventLanderReturned) constructor{} 55 | function EventLeftSystem(_callback): EventListener(_callback, EventLeftSystem) constructor{} 56 | function EventEnteredSystem(_callback): EventListener(_callback, EventEnteredSystem) constructor{} -------------------------------------------------------------------------------- /Services/srvJukebox.gml: -------------------------------------------------------------------------------- 1 | #macro JUKEBOX global.__jukebox 2 | JUKEBOX = { 3 | duckVolumeFactor: .25, 4 | priority: 100, 5 | volume: .75, 6 | 7 | queue: [], 8 | queuePosition: 0, 9 | queueCrossfadeLength: 2000, 10 | currentSong: noone, 11 | 12 | isDucked: false, 13 | currentVolume: 1, 14 | timeSource: noone, 15 | debugView: undefined 16 | } 17 | 18 | ///@function jukebox_change_settings([volume],[duckVolumeFactor],[songPriority]) 19 | function jukebox_change_settings(_volume = undefined, _duckVol = undefined, _priority = undefined){ 20 | if(_volume != undefined && _volume != JUKEBOX.volume){ 21 | JUKEBOX.volume = clamp(_volume, 0, 1); 22 | __jukebox_internal_update_volume(); 23 | } 24 | if(_duckVol != undefined){ 25 | JUKEBOX.duckVolumeFactor = _duckVol; 26 | __jukebox_internal_update_volume(); 27 | } 28 | if(_priority != undefined) JUKEBOX.priority = _priority; 29 | } 30 | 31 | ///@function jukebox_play_song(song, [fadeIn = 0ms], [fadeOut = 0ms], [crossfade = false]) 32 | function jukebox_play_song(_song, _fadeIn = 0, _fadeOut = 0, _cross = false){ 33 | if(!audio_is_playing(JUKEBOX.currentSong)){ 34 | __jukebox_internal_play(_song, _fadeIn); 35 | return; 36 | } 37 | 38 | if(audio_is_playing(_song)) return; 39 | 40 | if(_cross){ 41 | __jukebox_internal_stop(_fadeOut); 42 | __jukebox_internal_play(_song, _fadeIn); 43 | } else { 44 | __jukebox_internal_stop(_fadeOut, method({_song, _fadeIn}, function(){ __jukebox_internal_play(_song, _fadeIn); })) 45 | } 46 | } 47 | 48 | ///@function jukebox_stop_song([fadeOut = 0]); 49 | function jukebox_stop_song(_fadeOut = 0) { 50 | __jukebox_internal_stop(_fadeOut); 51 | JUKEBOX.currentSong = noone; 52 | } 53 | 54 | ///@function jukebox_toggle_duck([lengthMs = 0]) 55 | function jukebox_toggle_duck(_length = 0){ 56 | JUKEBOX.isDucked = !JUKEBOX.isDucked; 57 | audio_sound_gain(JUKEBOX.currentSong, JUKEBOX.volume * (JUKEBOX.isDucked ? JUKEBOX.duckVolumeFactor : 1), _length); 58 | JUKEBOX.currentVolume = JUKEBOX.volume * (JUKEBOX.isDucked ? JUKEBOX.duckVolumeFactor : 1); 59 | } 60 | 61 | ///@function jukebox_queue(song array, [clearQueue = false], [startNow = true]) 62 | function jukebox_queue(_songs, _clear = false, _startNow = true){ 63 | if(_clear) jukebox_queue_clear(); 64 | 65 | array_foreach(_songs, function(_x){ 66 | array_push(JUKEBOX.queue, _x); 67 | }) 68 | 69 | if(_startNow){ 70 | JUKEBOX.queuePosition = 0; 71 | __jukebox_internal_start(); 72 | } 73 | } 74 | 75 | ///@function jukebox_queue_start([track]) 76 | function jukebox_queue_start(_pos = JUKEBOX.queuePosition){ 77 | JUKEBOX.queuePosition = clamp(_pos, 0, array_length(JUKEBOX.queue)); 78 | __jukebox_internal_start(); 79 | } 80 | 81 | ///@function jukebox_queue_clear() 82 | function jukebox_queue_clear(){ 83 | JUKEBOX.queue = []; 84 | JUKEBOX.queuePosition = 0; 85 | } 86 | 87 | ///@function jukebox_play_next() 88 | function jukebox_play_next(){ 89 | if(time_source_exists(JUKEBOX.timeSource)) 90 | time_source_destroy(JUKEBOX.timeSource); 91 | JUKEBOX.queuePosition++; 92 | if(JUKEBOX.queuePosition >= array_length(JUKEBOX.queue)) 93 | JUKEBOX.queuePosition = 0; 94 | __jukebox_internal_start(); 95 | } 96 | 97 | ///@function jukebox_play_previous() 98 | function jukebox_play_previous(){ 99 | if(time_source_exists(JUKEBOX.timeSource)) 100 | time_source_destroy(JUKEBOX.timeSource); 101 | JUKEBOX.queuePosition--; 102 | if(JUKEBOX.queuePosition < 0) 103 | JUKEBOX.queuePosition = array_length(JUKEBOX.queue)-1; 104 | __jukebox_internal_start(); 105 | } 106 | 107 | ///@function jukebox_toggle_pause() 108 | function jukebox_toggle_pause(){ 109 | if(audio_is_paused(JUKEBOX.currentSong)){ 110 | audio_resume_sound(JUKEBOX.currentSong); 111 | if(time_source_exists(JUKEBOX.timeSource)) time_source_resume(JUKEBOX.timeSource); 112 | } else { 113 | audio_pause_sound(JUKEBOX.currentSong); 114 | if(time_source_exists(JUKEBOX.timeSource)) time_source_pause(JUKEBOX.timeSource); 115 | } 116 | } 117 | 118 | ///@func jukebox_debug(songArray) 119 | function jukebox_debug(_songs){ 120 | call_later(1, time_source_units_seconds, method({_songs}, function(){__jukebox_internal_debug(_songs)}), true); 121 | } 122 | 123 | ///@func jukebox_queue_debug() 124 | function jukebox_queue_debug(){ 125 | call_later(1, time_source_units_seconds, function(){__jukebox_internal_queue_debug()}, true); 126 | } 127 | 128 | function __jukebox_internal_update_volume(){ 129 | JUKEBOX.currentVolume = JUKEBOX.volume * (JUKEBOX.isDucked ? JUKEBOX.duckVolumeFactor : 1); 130 | if(!audio_is_playing(JUKEBOX.currentSong)) return; 131 | audio_sound_gain(JUKEBOX.currentSong, JUKEBOX.currentVolume, 0); 132 | } 133 | 134 | function __jukebox_internal_play(_song, _fadeIn, _loop = true){ 135 | var _bgm = audio_play_sound(_song, JUKEBOX.priority, _loop, _fadeIn == 0 ? JUKEBOX.currentVolume : 0); 136 | if(_fadeIn != 0) 137 | audio_sound_gain(_bgm, JUKEBOX.currentVolume, _fadeIn); 138 | JUKEBOX.currentSong = _bgm; 139 | } 140 | 141 | function __jukebox_internal_stop(_fadeOut, _onStop = function(){}){ 142 | if(!audio_is_playing(JUKEBOX.currentSong)) return; 143 | audio_sound_gain(JUKEBOX.currentSong, 0, _fadeOut); 144 | if(_fadeOut <=0){ 145 | audio_stop_sound(JUKEBOX.currentSong); 146 | _onStop(); 147 | return; 148 | } 149 | 150 | call_later( 151 | _fadeOut/1000, 152 | time_source_units_seconds, 153 | method({oldSong: JUKEBOX.currentSong, _onStop}, function(){ 154 | audio_stop_sound(oldSong) 155 | _onStop(); 156 | })) 157 | } 158 | 159 | function __jukebox_internal_start(){ 160 | if(array_length(JUKEBOX.queue) == 0) return; 161 | if(audio_is_playing(JUKEBOX.currentSong)) 162 | __jukebox_internal_stop(JUKEBOX.queueCrossfadeLength) 163 | 164 | __jukebox_internal_play(JUKEBOX.queue[ JUKEBOX.queuePosition], JUKEBOX.queueCrossfadeLength); 165 | var _length = audio_sound_length(JUKEBOX.currentSong); 166 | JUKEBOX.timeSource = time_source_create(time_source_global, _length, time_source_units_seconds, __jukebox_internal_on_song_end); 167 | time_source_start(JUKEBOX.timeSource); 168 | } 169 | 170 | function __jukebox_internal_on_song_end(){ 171 | jukebox_play_next(); 172 | } 173 | 174 | function __jukebox_internal_seconds_to_time(_seconds){ 175 | _seconds = round(_seconds); 176 | var _m = _seconds div 60; 177 | var _s = _seconds mod 60; 178 | return string("{0}:{1}{2}", _m, _s < 10 ? "0" : "", _s); 179 | } 180 | 181 | function __jukebox_internal_debug_volume_controls(){ 182 | var _size = 20; 183 | dbg_text("Volume") 184 | dbg_same_line() 185 | dbg_button("-", function(){ jukebox_change_settings(JUKEBOX.volume - .05) }, _size, _size); 186 | dbg_same_line() 187 | dbg_text(string(round(JUKEBOX.volume * 100))); 188 | dbg_same_line() 189 | dbg_button("+", function(){ jukebox_change_settings(JUKEBOX.volume + .05) }, _size, _size) 190 | } 191 | 192 | function __jukebox_internal_debug(_songs){ 193 | if(JUKEBOX.debugView != undefined) 194 | dbg_view_delete(JUKEBOX.debugView); 195 | 196 | JUKEBOX.debugView = dbg_view("Jukebox", true,20,100,600); 197 | var _isPlaying = audio_is_playing(JUKEBOX.currentSong); 198 | 199 | dbg_section(_isPlaying 200 | ? string("Currently Playing: {0} --- {1} / {2}", 201 | audio_get_name(JUKEBOX.currentSong), 202 | __jukebox_internal_seconds_to_time(audio_sound_get_track_position(JUKEBOX.currentSong)), 203 | __jukebox_internal_seconds_to_time(audio_sound_length(JUKEBOX.currentSong))) 204 | : "Currently Playing: --- 0:00 / 0:00"); 205 | __jukebox_internal_debug_volume_controls() 206 | if(_isPlaying){ 207 | dbg_button(audio_is_paused(JUKEBOX.currentSong) ? "Resume" : "Pause", function(){ 208 | jukebox_toggle_pause() 209 | }); 210 | dbg_same_line() 211 | dbg_button("Stop", function(){ 212 | jukebox_stop_song(); 213 | }); 214 | dbg_same_line() 215 | dbg_button(JUKEBOX.isDucked ? "Unduck" : "Duck", function(){ 216 | jukebox_toggle_duck(500); 217 | }); 218 | } 219 | dbg_section("Basic"); 220 | array_foreach(_songs, method({_songs}, function(_x, _i){ 221 | dbg_button(audio_get_name(_x), method({_x}, function(){ jukebox_play_song(_x, 0, 1000); })) 222 | if(_i != array_length(_songs)-1) 223 | dbg_same_line(); 224 | })) 225 | 226 | dbg_section("Cross Fade"); 227 | array_foreach(_songs, method({_songs}, function(_x, _i){ 228 | dbg_button(audio_get_name(_x), method({_x}, function(){ jukebox_play_song(_x, 2000, 2000, true); })) 229 | if(_i != array_length(_songs)-1) 230 | dbg_same_line(); 231 | })) 232 | } 233 | 234 | function __jukebox_internal_queue_debug(){ 235 | if(JUKEBOX.debugView != undefined) 236 | dbg_view_delete(JUKEBOX.debugView); 237 | 238 | JUKEBOX.debugView = dbg_view("Jukebox", true,20,100,600); 239 | 240 | dbg_section(string("Currently Playing: {0} --- {1} / {2}", 241 | audio_get_name(JUKEBOX.queue[JUKEBOX.queuePosition]), 242 | __jukebox_internal_seconds_to_time(audio_sound_get_track_position(JUKEBOX.currentSong)), 243 | __jukebox_internal_seconds_to_time(audio_sound_length(JUKEBOX.currentSong)))); 244 | 245 | __jukebox_internal_debug_volume_controls() 246 | 247 | dbg_button("Next",function(){ 248 | jukebox_play_next() 249 | }); 250 | dbg_same_line() 251 | dbg_button("Prev",function(){ 252 | jukebox_play_previous() 253 | }); 254 | dbg_same_line() 255 | dbg_button(audio_is_paused(JUKEBOX.currentSong) ? "Resume" : "Pause", function(){ 256 | jukebox_toggle_pause() 257 | }); 258 | dbg_same_line() 259 | dbg_button(JUKEBOX.isDucked ? "Unduck" : "Duck", function(){ 260 | jukebox_toggle_duck(500); 261 | }); 262 | 263 | dbg_section("Playlist"); 264 | array_foreach(JUKEBOX.queue, function(_x, _index){ 265 | dbg_text(string(" {0}: {1} {2}", _index+1, audio_get_name(_x), _index == JUKEBOX.queuePosition ? " < NOW PLAYING": "")); 266 | }); 267 | } 268 | -------------------------------------------------------------------------------- /Services/srvPause.gml: -------------------------------------------------------------------------------- 1 | function VisiblePauseManager() constructor{ 2 | __iPausedIds = []; 3 | static preDraw = function(){ 4 | array_foreach(__iPausedIds, function(_paused){ 5 | instance_activate_object(_paused.id); 6 | }) 7 | } 8 | 9 | static guiEnd = function(){ 10 | var _count = array_length(__iPausedIds); 11 | for(var _i = 0; _i < _count; _i++){ 12 | __iPausedIds[_i].length--; 13 | if(__iPausedIds[_i].length == 0){ 14 | array_delete(__iPausedIds, _i, 1); 15 | _i--; 16 | _count--; 17 | } else { 18 | instance_deactivate_object(__iPausedIds[_i].id); 19 | } 20 | } 21 | } 22 | 23 | static pauseObject = function(_id, _length = -1){ 24 | with(_id){ 25 | if(array_find_index(other.__iPausedIds, method({_id, _length}, function(_paused){ return _paused.id == _id})) != -1) continue; 26 | array_push(other.__iPausedIds, {id: _id, length: _length}); 27 | } 28 | } 29 | 30 | static unpauseObject = function(_id){ 31 | var _index = array_find_index(__iPausedIds, method({_id}, function(_paused){ return _paused.id == _id})); 32 | if(_index == -1) return; 33 | __iPausedIds[_index].length = 1; 34 | } 35 | 36 | static pauseTag = function(_tags, _length = -1){ 37 | var _objects = tag_get_asset_ids(_tags, asset_object) 38 | for(var _i = 0; _i < array_length(_objects); _i++){ 39 | pauseObject(_objects[_i]); 40 | } 41 | } 42 | 43 | static unpauseTag = function(_tags, _length = -1){ 44 | var _objects = tag_get_asset_ids(_tags, asset_object) 45 | for(var _i = 0; _i < array_length(_objects); _i++){ 46 | unpauseObject(_objects[_i]); 47 | } 48 | } 49 | } 50 | 51 | global.pauseManager = new VisiblePauseManager(); -------------------------------------------------------------------------------- /Services/srvSaveData.gml: -------------------------------------------------------------------------------- 1 | ///PRE-ALPHA 2 | ///CONCEPT ONLY. UNTESTED 3 | 4 | global.data = { 5 | 6 | } 7 | 8 | global.settings = { 9 | fullscreen: false, 10 | windowScale: 1, 11 | } 12 | 13 | #macro SETTINGS_FILE_NAME "settings.dat" 14 | #macro SETTINGS global.settings 15 | #macro SAVE_FILE_NAME "save.dat" 16 | #macro DATA global.data 17 | 18 | function __write_file(_filename, _data){ 19 | var _file = file_text_open_write(_filename) 20 | file_text_write_string(_file, json_stringify(_data)) 21 | file_text_close(_file); 22 | } 23 | 24 | function __load_file(_filename){ 25 | if(!file_exists(_filename)) { 26 | show_debug_message("File not found") 27 | return undefined; 28 | } 29 | 30 | var _file = file_text_open_read(_filename) 31 | var _data = json_parse(file_text_read_string(_file)) 32 | file_text_close(_file); 33 | return _data; 34 | } 35 | 36 | function save_data(_slot = 0){ 37 | __write_file(SAVE_FILE_NAME+string(_slot), global.data); 38 | } 39 | 40 | function load_data(_slot = 0){ 41 | global.data ??= __load_file(SAVE_FILE_NAME+string(_slot)); 42 | } 43 | 44 | function write_settings(){ 45 | __write_file(SETTINGS_FILE_NAME, global.settings); 46 | } 47 | 48 | function load_settings(){ 49 | global.settings ??= __load_file(SAVE_FILE_NAME+string(_slot)); 50 | } 51 | 52 | load_settings(); -------------------------------------------------------------------------------- /Systems and Examples/Camera Click Drag and Zoom.yyz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PixelatedPope/HelpfulGMLScripts/5f05b9329ab909563f9085d144d56ddbad5aa2e3/Systems and Examples/Camera Click Drag and Zoom.yyz -------------------------------------------------------------------------------- /Systems and Examples/Diablo Inventory.yyz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PixelatedPope/HelpfulGMLScripts/5f05b9329ab909563f9085d144d56ddbad5aa2e3/Systems and Examples/Diablo Inventory.yyz -------------------------------------------------------------------------------- /Systems and Examples/Distribute N Rectangles In Rectangle.yyz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PixelatedPope/HelpfulGMLScripts/5f05b9329ab909563f9085d144d56ddbad5aa2e3/Systems and Examples/Distribute N Rectangles In Rectangle.yyz -------------------------------------------------------------------------------- /Systems and Examples/NoiseGeneration.yymps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PixelatedPope/HelpfulGMLScripts/5f05b9329ab909563f9085d144d56ddbad5aa2e3/Systems and Examples/NoiseGeneration.yymps -------------------------------------------------------------------------------- /Systems and Examples/PixelPerfectScalingWithGraphicBorderAndFunctionalGui.yyz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PixelatedPope/HelpfulGMLScripts/5f05b9329ab909563f9085d144d56ddbad5aa2e3/Systems and Examples/PixelPerfectScalingWithGraphicBorderAndFunctionalGui.yyz -------------------------------------------------------------------------------- /Systems and Examples/ScalingShadersDemo.yyz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PixelatedPope/HelpfulGMLScripts/5f05b9329ab909563f9085d144d56ddbad5aa2e3/Systems and Examples/ScalingShadersDemo.yyz -------------------------------------------------------------------------------- /Systems and Examples/SequenceAnchorPointsTest.yyz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PixelatedPope/HelpfulGMLScripts/5f05b9329ab909563f9085d144d56ddbad5aa2e3/Systems and Examples/SequenceAnchorPointsTest.yyz -------------------------------------------------------------------------------- /Systems and Examples/SoftShadowSurfaceBlending.yyz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PixelatedPope/HelpfulGMLScripts/5f05b9329ab909563f9085d144d56ddbad5aa2e3/Systems and Examples/SoftShadowSurfaceBlending.yyz -------------------------------------------------------------------------------- /Systems and Examples/VeryBasicMasking.yyz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PixelatedPope/HelpfulGMLScripts/5f05b9329ab909563f9085d144d56ddbad5aa2e3/Systems and Examples/VeryBasicMasking.yyz -------------------------------------------------------------------------------- /Systems and Examples/Visible Pausing.yymps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PixelatedPope/HelpfulGMLScripts/5f05b9329ab909563f9085d144d56ddbad5aa2e3/Systems and Examples/Visible Pausing.yymps -------------------------------------------------------------------------------- /Systems and Examples/VisiblePausing.yyz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PixelatedPope/HelpfulGMLScripts/5f05b9329ab909563f9085d144d56ddbad5aa2e3/Systems and Examples/VisiblePausing.yyz -------------------------------------------------------------------------------- /Systems and Examples/resolution_picker.yyz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PixelatedPope/HelpfulGMLScripts/5f05b9329ab909563f9085d144d56ddbad5aa2e3/Systems and Examples/resolution_picker.yyz -------------------------------------------------------------------------------- /_Maybe Not that great/DS Scripts/ds_grid_add_row.gml: -------------------------------------------------------------------------------- 1 | ///ds_grid_add_row(grid index) 2 | //Adds a row to the grid and returns the index of the new row 3 | var _grid = argument[0]; 4 | ds_grid_resize(_grid,ds_grid_width(_grid),ds_grid_height(_grid)+1); 5 | return(ds_grid_height(_grid)-1); 6 | -------------------------------------------------------------------------------- /_Maybe Not that great/DS Scripts/ds_grid_change_orientation.gml: -------------------------------------------------------------------------------- 1 | /// @description ds_grid_change_orientation(grid) 2 | /// @param {real} grid 3 | 4 | var _grid = argument0; 5 | var _w = ds_grid_width(_grid); 6 | var _h = ds_grid_height(_grid); 7 | 8 | var _new_grid = ds_grid_create(_h,_w); 9 | 10 | for(var _y = 0; _y < _h; _y++) 11 | { 12 | for(var _x = 0; _x < _w; _x++) 13 | { 14 | var _value = _grid[# _x,_y]; 15 | _new_grid[# _y,_x]=_value; 16 | } 17 | } 18 | 19 | ds_grid_copy(_grid,_new_grid); 20 | ds_grid_destroy(_new_grid); 21 | -------------------------------------------------------------------------------- /_Maybe Not that great/DS Scripts/ds_grid_crop.gml: -------------------------------------------------------------------------------- 1 | ///ds_grid_crop(grid, croppable value,margin); 2 | //Cuts all of the unneeded space out of the grid. Returns a copy of the cropped grid. 3 | var _grid = argument0; 4 | var _val = argument1; 5 | var _margin = argument2; 6 | //Find the bounds 7 | var _min_x = 100000; 8 | var _max_x = -1; 9 | var _min_y = 100000; 10 | var _max_y = -1; 11 | 12 | for (var _x = 0; _x < ds_grid_width(_grid); _x++) 13 | { 14 | for (var _y = 0; _y < ds_grid_height(_grid); _y++) 15 | { 16 | if (_grid[#_x, _y] != _val) 17 | { 18 | if (_x < _min_x) _min_x = _x; 19 | if (_x > _max_x) _max_x = _x; 20 | if (_y < _min_y) _min_y = _y; 21 | if (_y > _max_y) _max_y = _y; 22 | } 23 | } 24 | } 25 | var _cropped_grid = ds_grid_create(_max_x - _min_x + 1 + _margin * 2, _max_y - _min_y + 1 + _margin * 2); 26 | ds_grid_set_grid_region(_cropped_grid,_grid, 27 | _min_x - _margin, _min_y - _margin, 28 | _max_x + 1 + _margin, _max_y + 1 + _margin, 29 | 0, 0); 30 | ds_grid_destroy(_grid); 31 | return _cropped_grid; -------------------------------------------------------------------------------- /_Maybe Not that great/DS Scripts/ds_grid_delete_row.gml: -------------------------------------------------------------------------------- 1 | ///ds_grid_delete_row(grid index, row) 2 | //Returns a copy of the grid with the given row removed. 3 | //Destroys the original grid. So stop using it. 4 | 5 | var grid = argument0; 6 | var row = argument1; 7 | var grid_width=ds_grid_width(grid); 8 | var grid_height=ds_grid_height(grid); 9 | 10 | if(row>ds_grid_height(grid)-1) 11 | { 12 | return(grid); 13 | show_debug_message("You tried to delete a row from a grid that didn't exist"); 14 | } 15 | 16 | if(ds_grid_height(grid)>1) 17 | { //More than one row in the grid 18 | var tempgrid=ds_grid_create(ds_grid_width(grid),ds_grid_height(grid)); 19 | ds_grid_copy(tempgrid,grid); 20 | ds_grid_destroy(grid); 21 | ds_grid_set_region(tempgrid,0,row,ds_grid_width(tempgrid)-1,row,0); 22 | 23 | ds_grid_set_grid_region(tempgrid, tempgrid, 0, row+1, grid_width-1, grid_height-1, 0,row); 24 | 25 | ds_grid_resize(tempgrid,grid_width,grid_height-1); 26 | return tempgrid; 27 | } 28 | else 29 | return ds_grid_create(ds_grid_width(grid),0); 30 | -------------------------------------------------------------------------------- /_Maybe Not that great/DS Scripts/ds_grid_draw.gml: -------------------------------------------------------------------------------- 1 | ///ds_grid_draw(grid,x,y,headers list ,Show Row Numbers, Starting Row <0 by default>, Row Count <-1 for all>) 2 | //Draws the content of the grid as a table. 3 | //Not the most efficient script: USE ONLY FOR DEBUGGING! 4 | 5 | var _grid = argument[0]; 6 | var _x = argument[1]; 7 | var _y = argument[2]; 8 | var _headers=argument[3]; 9 | var _show_row_numbers=argument[4]; 10 | var _start_row=clamp(argument[5],0,ds_grid_height(_grid)-1); 11 | var _max_count; 12 | if(argument[6]<0) 13 | _max_count=ds_grid_height(_grid); 14 | else 15 | _max_count=clamp(argument[6],1,ds_grid_height(_grid)-1); 16 | 17 | if(ds_grid_height(_grid)-_start_row < _max_count) 18 | { 19 | _start_row=ds_grid_height(_grid)-_max_count; 20 | } 21 | 22 | 23 | var _padding = 5; 24 | var _spacer = "| "; 25 | 26 | var _header_height=0; 27 | 28 | var _column_widths, _row_heights; 29 | 30 | //Get column widths 31 | //init column_widths and row_heights array 32 | for (var _xx = 0; _xx < ds_grid_width(_grid); _xx++) 33 | { 34 | _column_widths[_xx] = 0; 35 | } 36 | for (var _yy = 0; _yy < ds_grid_height(_grid); _yy++) 37 | { 38 | _row_heights[_yy] = 0; 39 | } 40 | 41 | //Find max column widths and max row heights 42 | var _cw = 0; 43 | var _ch = 15; 44 | for (var _xx = 0; _xx < ds_grid_width(_grid); _xx++) 45 | { 46 | for (var _yy = 0; _yy < ds_grid_height(_grid); _yy++) 47 | { 48 | _cw = string_width(_spacer + string(ds_grid_get(_grid, _xx, _yy))); 49 | _ch = string_height(string(ds_grid_get(_grid, _xx, _yy))); 50 | if (_cw > _column_widths[_xx]) 51 | _column_widths[_xx] = _cw; 52 | if (_ch > _row_heights[_yy]) 53 | { 54 | _row_heights[_yy] = _ch; 55 | } 56 | } 57 | } 58 | 59 | if(_headers != noone) 60 | { //Add Column Headers 61 | for(var _i=0; _i _column_widths[_i]) 67 | _column_widths[_i]=_w; 68 | if(_h > _header_height) 69 | _header_height=_h; 70 | } 71 | } 72 | 73 | //Actually Draw the grid; 74 | draw_set_valign(fa_top); 75 | draw_set_halign(fa_left); 76 | var _y_orig=_y; 77 | for(var _xx=0; _xx= _w) 64 | { 65 | _xa = _x - 1; 66 | _xb = _w - 1; 67 | _valid_switch = true; 68 | } 69 | else 70 | { 71 | _xa = _x - 1; 72 | _xb = _x + 1; 73 | } 74 | 75 | if (_y - 1 < 0) 76 | { 77 | _ya = 0; 78 | _yb = _y + 1; 79 | _valid_switch = true; 80 | } 81 | else if (_y + 1 >= _h) 82 | { 83 | _ya = _y - 1; 84 | _yb = _h - 1; 85 | _valid_switch = true; 86 | } 87 | else 88 | { 89 | _ya = _y - 1; 90 | _yb = _y + 1; 91 | } 92 | 93 | if (_valid_switch) 94 | { 95 | if (_valid) 96 | { //Found the edge of the grid, this region isn't valid. 97 | ds_list_replace(_region_valid, _incr, false); 98 | _valid = false; 99 | } 100 | _valid_switch = false; 101 | } 102 | 103 | //Look at 8 adjacent cells 104 | for (_yy = _ya; _yy <= _yb; _yy++) 105 | { 106 | for (_xx = _xa; _xx <= _xb; _xx++) 107 | { 108 | if (_xx == _x) and(_yy == _y) 109 | continue; 110 | if (ds_grid_get(_regions, _xx, _yy) == noone) 111 | ds_queue_enqueue(_queue, _xx + _yy * _w); 112 | } 113 | } 114 | } 115 | } 116 | 117 | ds_queue_destroy(_queue); 118 | ds_map_destroy(_empty_cells); 119 | 120 | var result; 121 | result[0] = _regions; 122 | result[1] = _region_valid; 123 | 124 | //show_debug_message("time: " + string(get_timer() - t)); 125 | 126 | return result; 127 | -------------------------------------------------------------------------------- /_Maybe Not that great/DS Scripts/ds_grid_get_adjacent_count.gml: -------------------------------------------------------------------------------- 1 | ///ds_grid_get_adjacent_count(grid, x, y, number,is 8 dir ); 2 | //return the number cells above, below, left and right that match the given number. 3 | //If "is 4 dir" is set to true, will only check cardinal directions. 4 | //Otherwise, will check diagonal connections as well. 5 | 6 | var _grid=argument[0]; 7 | var _x=argument[1]; 8 | var _y=argument[2]; 9 | var _num=argument[3]; 10 | var _8dir=false; 11 | if(argument_count>4) 12 | _8dir=argument[4]; 13 | 14 | var _count=0; 15 | for(var _i=0;_i<3+4*_8dir;_i++) 16 | { 17 | var _xx=_x+lengthdir_x(1,_i*90-45*_8dir); 18 | var _yy=_y+lengthdir_y(1,_i*90*_8dir); 19 | if(ds_grid_in_bounds(_grid,_xx,_yy)) 20 | { 21 | var _val=_grid[# _xx,_yy]; 22 | if(_val == _num) 23 | _count++; 24 | } 25 | } 26 | return(_count); 27 | -------------------------------------------------------------------------------- /_Maybe Not that great/DS Scripts/ds_grid_in_bounds.gml: -------------------------------------------------------------------------------- 1 | ///ds_grid_in_bounds(grid,x,y) 2 | //returns true if the given coordinates are available within the grid. 3 | var _grid=argument[0]; 4 | var _x = argument[1]; 5 | var _y= argument[2]; 6 | 7 | return(!(_x<0 || 8 | _x>ds_grid_width(_grid)-1 || 9 | _y<0 || 10 | _y>ds_grid_height(_grid)-1)); 11 | -------------------------------------------------------------------------------- /_Maybe Not that great/DS Scripts/ds_grid_insert_row.gml: -------------------------------------------------------------------------------- 1 | ///ds_grid_insert_row(index,row position) 2 | //Inserts a row in the grid at the given position. 3 | 4 | var _grid = argument[0]; 5 | //show_debug_message("Resizing grid for insert..."); 6 | ds_grid_resize(_grid,ds_grid_width(_grid),ds_grid_height(_grid)+1); 7 | 8 | 9 | var _row = argument[1]; 10 | ds_grid_set_grid_region(_grid,_grid,0,_row,ds_grid_width(_grid),ds_grid_height(_grid)-1-_row, 11 | 0,_row+1); 12 | //show_debug_message("Insert Complete!"); 13 | -------------------------------------------------------------------------------- /_Maybe Not that great/DS Scripts/ds_grid_is_in_bounds.gml: -------------------------------------------------------------------------------- 1 | ///ds_grid_is_in_bounds(grid,x,y) 2 | //Returns true if the coordinate given is within the bounds of the ds_grid. 3 | var _grid=argument[0]; 4 | var _w=ds_grid_width(_grid); 5 | var _h=ds_grid_height(_grid); 6 | 7 | return(argument[1] >= 0 && argument[2] >= 0 && 8 | argument[1] < _w && argument[2] < _h); 9 | 10 | -------------------------------------------------------------------------------- /_Maybe Not that great/DS Scripts/ds_grid_replace_value.gml: -------------------------------------------------------------------------------- 1 | /// @description ds_grid_replace_value 2 | /// @param grid 3 | /// @param current_value 4 | /// @param replace_value 5 | 6 | var _grid = argument0; 7 | var _w = ds_grid_width(_grid); 8 | var _h = ds_grid_height(_grid); 9 | for(var _x = 0; _x<_w; _x++) 10 | { 11 | for(var _y = 0; _y<_h; _y++) 12 | { 13 | if( _grid[# _x,_y] == argument1) 14 | _grid[#_x,_y] = argument2; 15 | } 16 | } -------------------------------------------------------------------------------- /_Maybe Not that great/DS Scripts/ds_grid_sort_row.gml: -------------------------------------------------------------------------------- 1 | /// @description ds_grid_sort_row(_grid, row, ascending?) 2 | /// @param {real} grid 3 | /// @param {real} row 4 | /// @param {bool} ascending? 5 | 6 | var _grid = argument0; 7 | var _row = argument1; 8 | var _dir = argument2; 9 | 10 | ds_grid_change_orientation(_grid); 11 | ds_grid_sort(_grid,_row,_dir); 12 | ds_grid_change_orientation(_grid); -------------------------------------------------------------------------------- /_Maybe Not that great/DS Scripts/ds_grid_value_row.gml: -------------------------------------------------------------------------------- 1 | ///ds_grid_value_row(grid,column,value) 2 | //Returns the row number where the value was found. 3 | //If multiple exist, the first one found will be returned. 4 | //Returns noone if not found. 5 | var _grid=argument[0]; 6 | var _column=argument[1]; 7 | var _val=argument[2]; 8 | 9 | if(ds_grid_value_exists(_grid,_column,0,_column,ds_grid_height(_grid)-1,_val)) 10 | return(ds_grid_value_y(_grid,_column,0,_column,ds_grid_height(_grid)-1,_val)); 11 | else 12 | return(noone); 13 | -------------------------------------------------------------------------------- /_Maybe Not that great/DS Scripts/ds_list_add_list.gml: -------------------------------------------------------------------------------- 1 | ///ds_list_add_list(list, source) 2 | //Adds all the values from the source list to the target list. 3 | var _tar=argument[0]; 4 | var _source=argument[1]; 5 | for(var _i=0; _i=0; _i--) 8 | { 9 | if(_list[| _i] == _val) 10 | { 11 | _count ++; 12 | } 13 | } 14 | return (_count); 15 | -------------------------------------------------------------------------------- /_Maybe Not that great/DS Scripts/ds_list_create_number_list.gml: -------------------------------------------------------------------------------- 1 | ///ds_list_create_number_list(count) 2 | //Returns a list made up of numbers from 0 to count-1. 3 | var _list=ds_list_create(); 4 | for(var _i=0; _i=0; _i--) 7 | { 8 | if(_list[| _i] == _val) 9 | { 10 | ds_list_delete(_list,_i); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /_Maybe Not that great/DS Scripts/ds_list_value_exists.gml: -------------------------------------------------------------------------------- 1 | ///ds_list_value_exists(id,value) 2 | var _exists=ds_list_find_index(argument0,argument1)==-1; 3 | return(!_exists); 4 | -------------------------------------------------------------------------------- /_Maybe Not that great/TwerpFriends/arc.gml: -------------------------------------------------------------------------------- 1 | /// @description arc(start, peak, end, position, bias) 2 | /// @function arc 3 | /// @param start 4 | /// @param peak 5 | /// @param end 6 | /// @param position 7 | /// @param bias 8 | /// DEPENDS ON INTERPOLATE SCRIPT 9 | var _p = clamp(argument3,0,1); 10 | if(argument3 <= .5) 11 | { 12 | _p=_p*2; 13 | return interpolate(argument0,argument1,_p,argument4); 14 | } 15 | else 16 | { 17 | //var b=1-argument4; 18 | _p=2*_p-1; 19 | return interpolate(argument1,argument2,_p,1-argument4); 20 | } 21 | -------------------------------------------------------------------------------- /_Maybe Not that great/TwerpFriends/bias.gml: -------------------------------------------------------------------------------- 1 | /// @description bias(bias, value) 2 | /// @function bias 3 | /// @param bias 4 | /// @param value 5 | /* 6 | ** Usage: 7 | ** bias(b,t) 8 | ** 9 | ** Arguments: 10 | ** b bais, real 11 | ** t value, real 12 | ** 13 | ** Returns: 14 | ** If (t) varies over the [0,1] interval, then 15 | ** the result also varies over that interval. 16 | ** The zero and one endpoints of the interval 17 | ** are mapped onto themselves. Other values 18 | ** are shifted upward toward one if (b) is 19 | ** greater than 0.5, and shifted downward 20 | ** toward zero if (b) is between 0.0 and 0.5. 21 | ** 22 | ** GMLscripts.com 23 | */ 24 | { 25 | var _b=clamp(argument0,.0000000001,.999999999); 26 | return argument1/((1/_b-2)*(1-argument1)+1); 27 | } 28 | -------------------------------------------------------------------------------- /_Maybe Not that great/TwerpFriends/blink.gml: -------------------------------------------------------------------------------- 1 | /// @description blink(time, blink length) 2 | /// @function blink 3 | /// @param time 4 | /// @param blink length 5 | //Blinks true/false evenly given a timer 6 | //For example, if you give it a length of 60 and a timer that counts up 7 | //by 1 every step, you would get false for 30 steps, then true for 30 steps, repeating forever. 8 | return sin(argument0*pi/argument1)>=0 9 | -------------------------------------------------------------------------------- /_Maybe Not that great/TwerpFriends/cubic_bezier.gml: -------------------------------------------------------------------------------- 1 | /// @description cubic_bezier(start,end,position,x1,y1,x2,y2) 2 | /// @function cubic_bezier 3 | /// @param start 4 | /// @param end 5 | /// @param position 6 | /// @param x1 7 | /// @param y1 8 | /// @param x2 9 | /// @param y2 10 | var eps = math_get_epsilon(); 11 | math_set_epsilon(.000000000000001); 12 | 13 | var pos=clamp(argument2,0,1);; 14 | var p0,p1,p2,p3; 15 | p0=0; 16 | p1=clamp(argument3,0,1); 17 | p2=clamp(argument5,0,1); 18 | p3=1; 19 | 20 | // Determine t 21 | var t; 22 | if (pos == 0) 23 | t=0; 24 | else if (pos == 1) 25 | t=1; 26 | else 27 | { // Calculate t 28 | var a = -p0 + 3 * p1 - 3 * p2 + p3; 29 | var b = 3 * p0 - 6 * p1 + 3 * p2; 30 | var c = -3 * p0 + 3 * p1; 31 | var d = p0 - pos; 32 | var temp = solve_cubic(a,b,c,d); 33 | if(temp == noone) 34 | { 35 | math_set_epsilon(eps); 36 | return noone; 37 | } 38 | else 39 | t = temp; 40 | } 41 | 42 | // Calculate y from t 43 | p1=argument4; 44 | p2=argument6; 45 | var u=1-t; 46 | var result= u*u*u * p0 47 | + 3 * t * u*u * p1 48 | + 3 * t*t * u * p2 49 | + t*t*t * p3; 50 | 51 | math_set_epsilon(eps); 52 | return lerp(argument0,argument1,result); 53 | 54 | -------------------------------------------------------------------------------- /_Maybe Not that great/TwerpFriends/interpolate.gml: -------------------------------------------------------------------------------- 1 | /// @description interpolate(val 1, val 2, position, bias) 2 | /// @function interpolate 3 | /// @param val 1 4 | /// @param val 2 5 | /// @param position 6 | /// @param bias 7 | return(lerp(argument0,argument1,bias(argument3,argument2))); 8 | -------------------------------------------------------------------------------- /_Maybe Not that great/TwerpFriends/solve_cubic.gml: -------------------------------------------------------------------------------- 1 | var a = argument0; 2 | var b = argument1; 3 | var c = argument2; 4 | var d = argument3; 5 | 6 | if (a == 0) 7 | return solve_quadratic(b, c, d); 8 | if (d == 0) 9 | { 10 | show_debug_message("d == 0"); 11 | return 0; 12 | } 13 | b /= a; 14 | c /= a; 15 | d /= a; 16 | var q = (3.0 * c - (b*b)) / 9.0; 17 | var r = (-27.0 * d + b * (9.0 * c - 2.0 * (b * b))) / 54.0; 18 | var disc = q*q*q + r*r; 19 | var term1 = b / 3.0; 20 | 21 | if (disc > 0) 22 | { 23 | var s = r + sqrt(disc); 24 | if(s<0) 25 | s=-power(-s,1/3); 26 | else 27 | s=power(s,1/3); 28 | 29 | var t = r - sqrt(disc); 30 | if(t<0) 31 | t = -power(-t,1/3); 32 | else 33 | t = power(t,1/3); 34 | 35 | var result = -term1 + s + t; 36 | if (result >= 0 && result <= 1) 37 | return result; 38 | } 39 | else if (disc == 0) 40 | { 41 | var r13 42 | if(r<0) 43 | r13 = -power(-r,1/3); 44 | else 45 | r13 = power(r,1/3); 46 | 47 | var result = -term1 + 2.0 * r13; 48 | if (result >= 0 && result <= 1) 49 | return result; 50 | 51 | result = -(r13 + term1); 52 | if (result >= 0 && result <= 1) 53 | return result; 54 | } 55 | else 56 | { 57 | q = -q; 58 | var dum1 = q * q * q; 59 | dum1 = arccos(r / sqrt(dum1)); 60 | var r13 = 2.0 * sqrt(q); 61 | 62 | var result = -term1 + r13 * cos(dum1 / 3.0); 63 | if (result >= 0 && result <= 1) 64 | return result; 65 | 66 | result = -term1 + r13 *cos((dum1 + 2.0 * pi) / 3.0); 67 | if (result >= 0 && result <= 1) 68 | return result; 69 | 70 | result = -term1 + r13 * cos((dum1 + 4.0 * pi) / 3.0); 71 | if (result >= 0 && result <= 1) 72 | return result; 73 | } 74 | 75 | show_debug_message("Disc:" +string(disc)); 76 | return noone; 77 | 78 | -------------------------------------------------------------------------------- /_Maybe Not that great/TwerpFriends/solve_quadratic.gml: -------------------------------------------------------------------------------- 1 | var a=argument0; 2 | var b=argument1; 3 | var c=argument2; 4 | 5 | var result = (-b + sqrt((b*b) - 4 * a * c)) / (2 * a); 6 | if (result >= 0 && result <= 1) 7 | return result; 8 | 9 | result = (-b - sqrt((b * b) - 4 * a * c)) / (2 * a); 10 | if (result >= 0 && result <= 1) 11 | return result; 12 | 13 | show_debug_message("quadratic returning -4"); 14 | return noone; 15 | -------------------------------------------------------------------------------- /_Maybe Not that great/TwerpFriends/twerp.gml: -------------------------------------------------------------------------------- 1 | ///@func twerp(TwerpType, start, end, pos, [looped], [option1], [option2]); 2 | function twerp(_type, _start, _end, _pos, _looped = false) { 3 | _type = clamp(_type,0,TwerpType.count); 4 | _pos = clamp(_looped ? _pos % 1 : _pos,0,1); 5 | var _chng = _end-_start; 6 | var _mid = (_start+_end) / 2; 7 | 8 | #region Tween Types 9 | enum TwerpType 10 | { 11 | linear, 12 | inout_back, in_back, out_back, 13 | inout_bounce, out_bounce, in_bounce, 14 | inout_circle, out_circle, in_circle, 15 | inout_cubic, out_cubic, in_cubic, 16 | inout_elastic, out_elastic, in_elastic, 17 | inout_expo, out_expo, in_expo, 18 | inout_quad, out_quad, in_quad, 19 | inout_quart, out_quart, in_quart, 20 | inout_quint, out_quint, in_quint, 21 | inout_sine, out_sine, in_sine, 22 | count 23 | } 24 | #endregion 25 | 26 | switch(_type) 27 | { 28 | case TwerpType.linear: return lerp(_start,_end,_pos); //Why are you using this? 29 | #region Back 30 | // Optional Argument: Bounciness - Default: 1.5 31 | #macro Twerp_Back_DefaultBounciness 1.5 32 | case TwerpType.inout_back: 33 | var _b = (argument_count > 5) ? argument[5] : Twerp_Back_DefaultBounciness; 34 | return (_pos < .5) ? twerp(TwerpType.in_back,_start,_mid,_pos*2,_b) 35 | : twerp(TwerpType.out_back,_mid,_end,(_pos-.5)*2,_b); 36 | 37 | case TwerpType.in_back: 38 | var _b = (argument_count > 5) ? argument[5] : Twerp_Back_DefaultBounciness; 39 | return _chng * _pos * _pos * ((_b + 1) * _pos - _b) + _start 40 | 41 | case TwerpType.out_back: 42 | var _b = (argument_count > 5) ? argument[5] : Twerp_Back_DefaultBounciness; 43 | _pos -= 1; 44 | return _chng * (_pos * _pos * ((_b + 1) * _pos + _b) + 1) + _start; 45 | 46 | #endregion 47 | #region Bounce 48 | //No Optional Arguments 49 | #macro Twerp_Bounce_DefaultBounciness 7.5625 50 | 51 | case TwerpType.inout_bounce: 52 | return (_pos < 0.5) ? twerp(TwerpType.in_bounce,_start, (_start + _end) / 2, _pos*2) 53 | : twerp(TwerpType.out_bounce,(_start + _end) / 2, _end, (_pos-.5)*2); 54 | 55 | case TwerpType.out_bounce: 56 | if (_pos < 1/2.75) 57 | return _chng * (Twerp_Bounce_DefaultBounciness * _pos * _pos) + _start; 58 | else if (_pos < 2/2.75) 59 | { 60 | _pos -= 1.5/2.75; 61 | return _chng * (Twerp_Bounce_DefaultBounciness * _pos * _pos + 3/4) + _start; 62 | } 63 | else if (_pos < 2.5/2.75) 64 | { 65 | _pos -= 2.25/2.75; 66 | return _chng * (Twerp_Bounce_DefaultBounciness * _pos * _pos + 15/16) + _start; 67 | } 68 | 69 | _pos -= 2.625/2.75; 70 | return _chng * (Twerp_Bounce_DefaultBounciness * _pos * _pos + 63/64) + _start; 71 | 72 | case TwerpType.in_bounce: 73 | _chng = _end-_pos; 74 | _pos = 1-_pos; 75 | return _chng - twerp(TwerpType.out_bounce,_start,_end,_pos,Twerp_Bounce_DefaultBounciness)+_start; 76 | 77 | #endregion 78 | #region Circle 79 | //No Optional Arguments 80 | case TwerpType.inout_circle: 81 | return (_pos < .5) ? twerp(TwerpType.in_circle,_start,_mid,_pos*2) 82 | : twerp(TwerpType.out_circle,_mid,_end,(_pos-.5)*2); 83 | 84 | case TwerpType.out_circle: 85 | _pos--; 86 | return _chng * sqrt(1 - _pos * _pos) + _start; 87 | 88 | case TwerpType.in_circle: 89 | return -_chng * (sqrt(1 - _pos*_pos)-1) + _start; 90 | 91 | #endregion 92 | #region Cubic 93 | //No Optional Arguments 94 | case TwerpType.inout_cubic: 95 | return (_pos < .5) ? twerp(TwerpType.in_cubic,_start,_mid,_pos*2) 96 | : twerp(TwerpType.out_cubic,_mid,_end,(_pos-.5)*2); 97 | case TwerpType.out_cubic: 98 | return _chng * (power(_pos - 1, 3) + 1) + _start; 99 | case TwerpType.in_cubic: 100 | return _chng * power(_pos, 3) + _start; 101 | #endregion 102 | #region Elastic 103 | // Optional Argument 1: Elasticity <0-1> - Default: .3 104 | // Optional Argument 2: Duration - Default: 5 105 | case TwerpType.inout_elastic: 106 | var _e = (argument_count > 5) ? argument[5] : 0.3; 107 | var _d = (argument_count > 6) ? argument[6] : 5.0; 108 | 109 | return (_pos < .5) ? twerp(TwerpType.in_elastic,_start,_mid,_pos*2,_e,_d) 110 | : twerp(TwerpType.out_elastic,_mid,_end,(_pos-.5)*2,_e,_d); 111 | 112 | case TwerpType.out_elastic: 113 | var _s,_p; 114 | var _e = (argument_count > 5) ? argument[5] : 0.3; 115 | var _d = (argument_count > 6) ? argument[6] : 5.0; 116 | 117 | if (_pos == 0 || _chng == 0) return _start; 118 | if (_pos == 1) return _end; 119 | 120 | _p = _d * _e; 121 | _s = (sign(_chng) == -1) ? _p * 0.25 : _p / (2 * pi) * arcsin (1); 122 | 123 | return _chng * power(2, -10 * _pos) * sin((_pos * _d - _s) * (2 * pi) / _p ) + _chng + _start; 124 | case TwerpType.in_elastic: 125 | var _s,_p; 126 | 127 | var _e = (argument_count > 5) ? argument[5] : 0.3; 128 | var _d = (argument_count > 6) ? argument[6] : 5.0; 129 | 130 | if (_pos == 0 || _chng == 0) return _start; 131 | if (_pos == 1) return _end; 132 | 133 | _p = _d * _e; 134 | _s = sign(_chng) == -1 ? _p * 0.25 : _p / (2 * pi) * arcsin(1); 135 | 136 | return -(_chng * power(2,10 * (--_pos)) * sin((_pos * _d - _s) * (pi * 2) / _p)) + _start; 137 | 138 | #endregion 139 | #region Expo 140 | //No Optional arguments 141 | case TwerpType.inout_expo: 142 | return (_pos < .5) ? twerp(TwerpType.in_expo,_start,_mid,_pos*2) 143 | : twerp(TwerpType.out_expo,_mid,_end,(_pos-.5)*2); 144 | 145 | case TwerpType.out_expo: 146 | return _chng * (-power(2, -10 * _pos) + 1) + _start; 147 | 148 | case TwerpType.in_expo: 149 | return _chng * power(2, 10 * (_pos - 1)) + _start; 150 | 151 | #endregion 152 | #region Quad 153 | //No Optional Arguments 154 | case TwerpType.inout_quad: 155 | return (_pos < .5) ? twerp(TwerpType.in_quad,_start,_mid,_pos*2) 156 | : twerp(TwerpType.out_quad,_mid,_end,(_pos-.5)*2); 157 | case TwerpType.out_quad: 158 | return -_chng * _pos * (_pos - 2) + _start; 159 | 160 | case TwerpType.in_quad: 161 | return _chng * _pos * _pos + _start; 162 | 163 | #endregion 164 | #region Quart 165 | //No Optional Arguments 166 | case TwerpType.inout_quart: 167 | return (_pos < .5) ? twerp(TwerpType.in_quart,_start,_mid,_pos*2) 168 | : twerp(TwerpType.out_quart,_mid,_end,(_pos-.5)*2); 169 | 170 | case TwerpType.out_quart: 171 | return -_chng * (((_pos - 1) * (_pos - 1) * (_pos - 1) * (_pos - 1)) - 1) + _start; 172 | 173 | case TwerpType.in_quart: 174 | return _chng * (_pos * _pos * _pos * _pos) + _start; 175 | 176 | #endregion 177 | #region Quint 178 | //No Optional Arguments 179 | case TwerpType.inout_quint: 180 | return _pos < .5 ? twerp(TwerpType.in_quint,_start,_mid,_pos*2) 181 | : twerp(TwerpType.out_quint,_mid,_end,(_pos-.5)*2); 182 | 183 | case TwerpType.out_quint: 184 | 185 | return _chng * ((_pos - 1) * (_pos -1) * (_pos -1) * (_pos -1) * (_pos -1) + 1) + _start; 186 | 187 | case TwerpType.in_quint: 188 | return _chng * _pos * _pos * _pos * _pos * _pos + _start; 189 | 190 | #endregion 191 | #region Sine 192 | //No Optional Arguments 193 | #macro Twerp_Sine_Half_Pi 1.57079632679 194 | case TwerpType.inout_sine: 195 | return _chng * 0.5 * (1 - cos(pi * _pos)) + _start; 196 | 197 | case TwerpType.out_sine: 198 | return _chng * sin(_pos * Twerp_Sine_Half_Pi) + _start; 199 | 200 | case TwerpType.in_sine: 201 | return _chng * (1 - cos(_pos * Twerp_Sine_Half_Pi)) + _start; 202 | 203 | #endregion 204 | } 205 | } -------------------------------------------------------------------------------- /_Maybe Not that great/TwerpFriends/twerp_random.gml: -------------------------------------------------------------------------------- 1 | /// @param x 2 | /// @param twerp_type 3 | /// @param [invert=false] 4 | var _x = argument[0]; 5 | var _invert = argument_count>2 ? argument[2] : false; 6 | while(true) 7 | { 8 | var _ran = random(1); 9 | var _twerp = twerp(argument[1],0,_x,_ran); 10 | var _random = random(_x); 11 | 12 | if(_invert && _random>_twerp) 13 | return _random; 14 | else if(!_invert && _random < _twerp) 15 | return _random; 16 | } -------------------------------------------------------------------------------- /_Maybe Not that great/TwerpFriends/twerp_random_distributed.gml: -------------------------------------------------------------------------------- 1 | /// @param median 2 | /// @param range 3 | /// @param twerp_type 4 | /// @param [invert=false] 5 | var _med = argument[0]; 6 | var _x = argument[1]; 7 | var _curve = argument[2]; 8 | var _val = twerp_random(_x,_curve,argument_count > 3 ? argument[3] : false); 9 | return _med + choose(1,-1)*_val; 10 | -------------------------------------------------------------------------------- /_Maybe Not that great/TwerpFriends/twerp_random_range.gml: -------------------------------------------------------------------------------- 1 | /// @param min 2 | /// @param max 3 | /// @param twerp_type 4 | /// @param [invert=false] 5 | var _min = argument[0]; 6 | var _max = argument[1]; 7 | var _curve = argument[2]; 8 | var _val = twerp_random(_max-_min,_curve,argument_count > 3 ? argument[3] : false); 9 | return _min + _val; 10 | -------------------------------------------------------------------------------- /_Maybe Not that great/TwerpFriends/value_bounce_between.gml: -------------------------------------------------------------------------------- 1 | ///@param min 2 | ///@param max 3 | ///@param pos 4 | ///Works like lerp, but passing a position between 1 and 2 will "reflect" the results. 5 | var _min = argument0; 6 | var _max = argument1; 7 | var _pos = abs(argument2) mod 2; 8 | 9 | return _pos > 1 ? lerp(_max,_min,_pos-1) : lerp(_min,_max,_pos); -------------------------------------------------------------------------------- /_Maybe Not that great/Vec2 and Dependant Scripts/vec2.gml: -------------------------------------------------------------------------------- 1 | /// @description Creates a 2D vector array 2 | /// @param x 3 | /// @param y 4 | 5 | var _v; 6 | _v[0] = argument0; 7 | _v[1] = argument1; 8 | return _v; -------------------------------------------------------------------------------- /_Maybe Not that great/Vec2 and Dependant Scripts/vec2_add.gml: -------------------------------------------------------------------------------- 1 | /// @description Adds two 2D vectors together. 2 | /// @param vec1 3 | /// @param vec2 4 | 5 | var _v1 = argument0; 6 | var _v2 = argument1; 7 | var _v; 8 | 9 | _v[0] = _v1[0]+_v2[0]; 10 | _v[1] = _v1[1]+_v2[1]; 11 | 12 | return _v; -------------------------------------------------------------------------------- /_Maybe Not that great/Vec2 and Dependant Scripts/vec2_dir.gml: -------------------------------------------------------------------------------- 1 | ///@description Returns the direction of the given vector 2 | ///@arg vector 3 | var _vec = argument0; 4 | if(_vec[0]==0 && _vec[1]==0) return no_direction; 5 | 6 | return point_direction(0,0,_vec[0],_vec[1]); -------------------------------------------------------------------------------- /_Maybe Not that great/Vec2 and Dependant Scripts/vec2_equals.gml: -------------------------------------------------------------------------------- 1 | ///Compares two vec2 arrays and returns if they are the same. 2 | ///@arg vector 3 | ///@arg vector 4 | return argument0[0]==argument1[0] && argument0[1]==argument1[1]; -------------------------------------------------------------------------------- /_Maybe Not that great/Vec2 and Dependant Scripts/vec2_from_length_dir.gml: -------------------------------------------------------------------------------- 1 | /// @description Creates a 2D vector array based on a length and direction 2 | /// @param length 3 | /// @param direction 4 | 5 | var _v; 6 | _v[0] = lengthdir_x(argument0,argument1); 7 | _v[1] = lengthdir_y(argument0,argument1); 8 | return _v; -------------------------------------------------------------------------------- /_Maybe Not that great/Vec2 and Dependant Scripts/vec2_length.gml: -------------------------------------------------------------------------------- 1 | /// @description returns the length of the given 2D vector 2 | /// @param vector 3 | var _v1 = argument0; 4 | 5 | var _tot = 0; 6 | _tot+=_v1[0]*_v1[0]; 7 | _tot+=_v1[1]*_v1[1]; 8 | if(_tot != 0) 9 | _tot = sqrt(_tot); 10 | 11 | return _tot; -------------------------------------------------------------------------------- /_Maybe Not that great/Vec2 and Dependant Scripts/vec2_length_approach.gml: -------------------------------------------------------------------------------- 1 | ///@arg current_vec 2 | ///@arg target_length 3 | ///@arg change_amount 4 | ///Returns a vector changed by the give amount towards the target. 5 | var _vec = argument0; 6 | var _tar = argument1; 7 | var _change = argument2; 8 | var _cur_length = vec2_length(_vec); 9 | if(_cur_length < _tar) 10 | { 11 | _cur_length = min(_cur_length+_change,_tar); 12 | } 13 | else 14 | { 15 | _cur_length = max(_cur_length-_change,_tar); 16 | } 17 | return vec2_set_length(_vec,_cur_length); -------------------------------------------------------------------------------- /_Maybe Not that great/Vec2 and Dependant Scripts/vec2_normalize.gml: -------------------------------------------------------------------------------- 1 | /// @description Returns a 2D vector with a length of 1 2 | /// @param vector 3 | var _v1 = argument0; 4 | var _v; 5 | 6 | var _tot = 0; 7 | _v[0] = 0; 8 | _v[1] = 0; 9 | _tot+=_v1[0]*_v1[0]; 10 | _tot+=_v1[1]*_v1[1]; 11 | 12 | if(_tot != 0) 13 | { 14 | _tot = sqrt(_tot); 15 | _v[0] = _v1[0]/_tot; 16 | _v[1] = _v1[1]/_tot; 17 | } 18 | 19 | return _v; 20 | -------------------------------------------------------------------------------- /_Maybe Not that great/Vec2 and Dependant Scripts/vec2_scale.gml: -------------------------------------------------------------------------------- 1 | /// @description returns a 2D vector array with the length scaled by the passed value. 2 | /// @param vec 3 | /// @param real 4 | 5 | var _v1 = vec2_normalize(argument0); 6 | var _scale = argument1; 7 | var _v; 8 | 9 | var _tot = 0; 10 | _v[0] = _v1[0]*_scale; 11 | _v[1] = _v1[1]*_scale; 12 | 13 | return _v; -------------------------------------------------------------------------------- /_Maybe Not that great/Vec2 and Dependant Scripts/vec2_set_length.gml: -------------------------------------------------------------------------------- 1 | ///@arg vector 2 | ///@arg length 3 | return vec2_scale(vec2_normalize(argument0),argument1); -------------------------------------------------------------------------------- /_Maybe Not that great/Vec2 and Dependant Scripts/vec2_subtract.gml: -------------------------------------------------------------------------------- 1 | /// @description returns 2D vector with vec2 subtracted from vec1 2 | /// @param vec1 3 | /// @param vec2 4 | var _v1 = argument0; 5 | var _v2 = argument1; 6 | var _v; 7 | 8 | _v[0] = _v1[0]-_v2[0]; 9 | _v[1] = _v1[1]-_v2[1]; 10 | 11 | return _v; -------------------------------------------------------------------------------- /_Maybe Not that great/Vec2 and Dependant Scripts/vec2_sum.gml: -------------------------------------------------------------------------------- 1 | /// @description Adds any number of 2D vectors together. 2 | /// @param vec1 3 | /// @param vec2 4 | /// @param [vec3...] 5 | 6 | var _v=vec2_zero(); 7 | for(var _i=0; _i< argument_count; _i++) 8 | { 9 | var _vec = argument[_i]; 10 | _v[0] += _vec[0]; 11 | _v[1] += _vec[1]; 12 | } 13 | return _v; -------------------------------------------------------------------------------- /_Maybe Not that great/Vec2 and Dependant Scripts/vec2_truncate.gml: -------------------------------------------------------------------------------- 1 | /// @description if the vector exceeds the given length, it will be returned truncated to max length. 2 | /// @param vector 3 | /// @param max_length 4 | var _vec=argument0; 5 | var _len=argument1; 6 | 7 | if(vec2_length(_vec) > _len) 8 | _vec=vec2_scale(_vec,_len); 9 | return _vec; -------------------------------------------------------------------------------- /_Maybe Not that great/Vec2 and Dependant Scripts/vec2_zero.gml: -------------------------------------------------------------------------------- 1 | /// @description Creates a 2D vector array with the values 0,0 2 | return [0,0] -------------------------------------------------------------------------------- /_Maybe Not that great/display_get_best_fit.gml: -------------------------------------------------------------------------------- 1 | ///@func display_get_best_fit(desired width, desired height, [display width],[display height]) 2 | ///Returns an array with ideal width, height, and full screen zoom factor. 3 | ///Optional arguments for checking what your game would look like on different resolutions. 4 | function display_get_best_fit(_w, _h, _dispW = display_get_width(), _dispH = display_get_height()) { 5 | var _options = []; 6 | 7 | for(var _i = 100; _i > 1; _i--) { 8 | if(_dispW % _i != 0 || _dispH % _i != 0) continue; 9 | array_push(_options, _i); 10 | } 11 | 12 | var _closest = infinity; 13 | var _best = 0; 14 | for(var _i = 0; _i< array_length(_options); _i++) { 15 | var _scale = _options[_i]; 16 | var _width = _dispW / _scale; 17 | var _height = _dispH / _scale; 18 | var _dist = point_distance(_w,_h,_width,_height); 19 | if(_dist < _closest) { 20 | _closest = _dist; 21 | _best = _scale; 22 | } 23 | } 24 | 25 | return [_dispW / _best, _dispH / _best, _best]; 26 | } -------------------------------------------------------------------------------- /_Maybe Not that great/draw_line_sprite.gml: -------------------------------------------------------------------------------- 1 | ///@func draw_line_sprite(pixel_sprite, x1, y1, x2, y2, [width], [color], [alpha]) 2 | function draw_line_sprite(_pixel, _x1, _y1, _x2, _y2, _width = 1, _color = draw_get_color(), _alpha = draw_get_alpha()) { 3 | if(_width == 0) return; 4 | var _dir = point_direction(_x1, _y1, _x2, _y2), 5 | _len = point_distance(_x1, _y1, _x2, _y2) / sprite_get_width(_pixel); 6 | 7 | draw_sprite_ext(_pixel, 0, 8 | _x1+lengthdir_x(_width/2,_dir+90), 9 | _y1+lengthdir_y(_width/2,_dir+90), 10 | _len, _width, _dir, _color, _alpha); 11 | } -------------------------------------------------------------------------------- /_Maybe Not that great/draw_rectangle_sprite.gml: -------------------------------------------------------------------------------- 1 | ///@func draw_rectangle_sprite(pixel_sprite,x1, y1, x2, y2, outline, color, alpha); 2 | function draw_rectangle_sprite(_pixel, _x1, _y1, _x2, _y2, _outline, _color = draw_get_color(), _alpha = draw_get_alpha()) { 3 | if(_outline) { 4 | draw_sprite_ext(_pixel,0, _x1+1, _y1, _x2-_x1-2, 1, 0, _color,_alpha); //top 5 | draw_sprite_ext(_pixel,0, _x1, _y2-1, _x2-_x1, 1, 0, _color,_alpha); //bottom 6 | draw_sprite_ext(_pixel,0, _x1, _y1, 1, _y2-_y1-1, 0, _color,_alpha); //left 7 | draw_sprite_ext(_pixel,0, _x2-1,_y1, 1, _y2-_y1-1, 0, _color,_alpha); //rirght 8 | } else { 9 | draw_sprite_ext(_pixel,0,_x1,_y1,_x2-_x1,_y2-_y1,0,_color,_alpha); 10 | } 11 | } -------------------------------------------------------------------------------- /_Maybe Not that great/draw_sprite_ext_alpha.gml: -------------------------------------------------------------------------------- 1 | /// @description draw_sprite_ext_alpha 2 | /// by DifferentName 3 | /// @param sprite 4 | /// @param subimg 5 | /// @param x 6 | /// @param y 7 | /// @param xscale 8 | /// @param yscale 9 | /// @param rot 10 | /// @param col 11 | /// @param alpha 12 | var _blendMode=gpu_get_blendmode_ext(); 13 | gpu_set_colorwriteenable(true, true, true, false); 14 | draw_sprite_ext(argument0, argument1, argument2, argument3, argument4, argument5, argument6, argument7, argument8); 15 | gpu_set_colorwriteenable(false, false, false, true); 16 | gpu_set_blendmode_ext(bm_one, bm_inv_src_alpha); 17 | draw_sprite_ext(argument0, argument1, argument2, argument3, argument4, argument5, argument6, argument7, argument8); 18 | gpu_set_blendmode_ext(_blendMode[0], _blendMode[1]); 19 | gpu_set_colorwriteenable(1,1,1,1); 20 | -------------------------------------------------------------------------------- /_Maybe Not that great/draw_text_transformed_gpu.gml: -------------------------------------------------------------------------------- 1 | /// @description draw_text_transformed_gpu 2 | /// @param x 3 | /// @param y 4 | /// @param string 5 | /// @param xscale 6 | /// @param yscale 7 | /// @param angle 8 | /// Translated from GMS1 by Kirill Zolovkin 9 | 10 | var _x=argument[0]; 11 | var _y=argument[1]; 12 | var _str=argument[2]; 13 | var _xscale=argument[3]; 14 | var _yscale=argument[4]; 15 | var _angle=argument[5]; 16 | 17 | var _mtx = matrix_build(_x,_y,0,0,0,_angle,_xscale,_yscale,1); 18 | matrix_set(matrix_world,_mtx); 19 | draw_text(0,0,_str); 20 | matrix_set(matrix_world,matrix_build_identity()); -------------------------------------------------------------------------------- /_Maybe Not that great/instance_place_array.gml: -------------------------------------------------------------------------------- 1 | ///@func instance_place_array(x, y, object, [ordered = false]) { 2 | function instance_place_array(_x, _y, _obj, _ordered = false) { 3 | var _list = ds_list_create(); 4 | instance_place_list(_x, _y, _obj, _list, _ordered); 5 | var _arr = []; 6 | 7 | for(var _i = 0; _i < ds_list_size(_list); _i++) 8 | array_push(_arr, _list[| _i]); 9 | 10 | ds_list_destroy(_list); 11 | return _arr; 12 | } -------------------------------------------------------------------------------- /_Maybe Not that great/instance_position_array.gml: -------------------------------------------------------------------------------- 1 | ///@func instance_position_array(x, y, object, [ordered = false]) { 2 | function instance_position_array(_x, _y, _obj, _ordered = false) { 3 | var _list = ds_list_create(); 4 | instance_position_list(_x, _y, _obj, _list, _ordered); 5 | var _arr = []; 6 | 7 | for(var _i = 0; _i < ds_list_size(_list); _i++) 8 | array_push(_arr, _list[| _i]); 9 | 10 | ds_list_destroy(_list); 11 | return _arr; 12 | } -------------------------------------------------------------------------------- /_Need To Be Upgraded/Collision Point Line to Rectangle/collision_point_line_to_rectangle.gml: -------------------------------------------------------------------------------- 1 | ///collision_point_line_to_rectangle(l-x1, l-y1, l-x2, l-y2, r-x1, r-y1, r-x2, r-y2) 2 | //Returns a vector with the x and y position of the collision between the given line and the given rectangle. 3 | //If no intersection is found, will not return an array 4 | //(so check to see if an array is returned before working with the result. 5 | var _x1 = argument[0]; 6 | var _y1 = argument[1]; 7 | var _x2 = argument[2]; 8 | var _y2 = argument[3]; 9 | var _x3 = argument[4]; 10 | var _y3 = argument[5]; 11 | var _x4 = argument[6]; 12 | var _y4 = argument[7]; 13 | 14 | var _point; 15 | //Top Edge 16 | _point = line_intersect_point(_x1,_y1,_x2,_y2,_x3,_y3,_x4,_y3); 17 | if(is_array(_point)) 18 | return(_point); 19 | 20 | //Left Edge 21 | _point = line_intersect_point(_x1,_y1,_x2,_y2,_x3,_y3,_x3,_y4); 22 | if(is_array(_point)) 23 | return(_point); 24 | //Right Edge 25 | _point = line_intersect_point(_x1,_y1,_x2,_y2,_x4,_y3,_x4,_y4); 26 | if(is_array(_point)) 27 | return(_point); 28 | //Bottom Edge 29 | _point = line_intersect_point(_x1,_y1,_x2,_y2,_x3,_y4,_x4,_y4); 30 | if(is_array(_point)) 31 | return(_point); 32 | 33 | return noone; 34 | -------------------------------------------------------------------------------- /_Need To Be Upgraded/Collision Point Line to Rectangle/line_intersect_point.gml: -------------------------------------------------------------------------------- 1 | ///line_intersect_point(x1,y1,x2,y2,x3,y3,x4,y4) 2 | //Returns an array with the x and y position for the intersection point. 3 | var _t = lines_intersect(argument[0], 4 | argument[1], 5 | argument[2], 6 | argument[3], 7 | argument[4], 8 | argument[5], 9 | argument[6], 10 | argument[7], 11 | true); 12 | if(_t > 0 && _t <=1) 13 | { 14 | var _point; 15 | _point[0]= argument[0] + _t * (argument[2] - argument[0]); 16 | _point[1]= argument[1] + _t * (argument[3] - argument[1]); 17 | 18 | return _point; 19 | } 20 | else 21 | return noone; 22 | 23 | // eg. x = x1 + t * (x2 - x1) 24 | // y = y1 + t * (y2 - y1) 25 | -------------------------------------------------------------------------------- /_Need To Be Upgraded/Collision Point Line to Rectangle/lines_intersect.gml: -------------------------------------------------------------------------------- 1 | /// lines_intersect(x1,y1,x2,y2,x3,y3,x4,y4,segment) 2 | // 3 | // Returns a vector multiplier (t) for an intersection on the 4 | // first line. A value of (0 < t <= 1) indicates an intersection 5 | // within the line segment, a value of 0 indicates no intersection, 6 | // other values indicate an intersection beyond the endpoints. 7 | // 8 | // x1,y1,x2,y2 1st line segment 9 | // x3,y3,x4,y4 2nd line segment 10 | // segment If true, confine the test to the line segments. 11 | // 12 | // By substituting the return value (t) into the parametric form 13 | // of the first line, the point of intersection can be determined. 14 | // eg. x = x1 + t * (x2 - x1) 15 | // y = y1 + t * (y2 - y1) 16 | // 17 | /// GMLscripts.com/license 18 | { 19 | var ua, ub, ud, ux, uy, vx, vy, wx, wy; 20 | ua = 0; 21 | ux = argument2 - argument0; 22 | uy = argument3 - argument1; 23 | vx = argument6 - argument4; 24 | vy = argument7 - argument5; 25 | wx = argument0 - argument4; 26 | wy = argument1 - argument5; 27 | ud = vy * ux - vx * uy; 28 | if (ud != 0) 29 | { 30 | ua = (vx * wy - vy * wx) / ud; 31 | if (argument8) 32 | { 33 | ub = (ux * wy - uy * wx) / ud; 34 | if (ua < 0 || ua > 1 || ub < 0 || ub > 1) ua = 0; 35 | } 36 | } 37 | return ua; 38 | } 39 | -------------------------------------------------------------------------------- /_Need To Be Upgraded/angle_normalize.gml: -------------------------------------------------------------------------------- 1 | ///angle_normalize(angle) 2 | return argument0 mod 360; 3 | -------------------------------------------------------------------------------- /_Need To Be Upgraded/chance.gml: -------------------------------------------------------------------------------- 1 | ///chance(%success) 2 | //Rolls a 100 sided die, returns true if the roll is less than the given percentage. 3 | //chance(5) would return true for any value less than or equal to 5. 4 | var _roll = irandom(99)+1; 5 | //show_debug_message("Chance: "+string(argument[0])+" Roll: "+string(_roll)); 6 | return(_roll<=argument[0]); 7 | 8 | -------------------------------------------------------------------------------- /_Need To Be Upgraded/circular_sum_noise.gml: -------------------------------------------------------------------------------- 1 | ///circular_sum_noise 2 | ///@param ds_grid 3 | ///@param min_radius 4 | ///@param max_radius 5 | ///@param spacing 6 | ///@param {normal} 7 | ///Script by RujiK 8 | 9 | var grid = argument[0]; 10 | var width = ds_grid_width(grid); 11 | var height = ds_grid_height(grid); 12 | 13 | //CHANGE THESE VARIABLES FOR DIFFERENT LOOKS! 14 | var rad_min = argument[1]; 15 | var rad_max = argument[2]; 16 | var spacing = argument[3]; 17 | var normal = argument_count > 4 ? argument[4] : 255; 18 | 19 | var val = 0; 20 | var xx=rad_max; 21 | var yy=rad_max; 22 | 23 | while (yy < (height - rad_max)) 24 | { 25 | while (xx < (width - rad_max)) 26 | { 27 | val=irandom(255); 28 | ds_grid_add_disk(grid,xx,yy,random_range(rad_min,rad_max),val); 29 | xx+=spacing; 30 | } 31 | yy+=spacing; 32 | xx=rad_max; 33 | } 34 | 35 | 36 | //GENERATION DONE! But max value is unknown. Normalize values 37 | var grid_max = (ds_grid_get_max(grid,rad_max*2,rad_max*2,width - rad_max*2,height - rad_max*2) + 1); 38 | var grid_min = ds_grid_get_min(grid,rad_max*2,rad_max*2,width - rad_max*2,height - rad_max*2); 39 | 40 | xx=0; 41 | yy=0; 42 | 43 | while yy < height 44 | { // loop through grid and set range from to 0 - normal (normal is set above) 45 | while xx < width 46 | { 47 | val = floor((ds_grid_get(grid,xx,yy)- grid_min) * normal / (grid_max - grid_min)); 48 | ds_grid_set(grid,xx,yy,max(val,0)); 49 | xx+=1; 50 | } 51 | yy+=1; 52 | xx=0; 53 | } -------------------------------------------------------------------------------- /_Need To Be Upgraded/ilengthdir_x.gml: -------------------------------------------------------------------------------- 1 | ///ilengthdir_x(length,direction) 2 | return(round(lengthdir_x(argument[0],argument[1]))); 3 | -------------------------------------------------------------------------------- /_Need To Be Upgraded/ilengthdir_y.gml: -------------------------------------------------------------------------------- 1 | ///ilengthdir_y(length,direction) 2 | return(round(lengthdir_y(argument[0],argument[1]))); 3 | -------------------------------------------------------------------------------- /_Need To Be Upgraded/is_even.gml: -------------------------------------------------------------------------------- 1 | ///is_even(value) 2 | return !(argument0 & 1); 3 | -------------------------------------------------------------------------------- /_Need To Be Upgraded/merge_color_multi.gml: -------------------------------------------------------------------------------- 1 | /// @description merge_color_multi(pos,col1,col2,col3,...) 2 | /// @arg pos 3 | /// @arg color1 4 | /// @arg color2 5 | /// @arg [value3...] 6 | 7 | var _pos = argument[0] mod 1, 8 | _count = argument_count-2, 9 | _color = floor(_pos / (1/_count))+1; 10 | _pos *= _count; 11 | return merge_color(argument[_color],argument[_color+1], _pos mod 1); 12 | //return merge_color_rainbow(argument[_color],argument[_color+1], _pos mod 1); 13 | -------------------------------------------------------------------------------- /_Need To Be Upgraded/merge_color_rainbow.gml: -------------------------------------------------------------------------------- 1 | /// @description merge_color_rainbow() 2 | /// @param color1 3 | /// @param color2 4 | /// @param amount 5 | 6 | var _col1 = [color_get_hue(argument0), 7 | color_get_saturation(argument0), 8 | color_get_value(argument0)]; 9 | var _col2 = [color_get_hue(argument1), 10 | color_get_saturation(argument1), 11 | color_get_value(argument1)]; 12 | 13 | //This makes blending towards white look better. 14 | if(_col1[1] == 0) _col1[0] = _col2[0]; 15 | if(_col2[1] == 0) _col2[0] = _col1[0]; 16 | //This make blending towards black look better. 17 | if(_col1[2] == 0) _col1[1] = _col2[1]; 18 | if(_col2[2] == 0) _col2[1] = _col1[1]; 19 | 20 | //Find shortest path to target hue 21 | var _dif = _col2[0] - _col1[0]; 22 | if(abs(_dif) > 128) 23 | _col1[0]+=(sign(_dif)*256); 24 | 25 | //Wrap value between 0 <= 255 26 | var _hue = lerp(_col1[0],_col2[0],argument2); 27 | _hue = _hue-floor(_hue/256)*256; 28 | 29 | return make_color_hsv(round(_hue), 30 | lerp(_col1[1],_col2[1],argument2), 31 | lerp(_col1[2],_col2[2],argument2)); -------------------------------------------------------------------------------- /_Need To Be Upgraded/minutes.gml: -------------------------------------------------------------------------------- 1 | ///minutes(number of minutes) 2 | return(room_speed*60*argument[0]); 3 | -------------------------------------------------------------------------------- /_Need To Be Upgraded/mouse_is_in_window.gml: -------------------------------------------------------------------------------- 1 | ///mouse_is_in_window 2 | return point_in_rectangle(display_mouse_get_x(), 3 | display_mouse_get_y(), 4 | window_get_x(), 5 | window_get_y(), 6 | window_get_x()+window_get_width(), 7 | window_get_y()+window_get_height()); -------------------------------------------------------------------------------- /_Need To Be Upgraded/seconds.gml: -------------------------------------------------------------------------------- 1 | ///seconds(number of seconds) 2 | return(room_speed*argument[0]); 3 | -------------------------------------------------------------------------------- /_Need To Be Upgraded/target_chain.gml: -------------------------------------------------------------------------------- 1 | /// @description target_chain(list,object,max_distance) 2 | /// @param list 3 | /// @param object 4 | /// @param max_dist 5 | var _list = argument0; 6 | var _obj = argument1; 7 | var _max_dist = argument2; 8 | 9 | var _nearest = noone; 10 | var _near_dist = _list/0; //Infinity 11 | with(_obj) 12 | { 13 | if(id == other) continue; //This is me. 14 | if(ds_list_find_index(_list,id)!= -1) continue; //already on the list 15 | var _dist = point_distance(other.x,other.y,x,y); 16 | if(_dist >= _near_dist || _dist > _max_dist) continue; 17 | _nearest=id; 18 | _near_dist=_dist; 19 | } 20 | 21 | with(_nearest) 22 | { 23 | ds_list_add(_list,id); 24 | target_chain(_list,_obj,_max_dist); 25 | } -------------------------------------------------------------------------------- /_Need To Be Upgraded/tileset_get_tile_index.gml: -------------------------------------------------------------------------------- 1 | /// @description Returns the index of the tile at the specified cell within the given tileset. 2 | /// @param tileset_width The width -in pixels- of the base sprite used for the tileset 3 | /// @param tileset_height The height -in pixels- of the base sprite used for the tileset 4 | /// @param tile_width The width -in pixels- of each cell in the tileset. 5 | /// @param tile_height The height -in pixels- of each cell in the tileset. 6 | /// @param x_cell The x position for the desired cell. 7 | /// @param y_cell the y position for the desired cell. 8 | 9 | var _tw = argument[2]; 10 | var _th = argument[3]; 11 | var _w = argument[0]/_tw; 12 | var _h = argument[1]/_th; 13 | var _x = argument[4]; 14 | var _y = argument[5]; 15 | 16 | if(_x > _w || _y > _h) 17 | return 0; 18 | 19 | return _y*_w+_x; 20 | 21 | -------------------------------------------------------------------------------- /angle_clamp.gml: -------------------------------------------------------------------------------- 1 | ///@func angle_clamp(angle, center, arc) 2 | function angle_clamp(_angle, _center_dir, _arc){ 3 | var _half_arc = _arc / 2; 4 | var _dif = angle_difference(_angle, _center_dir) 5 | if(abs(_dif) < _half_arc) return _angle; 6 | 7 | return _center_dir + _half_arc * sign(_dif) 8 | } -------------------------------------------------------------------------------- /angle_rotate_towards.gml: -------------------------------------------------------------------------------- 1 | ///@func angle_rotate_towards(current, target, velocity, [direction]) 2 | function angle_rotate_towards(_current, _target, _velocity, _direction = sign(angle_difference(_current, _target))) { 3 | _velocity = abs(_velocity); 4 | var _remaining = angle_difference(_current, _target); 5 | if(_remaining == 0) return _target; 6 | 7 | 8 | return abs(_remaining) < _velocity && sign(_remaining) == _direction 9 | ? _target 10 | : _current - _velocity * _direction; 11 | } -------------------------------------------------------------------------------- /angle_rotate_towards_smooth.gml: -------------------------------------------------------------------------------- 1 | ///@func angle_rotate_towards_smooth(start, end, amount) 2 | function angle_rotate_towards_smooth(a, b, i) { 3 | var angle = a + angle_difference(b, a); 4 | return lerp(a, angle, i); 5 | } 6 | -------------------------------------------------------------------------------- /animation_end.gml: -------------------------------------------------------------------------------- 1 | /// @func animation_end(psprite_index],[image_index], [rate]) 2 | /// @param [sprite_index] The index of the sprite being animated 3 | /// @param [image_index] The current frame value 4 | /// @param [rate] The rate of change in frames per step if not 5 | /// using built in image_index/image_speed. 6 | /// If you don't think you need this. You probably don't. 7 | /// Returns true if the animation will loop this step. 8 | function animation_end(_sprite = sprite_index, _image = image_index, _rate = undefined) { 9 | var _type = sprite_get_speed_type(_sprite); 10 | var _spd = sprite_get_speed(_sprite) * image_speed; 11 | if(_type == spritespeed_framespersecond) 12 | _spd = _spd / room_speed; 13 | _spd = _rate == undefined ? _spd : _rate; 14 | return _image + _spd >= sprite_get_number(_sprite); 15 | } -------------------------------------------------------------------------------- /animcurve_lerp.gml: -------------------------------------------------------------------------------- 1 | ///@func animcurve_lerp(curve, channel, val1, val2, position) 2 | function animcurve_lerp(_curve, _channel, _val1, _val2, _position){ 3 | var _pos = animcurve_channel_evaluate(animcurve_get_channel(_curve, _channel), _position); 4 | return lerp(_val1, _val2, _pos) 5 | } -------------------------------------------------------------------------------- /approach.gml: -------------------------------------------------------------------------------- 1 | ///@func approach(start, end, shift) 2 | function approach(_start, _end, _shift){ 3 | return _start < _end ? min(_start + _shift, _end) : max(_start - _shift, _end); 4 | } -------------------------------------------------------------------------------- /approach_smooth.gml: -------------------------------------------------------------------------------- 1 | ///@func approach_smooth(start, end, shift,[snap_distance]) 2 | function approach_smooth(_start, _end, _shift, _snap = math_get_epsilon()){ 3 | //We are close enough 4 | if(abs(_start-_end) < _snap) 5 | return _end; 6 | 7 | return lerp(_start,_end,_shift); 8 | } -------------------------------------------------------------------------------- /audio_play_sound_spaced.gml: -------------------------------------------------------------------------------- 1 | ///@func audio_play_sound_spaced(sound, priority, loop, [min time between], [gain = 1]) 2 | function audio_play_sound_spaced(_id, _priority, _loops, _min_time_between = 100, _gain = 1){ 3 | static history = {} 4 | 5 | var _assetName = audio_get_name(_id) 6 | var _lastPlayed = history[$ _assetName]; 7 | if(_lastPlayed == undefined || current_time - _lastPlayed > _min_time_between){ 8 | history[$ _assetName] = current_time; 9 | return audio_play_sound(_id, _priority, _loops, _gain); 10 | } 11 | } -------------------------------------------------------------------------------- /ceil_n.gml: -------------------------------------------------------------------------------- 1 | ///@func ceil_n(value, increment) 2 | function ceil_n(_val, _inc){ 3 | return ceil(_val / _inc) * _inc; 4 | } 5 | -------------------------------------------------------------------------------- /cos_oscillate.gml: -------------------------------------------------------------------------------- 1 | /// @func cos_oscillate(min,max,duration,[position in microseconds]) 2 | function cos_oscillate(_min, _max, _duration, _pos = get_timer()) { 3 | if(_duration == 0) _duration = math_get_epsilon(); 4 | return((_max-_min)/2 * dcos(360 * 0.000001 * _pos / _duration) + (_max+_min)/2); 5 | } -------------------------------------------------------------------------------- /draw_cone.gml: -------------------------------------------------------------------------------- 1 | function draw_cone(_x1, _y1, _dist, _dir, _angle, _smoothness = 10) { 2 | _smoothness= max(1,round(_smoothness)); 3 | 4 | draw_primitive_begin(pr_trianglefan); 5 | var _col = draw_get_color(); 6 | var _alpha = draw_get_alpha(); 7 | var _start_angle =_dir-_angle/2; 8 | var _angle_inc =_angle/_smoothness; 9 | 10 | draw_vertex_colour(_x1,_y1,_col,_alpha); 11 | for(var _i=_start_angle; _i<=_start_angle+_angle;_i+=_angle_inc) 12 | { 13 | draw_vertex_colour(_x1+lengthdir_x(_dist, _i), 14 | _y1+lengthdir_y(_dist, _i), 15 | _col,_alpha); 16 | } 17 | draw_primitive_end(); 18 | } 19 | -------------------------------------------------------------------------------- /draw_self_ext.gml: -------------------------------------------------------------------------------- 1 | function draw_self_ext(_sprite_index = sprite_index, _image_index = image_index, _x = x, _y = y, _image_xscale = image_xscale, _image_yscale = image_yscale, _image_angle = image_angle, _image_blend = image_blend, _image_alpha = image_alpha){ 2 | draw_sprite_ext(_sprite_index, _image_index, _x, _y, _image_xscale, _image_yscale, _image_angle, _image_blend, _image_alpha) 3 | } -------------------------------------------------------------------------------- /draw_set_text_alignment.gml: -------------------------------------------------------------------------------- 1 | #macro fa_left_bottom 1 2 | #macro fa_center_bottom 2 3 | #macro fa_right_bottom 3 4 | #macro fa_left_middle 4 5 | #macro fa_center_middle 5 6 | #macro fa_right_middle 6 7 | #macro fa_left_top 7 8 | #macro fa_center_top 8 9 | #macro fa_right_top 9 10 | //Why the above values? Look at your numpad. 11 | 12 | ///@func draw_set_text_alignment(alignment, [color], [font]) 13 | function draw_set_text_alignment(_alignment, _color = draw_get_color(), _font = draw_get_font()) { 14 | switch(_alignment) 15 | { 16 | case fa_left_bottom: draw_set_halign(fa_left); draw_set_valign(fa_bottom); break; 17 | case fa_center_bottom: draw_set_halign(fa_center); draw_set_valign(fa_bottom); break; 18 | case fa_right_bottom: draw_set_halign(fa_right); draw_set_valign(fa_bottom); break; 19 | case fa_left_middle: draw_set_halign(fa_left); draw_set_valign(fa_middle); break; 20 | case fa_center_middle: draw_set_halign(fa_center); draw_set_valign(fa_middle); break; 21 | case fa_right_middle: draw_set_halign(fa_right); draw_set_valign(fa_middle); break; 22 | case fa_left_top: draw_set_halign(fa_left); draw_set_valign(fa_top); break; 23 | case fa_center_top: draw_set_halign(fa_center); draw_set_valign(fa_top); break; 24 | case fa_right_top: draw_set_halign(fa_right); draw_set_valign(fa_top); break; 25 | } 26 | draw_set_color(_color); 27 | draw_set_font(_font); 28 | } -------------------------------------------------------------------------------- /draw_sprite_from_center.gml: -------------------------------------------------------------------------------- 1 | ///@func draw_sprite_from_center(sprite, image, x, y, xscale, yscale, rot, col, alpha) 2 | function draw_sprite_from_center(_spr, _img, _x, _y, _xscale, _yscale, _rot, _col, _alpha){ 3 | var _originX = sprite_get_xoffset(_spr) - sprite_get_width(_spr) / 2; 4 | var _originY = sprite_get_yoffset(_spr) - sprite_get_height(_spr) / 2; 5 | 6 | _originX *= _xscale; 7 | _originY *= _yscale; 8 | 9 | matrix_set(matrix_world, matrix_build(_x,_y,0,0,0,_rot,1,1,1)); 10 | 11 | draw_sprite_ext(_spr, _img ,_originX, _originY,_xscale,_yscale,0,_col,_alpha); 12 | matrix_set(matrix_world,matrix_build_identity()); 13 | } -------------------------------------------------------------------------------- /draw_sprite_solid_color.gml: -------------------------------------------------------------------------------- 1 | ///@func draw_sprite_solid_color(sprite_index, image_index, x, y, xscale, yscale, angle, color, alpha) 2 | function draw_sprite_solid_color(_spr = sprite_index, _img = image_index, _x = x, _y = y, _xs = image_xscale, _ys = image_yscale, _ang = image_angle, _col = image_blend, _a = image_alpha) { 3 | gpu_set_fog(true,_col,-16000,16000); 4 | draw_sprite_ext(_spr,_img,_x,_y,_xs,_ys,_ang,_col,_a); 5 | gpu_set_fog(false,0,0,0); 6 | } -------------------------------------------------------------------------------- /draw_surface_ext_origin.gml: -------------------------------------------------------------------------------- 1 | ///@func draw_surface_ext_origin(surf, x, y, xscale, yscale, rot, col, alpha, xorigin,yorigin) 2 | function draw_surface_ext_origin(_surf, _x, _y, _xscale, _yscale, _rot, _col, _alpha, _originX, _originY){ 3 | _originX *= _xscale; 4 | _originY *= _yscale; 5 | 6 | matrix_set(matrix_world, matrix_build(_x,_y,0,0,0,_rot,1,1,1)); 7 | 8 | draw_surface_ext(_surf,-_originX,-_originY,_xscale,_yscale,0,_col,_alpha); 9 | matrix_set(matrix_world,matrix_build_identity()); 10 | } -------------------------------------------------------------------------------- /floor_n.gml: -------------------------------------------------------------------------------- 1 | /// @func floor_n(value, increment) 2 | function floor_n(_val, _inc){ 3 | return(floor(_val/_inc)*_inc); 4 | } 5 | -------------------------------------------------------------------------------- /grid_pos_to_number.gml: -------------------------------------------------------------------------------- 1 | ///@func grid_pos_to_number(x, y, width) 2 | function grid_pos_to_number(_x,_y, _width){ 3 | return _x + _y * _width; 4 | } 5 | -------------------------------------------------------------------------------- /gtfo.gml: -------------------------------------------------------------------------------- 1 | ///@func 2 | function gtfo(_obj, _precision = 1){ 3 | _precision = max(_precision, 1); 4 | if(!place_meeting(x,y,_obj)) return; 5 | var _range = _precision; 6 | var _startX = x; 7 | var _startY = y; 8 | while(true) { 9 | for(var _x = -_range; _x <= _range; _x += _precision) { 10 | for(var _y = -_range; _y <= _range; _y += _precision) { 11 | if(_x > _range && _y > _range && _x < _range && _y < _range) continue; 12 | x = _startX + _x; 13 | y = _startY + _y; 14 | if(!place_meeting(x,y,_obj)) { 15 | show_debug_message("Got the F out after " + string(_range / _precision) + " cycles"); 16 | return; 17 | } 18 | } 19 | } 20 | _range += _precision 21 | } 22 | } -------------------------------------------------------------------------------- /how_far_out.gml: -------------------------------------------------------------------------------- 1 | ///@func how_far_out(value, min, max) 2 | function how_far_out(_val, _min, _max){ 3 | if(_val < _min) 4 | return _val - _min; 5 | if(_val > _max) 6 | return _val - _max; 7 | return 0; 8 | } -------------------------------------------------------------------------------- /instance_create.gml: -------------------------------------------------------------------------------- 1 | ///@func instance_create(object, [struct = {}]) 2 | function instance_create(_obj, _struct = {}){ 3 | return instance_create_depth(0, 0, 0, _obj, _struct); 4 | } -------------------------------------------------------------------------------- /is_between.gml: -------------------------------------------------------------------------------- 1 | ///is_between(value,bound a,bound b,[or equal to]) 2 | function is_between(_x, _bound_a, _bound_b, _equal_to = false) { 3 | var _left = min(_bound_a, _bound_b); 4 | var _right = max(_bound_a, _bound_b); 5 | return !_equal_to ? (_left < _x && _x < _right) : (_left <= _x && _x <= _right); 6 | } -------------------------------------------------------------------------------- /is_or.gml: -------------------------------------------------------------------------------- 1 | ///@func is_or(value, is_this, or_this, ...) 2 | function is_or(_value) { 3 | for(var _i=1; _i 48 && _key < 91 ) return chr(_key); 5 | 6 | switch( _key ) { 7 | case -1: return "No Key"; 8 | case 8: return "Backspace"; 9 | case 9: return "Tab"; 10 | case 13: return "Enter"; 11 | case 16: return "Shift"; 12 | case 17: return "Ctrl"; 13 | case 18: return "Alt"; 14 | case 19: return "Pause/Break"; 15 | case 20: return "CAPS"; 16 | case 27: return "Esc"; 17 | case 33: return "Page Up"; 18 | case 34: return "Page Down"; 19 | case 35: return "End"; 20 | case 36: return "Home"; 21 | case 37: return "Left Arrow"; 22 | case 38: return "Up Arrow"; 23 | case 39: return "Right Arrow"; 24 | case 40: return "Down Arrow"; 25 | case 45: return "Insert"; 26 | case 46: return "Delete"; 27 | case 96: return "Numpad 0"; 28 | case 97: return "Numpad 1"; 29 | case 98: return "Numpad 2"; 30 | case 99: return "Numpad 3"; 31 | case 100: return "Numpad 4"; 32 | case 101: return "Numpad 5"; 33 | case 102: return "Numpad 6"; 34 | case 103: return "Numpad 7"; 35 | case 104: return "Numpad 8"; 36 | case 105: return "Numpad 9"; 37 | case 106: return "Numpad *"; 38 | case 107: return "Numpad +"; 39 | case 109: return "Numpad -"; 40 | case 110: return "Numpad ."; 41 | case 111: return "Numpad /"; 42 | case 112: return "F1"; 43 | case 113: return "F2"; 44 | case 114: return "F3"; 45 | case 115: return "F4"; 46 | case 116: return "F5"; 47 | case 117: return "F6"; 48 | case 118: return "F7"; 49 | case 119: return "F8"; 50 | case 120: return "F9"; 51 | case 121: return "F10"; 52 | case 122: return "F11"; 53 | case 123: return "F12"; 54 | case 144: return "Num Lock"; 55 | case 145: return "Scroll Lock"; 56 | case 186: return ";"; 57 | case 187: return "="; 58 | case 188: return ","; 59 | case 189: return "-"; 60 | case 190: return "."; 61 | case 191: return "\\"; 62 | case 192: return "`"; 63 | case 219: return "/"; 64 | case 220: return "["; 65 | case 221: return "]"; 66 | case 222: return "'"; 67 | } 68 | } -------------------------------------------------------------------------------- /lerp_clamped.gml: -------------------------------------------------------------------------------- 1 | ///@func lerp_clamped(val1, val2, pos) 2 | function lerp_clamped(_val1,_val2,_pos) { 3 | var _min=min(_val1,_val2); 4 | var _max=max(_val1,_val2); 5 | return clamp(lerp(_val1,_val2,_pos),_min,_max); 6 | } -------------------------------------------------------------------------------- /matrix_build_rotation.gml: -------------------------------------------------------------------------------- 1 | ///@func matrix_build_rotation(x, y, z) 2 | function matrix_build_rotation(_x, _y, _z){ 3 | return matrix_build(0,0,0,_x,_y,_z,1,1,1); 4 | } -------------------------------------------------------------------------------- /matrix_build_scale.gml: -------------------------------------------------------------------------------- 1 | ///@func matrix_build_scale(x, y, z) 2 | function matrix_build_scale(_x, _y, _z){ 3 | return matrix_build(0,0,0,0,0,0,_x, _y, _z); 4 | } -------------------------------------------------------------------------------- /matrix_build_translation.gml: -------------------------------------------------------------------------------- 1 | ///@func matrix_build_translation(x, y, z) 2 | function matrix_build_translation(_x, _y, _z){ 3 | return matrix_build(_x, _y, _z,0,0,0,1,1,1); 4 | } -------------------------------------------------------------------------------- /matrix_combine.gml: -------------------------------------------------------------------------------- 1 | ///@func matrix_combine(matrix1, matrix2, ...); 2 | function matrix_combine(){ 3 | var _m = matrix_multiply(argument[0],argument[1]) 4 | for(var _i=2; _i