From 47cae629df49bd2b0acf5b776b76444abfe3ef78 Mon Sep 17 00:00:00 2001 From: the me Date: Sun, 14 Aug 2022 21:36:37 -0700 Subject: [PATCH] THE KILLSQUARE (does not kill) --- eastern flames/eastern flames.yyp | 2 + eastern flames/objects/o_unit/Create_0.gml | 3 +- .../scripts/c_decolor/c_decolor.gml | 19 +++++++ eastern flames/scripts/c_decolor/c_decolor.yy | 12 +++++ .../scripts/c_gettile/c_gettile.gml | 15 ++++++ eastern flames/scripts/c_gettile/c_gettile.yy | 12 +++++ eastern flames/scripts/c_input/c_input.gml | 6 +++ .../scripts/c_selectunit/c_selectunit.gml | 2 + .../scripts/st_moving/st_moving.gml | 49 +++++++++++++++++-- eastern flames/scripts/tiledata/tiledata.gml | 9 ++++ 10 files changed, 123 insertions(+), 6 deletions(-) create mode 100644 eastern flames/scripts/c_decolor/c_decolor.gml create mode 100644 eastern flames/scripts/c_decolor/c_decolor.yy create mode 100644 eastern flames/scripts/c_gettile/c_gettile.gml create mode 100644 eastern flames/scripts/c_gettile/c_gettile.yy diff --git a/eastern flames/eastern flames.yyp b/eastern flames/eastern flames.yyp index c0581ae..bd0fabf 100644 --- a/eastern flames/eastern flames.yyp +++ b/eastern flames/eastern flames.yyp @@ -9,6 +9,7 @@ {"id":{"name":"stat","path":"scripts/stat/stat.yy",},"order":3,}, {"id":{"name":"vlambeer","path":"scripts/vlambeer/vlambeer.yy",},"order":1,}, {"id":{"name":"x_unitsetup","path":"scripts/x_unitsetup/x_unitsetup.yy",},"order":0,}, + {"id":{"name":"c_decolor","path":"scripts/c_decolor/c_decolor.yy",},"order":10,}, {"id":{"name":"s_guy","path":"sprites/s_guy/s_guy.yy",},"order":0,}, {"id":{"name":"easing","path":"scripts/easing/easing.yy",},"order":4,}, {"id":{"name":"bint_sort","path":"scripts/bint_sort/bint_sort.yy",},"order":0,}, @@ -31,6 +32,7 @@ {"id":{"name":"format_time","path":"scripts/format_time/format_time.yy",},"order":12,}, {"id":{"name":"o_screenshake","path":"objects/o_screenshake/o_screenshake.yy",},"order":0,}, {"id":{"name":"ncm","path":"scripts/ncm/ncm.yy",},"order":14,}, + {"id":{"name":"c_gettile","path":"scripts/c_gettile/c_gettile.yy",},"order":11,}, {"id":{"name":"sinmult","path":"scripts/sinmult/sinmult.yy",},"order":16,}, {"id":{"name":"munction","path":"scripts/munction/munction.yy",},"order":12,}, {"id":{"name":"function_append","path":"scripts/function_append/function_append.yy",},"order":13,}, diff --git a/eastern flames/objects/o_unit/Create_0.gml b/eastern flames/objects/o_unit/Create_0.gml index 713109f..518ceee 100644 --- a/eastern flames/objects/o_unit/Create_0.gml +++ b/eastern flames/objects/o_unit/Create_0.gml @@ -4,4 +4,5 @@ state = st_standing; drawstate = c_null; hspd = 0; vspd = 0; -returnpos = new vec2(0, 0); \ No newline at end of file +returnpos = new vec2(0, 0); +dir = DIR.NONE; \ No newline at end of file diff --git a/eastern flames/scripts/c_decolor/c_decolor.gml b/eastern flames/scripts/c_decolor/c_decolor.gml new file mode 100644 index 0000000..f50d836 --- /dev/null +++ b/eastern flames/scripts/c_decolor/c_decolor.gml @@ -0,0 +1,19 @@ +function c_decolor(x, y, color) { + if x < array_length(mp) && x >= 0 { + if y < array_length(mp[x]) && y >= 0 { + array_remove(mp[x][y].overlays, color); + return true; + } + } + return false; +} +function c_decolor_all(color) { + var i, j; + for (i=0; i= 0 { + if posy < array_length(mp[posx]) && posy >= 0 { + return true; + } + } + return false; +} \ No newline at end of file diff --git a/eastern flames/scripts/c_gettile/c_gettile.yy b/eastern flames/scripts/c_gettile/c_gettile.yy new file mode 100644 index 0000000..bec42c5 --- /dev/null +++ b/eastern flames/scripts/c_gettile/c_gettile.yy @@ -0,0 +1,12 @@ +{ + "isDnD": false, + "isCompatibility": false, + "parent": { + "name": "Scripts", + "path": "folders/Scripts.yy", + }, + "resourceVersion": "1.0", + "name": "c_gettile", + "tags": [], + "resourceType": "GMScript", +} \ No newline at end of file diff --git a/eastern flames/scripts/c_input/c_input.gml b/eastern flames/scripts/c_input/c_input.gml index 2a8140a..da20fb2 100644 --- a/eastern flames/scripts/c_input/c_input.gml +++ b/eastern flames/scripts/c_input/c_input.gml @@ -4,6 +4,12 @@ function c_input() { up = keyboard_check(ord("W")) + keyboard_check(vk_up); right = keyboard_check(ord("D")) + keyboard_check(vk_right); + leftp = keyboard_check_pressed(ord("A")) + keyboard_check_pressed(vk_left); + downp = keyboard_check_pressed(ord("S")) + keyboard_check_pressed(vk_down); + upp = keyboard_check_pressed(ord("W")) + keyboard_check_pressed(vk_up); + rightp = keyboard_check_pressed(ord("D")) + keyboard_check_pressed(vk_right); + select = mouse_check_button_pressed(mb_left) + keyboard_check_pressed(vk_enter); back = mouse_check_button_pressed(mb_right) + keyboard_check_pressed(vk_escape); + stop = keyboard_check(vk_shift); } \ No newline at end of file diff --git a/eastern flames/scripts/c_selectunit/c_selectunit.gml b/eastern flames/scripts/c_selectunit/c_selectunit.gml index b7f3805..1064280 100644 --- a/eastern flames/scripts/c_selectunit/c_selectunit.gml +++ b/eastern flames/scripts/c_selectunit/c_selectunit.gml @@ -14,7 +14,9 @@ function c_selectunit(unitobject) { } function c_colortile(x, y, color) { + if !c_tileexists(x, y) return false; if !array_contains(global.map[x][y], color) { array_push(global.map[x][y].overlays, color); } + return true; } \ No newline at end of file diff --git a/eastern flames/scripts/st_moving/st_moving.gml b/eastern flames/scripts/st_moving/st_moving.gml index 93fb1e1..8e0957f 100644 --- a/eastern flames/scripts/st_moving/st_moving.gml +++ b/eastern flames/scripts/st_moving/st_moving.gml @@ -1,17 +1,27 @@ function st_moving() { - var mov = 2 + var mov = 2; c_input(); - hspd = lerp(hspd, (right-left)*.05, .4); vspd = lerp(vspd, (down-up)*.05, .4); + //if !stop dir = DIR.NONE; + if left dir = DIR.LEFT; + if down dir = DIR.DOWN; + if up dir = DIR.UP; + if right dir = DIR.RIGHT; + if leftp dir = DIR.LEFT; + if downp dir = DIR.DOWN; + if upp dir = DIR.UP; + if rightp dir = DIR.RIGHT; var remainingmov = mov+1 - ( abs(x+hspd-16-pos.x*ts.x)/ts.x + abs(y+vspd-16-pos.y*ts.y)/ts.y ); //var shitmode = point_distance(x, y, pos.x*ts.x, pos.y*ts.y); //if shitmode > mov*ts.x { - x += hspd*ts.x; - y += vspd*ts.y; + if !stop { + x += hspd*ts.x; + y += vspd*ts.y; + } while !remainingmov { hspd = 0; vspd = 0; @@ -29,6 +39,27 @@ function st_moving() { } prevremainingmov = remainingmov; + c_decolor_all(c_red); + c_decolor_all(c_green); + var guy = c_gettile(x, y); + if guy != noone { + c_colortile(guy.x, guy.y, c_green); + switch dir { + case DIR.LEFT: + c_colortile(guy.x-1, guy.y, c_red); + break; + case DIR.DOWN: + c_colortile(guy.x, guy.y+1, c_red); + break; + case DIR.UP: + c_colortile(guy.x, guy.y-1, c_red); + break; + case DIR.RIGHT: + c_colortile(guy.x+1, guy.y, c_red); + break; + } + } + /*if x < (pos.x-mov)*ts.x { x = (pos.x-mov)*ts.x; } else if x > (pos.x+mov+1)*ts.x { @@ -65,4 +96,12 @@ function st_movingdraw() { } draw_set_alpha(1);*/ } -#macro ts global.tilesize \ No newline at end of file +#macro ts global.tilesize + +enum DIR { + NONE, + LEFT, + DOWN, + UP, + RIGHT, +} \ No newline at end of file diff --git a/eastern flames/scripts/tiledata/tiledata.gml b/eastern flames/scripts/tiledata/tiledata.gml index 57297e9..69a6e2e 100644 --- a/eastern flames/scripts/tiledata/tiledata.gml +++ b/eastern flames/scripts/tiledata/tiledata.gml @@ -5,6 +5,15 @@ global.map = [ [new tiledata(), new tiledata(), new tiledata(), new tiledata(), new tiledata()], [new tiledata(), new tiledata(), new tiledata(), new tiledata(), new tiledata()], ]; +function c_informtiles() { + for (i=0; i