From ad36782c781962178b70e662cb94970be371d4ea Mon Sep 17 00:00:00 2001 From: TWLTriston Date: Thu, 28 Sep 2017 06:20:20 -0400 Subject: [PATCH] First iteration of pacman grid, uses a 0,1 array of pixel data to create an overlay, reuable for other ideas --- locale/gen_shape/pacman.lua | 80 ++++++++++++++++++++++++++++++++ locale/gen_shape/pacman_ref.png | Bin 0 -> 351 bytes map_layout.lua | 1 + 3 files changed, 81 insertions(+) create mode 100644 locale/gen_shape/pacman.lua create mode 100644 locale/gen_shape/pacman_ref.png diff --git a/locale/gen_shape/pacman.lua b/locale/gen_shape/pacman.lua new file mode 100644 index 00000000..f1c73aec --- /dev/null +++ b/locale/gen_shape/pacman.lua @@ -0,0 +1,80 @@ +--Pacman void script by TWLTriston + +local grid_width = 40 +local grid_height = 40 +local grid_scale = 32 -- 4/8/16/32 are good values here + +local image_grid = { +-- { 1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0 }, + + + { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, + { 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 }, + { 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 }, + { 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 }, + { 0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,0,0,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0 }, + { 0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,0,0,1,1,1,0,0,0,0,0,1,1,1,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0,1,1,0 }, + { 0,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,0 }, + { 0,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,0 }, + { 0,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0 }, + { 0,0,0,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,1,0,1,1,1,0,0,0 }, + { 0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0 }, + { 0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0 }, + { 0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0 }, + { 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 }, + { 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0 }, + { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } +} + +function run_shape_module(event) + local area = event.area + local surface = event.surface + local tiles = {} + + local top_left_x = area.left_top.x --make a more direct reference + local top_left_y = area.left_top.y --make a more direct reference +-- chunk_region = top_left_x / grid_scale + + for x = top_left_x, top_left_x + 32, grid_scale do + image_grid_position_x = ( ( x / grid_scale ) + 20 ) % grid_width + 1 + for y = top_left_y, top_left_y + 32, grid_scale do + image_grid_position_y = ( ( y / grid_scale ) + 19 ) % grid_height + 1 + if image_grid[image_grid_position_y][image_grid_position_x] ~= nil then + if image_grid[image_grid_position_y][image_grid_position_x] == 0 then + for x_1 = x, x + grid_scale do + for y_1 = y, y + grid_scale do + table.insert(tiles, {name = "out-of-map", position = {x_1,y_1}}) + end + end + end + end + end + end + + surface.set_tiles(tiles) + return true +end diff --git a/locale/gen_shape/pacman_ref.png b/locale/gen_shape/pacman_ref.png new file mode 100644 index 0000000000000000000000000000000000000000..18c60ded6c48865f279130ca56000e684ec305cc GIT binary patch literal 351 zcmV-l0igbgP)Mm_F+quIoKZI7esD^Oo>n zd4T-(YEIUrgWFmB%`DbLSj$jtX=kjo60dBaz1fvy%@AAbt;OqB3Jd`vLw8Hi=p_UJ z@RqjgJ#DYoW_=Dud4fFQ^%BCsuY+OkSo!JMyIhDjz}u6=Q;SiO^vYqn4o39QThsqn z2cuqsl*nxP_uyW>AM_6G(ZSs_yi0WAw}Q3uvA6GcIGEACM{G${9x`dtj~ZJC)Jc#utNBeK74O@pN3zagFi3;+lM