From ac134e83dd67d415cb2d63d1fd27d230ca2a98d7 Mon Sep 17 00:00:00 2001 From: Nicholas Hayashi Date: Wed, 17 Feb 2021 22:32:02 -0500 Subject: [PATCH] enlarge the hexes - shrink the map - make it easier to change map size --- res/thing.png | Bin 5938 -> 6194 bytes src/entity.lua | 4 ++-- src/game.lua | 6 +++--- src/grid.lua | 37 ++++++++++++++++++++++++------------- src/mob.lua | 6 +++--- src/projectile.lua | 4 ++-- src/tower.lua | 12 ++++++------ 7 files changed, 40 insertions(+), 29 deletions(-) diff --git a/res/thing.png b/res/thing.png index b358fee747173e17e23810975bd511f25d3426be..f16ad089755775767865009d3be5075dd99a80fa 100644 GIT binary patch literal 6194 zcma)=2{fDA+Q*~S)@fBbDC$(S=qZX;)lfsU$1#L+%tOW0mP5_0Sp*%ZTT~1w)gmp@ zP!g@7PLNPqLk+1Q4ke_f6H1~)LQ21__ulW``>pR=>&seM**n?U@B8d`Kl}gtKlg2| z&G+w>-3x(0_9HBQv4=oJ}^^jp6Brks#{TboNcXV?OEJ@=OwmWZ8qdCRc;oXl-rn&PYiTKL|h4fBn2? zYH^tc!r1V})76@yKNm+_A7o@$X5Tp;bAQAp@&NqEmGtsGm$=nRaz~H$kA1FOIPtsh z7PH`a=vbzbsomg!C)#Wm81*4Y2h&kgG?JhH9$dvi*La}$o1i1RR5?{VjW%>qfGyB` z4m)#B9!xUWOLK>+NY@MubVW84r+iUBTareCwhXC7O=0h5Y{Rs*bn(&>Fzlcz1@qv+ z(GHVV{e$q63=JaGioS0Tbe`tLj4|IMqpNDUqx8A)mX6ix;say5vwgyrP!XOh>p znC{h&V5W9ZJU>hkZTX`Ax>8!to;6O@n8J!K8O_ViNKd!0wB$sB$z{P`ebUP@7z{2G znbw2zqD-SKk{dKHsHmt=nprV=mlazHN%SEQ+tECeo7a3pR6S6B6D|nwzwp(+`dNR} zZskaORR;OTU%)cEFnzZ^zM=S4#32d580uc;^Al6q7fq2jC}P_FFADBY{hXd@2Y4=xQR>QO0!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yoo!2>8S+WK%E|#pXU*>jeGCK5|djq?ImIsd6lGb4RE+s;wVxelj z@v!3irvOz*m~(>w(7fqggF zSjiL$Wu_<}n0ouY<`B}HOu8}nlsaSCMmcZGDU9|Oztu8mObb5{@P=M<7-{~VbVEF+ zsiFKbnShdEjhB^JzxpY^&+rL0`yW0m&su&VszWT2q1d-Y?}e%r^IE_Wd+j(rrga}w z&3^6(Q5#Gju%e?$TGgG3=wIbn%yM5FLA+s7_(42BaD2mMVK1~O<9SeV>w1|>MI95% z>MYZ%CA6G_lN3QY=_#+p%(_^9KkJH+EoW1-tYO{v$3Xq^S%GeP710B-lEu}Nu&#nC z7dvKvV%=WrsyX8mC;aN^3PE@UDNy19`kKr{U{8q*NC(J?vaTGhVfq{6kMH#E z*Pw!>+c;Bo1cZr0Rc@V!lT<)8Z5oTnF?Pl=8)ND~eKA#uPB+8z7QwT>O>u8tB+(NG zGibx6FvEKecVvdBSFMZx2AxHaqlTsiquIL0b3k=1f_yaUarevb?=wrazl1dmZ4O=X zPT=+TjKthN861%|;j3|4#u^JpV zBbuL+SNVf(KWjbK$Ps;oHr$0CJRhvSHnA^53Wh%(yLziO;|N~RJDlBz+<`cyL~e{? z?4rjE8dEa%+}9>|;ru_-6K%i1jPzom+Wr4tP$rd!B$Bbi%$-8_fA_gf5~Mu4xDO(? S_;mk{g{{@43st}Sr2Y?G4O1Tg diff --git a/src/entity.lua b/src/entity.lua index 239aa6a..a45617b 100644 --- a/src/entity.lua +++ b/src/entity.lua @@ -26,10 +26,10 @@ function make_basic_entity(hex, node, update, position) -- corresponds to the provided pixel position if position then entity.position = position - entity.hex = pixel_to_hex(entity.position) + entity.hex = pixel_to_hex(entity.position, vec2(HEX_SIZE)) else entity.hex = hex - entity.position = hex_to_pixel(hex) + entity.position = hex_to_pixel(hex, vec2(HEX_SIZE)) end entity.update = update diff --git a/src/game.lua b/src/game.lua index 21fa8da..8f8c90a 100644 --- a/src/game.lua +++ b/src/game.lua @@ -166,8 +166,8 @@ local function game_action(scene) end local mouse = WIN:mouse_position() - local hex = pixel_to_hex(mouse - WORLDSPACE_COORDINATE_OFFSET) - local rounded_mouse = hex_to_pixel(hex) + WORLDSPACE_COORDINATE_OFFSET + local hex = pixel_to_hex(mouse - WORLDSPACE_COORDINATE_OFFSET, vec2(HEX_SIZE)) + local rounded_mouse = hex_to_pixel(hex, vec2(HEX_SIZE)) + WORLDSPACE_COORDINATE_OFFSET local evenq = hex_to_evenq(hex) local centered_evenq = evenq{ y = -evenq.y } - vec2(math.floor(HEX_GRID_WIDTH/2) , math.floor(HEX_GRID_HEIGHT/2)) @@ -423,7 +423,7 @@ function make_hex_cursor(radius, color_f, action_f) local group = am.group() for _,h in pairs(map) do - local hexagon = am.circle(hex_to_pixel(h), HEX_SIZE, color or color_f(h), 6) + local hexagon = am.circle(hex_to_pixel(h, vec2(HEX_SIZE)), HEX_SIZE, color or color_f(h), 6) group:append(hexagon) end diff --git a/src/grid.lua b/src/grid.lua index ffded8d..8cffd6e 100644 --- a/src/grid.lua +++ b/src/grid.lua @@ -1,23 +1,34 @@ -- distance from hex centerpoint to any vertex -HEX_SIZE = 20 +HEX_SIZE = 24 HEX_PIXEL_WIDTH = hex_width(HEX_SIZE, ORIENTATION.FLAT) HEX_PIXEL_HEIGHT = hex_height(HEX_SIZE, ORIENTATION.FLAT) HEX_PIXEL_DIMENSIONS = vec2(HEX_PIXEL_WIDTH, HEX_PIXEL_HEIGHT) --- with 1920x1080, the minimal dimensions to cover the screen is 65x33 --- added 2 cell padding, because we terraform the very outer edge and it looks ugly, so hide it --- odd numbers are important because we want a 'true' center -HEX_GRID_WIDTH = 67 -HEX_GRID_HEIGHT = 35 -HEX_GRID_DIMENSIONS = vec2(HEX_GRID_WIDTH, HEX_GRID_HEIGHT) --- leaving y == 0 makes this the center in hex coordinates -HEX_GRID_CENTER = vec2(math.floor(HEX_GRID_WIDTH/2) - , 0) - -- , math.floor(HEX_GRID_HEIGHT/2)) +-- odd numbers are important because we want a 'true' center +-- added 2 cell padding, because we terraform the very outer edge and it looks ugly, so hide it +do + -- padding should be an even number if the result of the below calculation returns an odd number, + -- and vice-versa + local padding = 2 + + HEX_GRID_WIDTH = math.floor(WIN.width / (HEX_PIXEL_WIDTH + HEX_SIZE) * 2) + padding + HEX_GRID_HEIGHT = math.floor(WIN.height / HEX_PIXEL_HEIGHT) + padding + HEX_GRID_DIMENSIONS = vec2(HEX_GRID_WIDTH, HEX_GRID_HEIGHT) + log(HEX_GRID_DIMENSIONS) + + assert(HEX_GRID_WIDTH % 2 == 1 + and HEX_GRID_HEIGHT % 2 == 1 + , string.format("grid dimensions aren't both odd numbers - %s", tostring(HEX_GRID_DIMENSIONS))) + + -- leaving y == 0 makes this the center in hex coordinates, assuming that our dimensions are correct + HEX_GRID_CENTER = vec2(math.floor(HEX_GRID_WIDTH/2) + , 0) + -- , math.floor(HEX_GRID_HEIGHT/2)) +end HEX_GRID_MINIMUM_ELEVATION = -1 HEX_GRID_MAXIMUM_ELEVATION = 1 @@ -115,7 +126,7 @@ function apply_flow_field(map, flow_field, world) if flow then map[i][j].priority = flow.priority - overlay_group:append(am.translate(hex_to_pixel(vec2(i, j))) + overlay_group:append(am.translate(hex_to_pixel(vec2(i, j), vec2(HEX_SIZE))) ^ am.text(string.format("%.1f", flow.priority * 10))) else map[i][j].priority = nil @@ -212,7 +223,7 @@ function random_map(seed) , ((-evenq.y - HEX_GRID_HEIGHT/2) / HEX_GRID_HEIGHT) ^ 2)) local color = color_at(noise) - mask - local node = am.translate(hex_to_pixel(vec2(i, j))) + local node = am.translate(hex_to_pixel(vec2(i, j), vec2(HEX_SIZE))) ^ am.circle(vec2(0), HEX_SIZE, color, 6) map.set(i, j, { diff --git a/src/mob.lua b/src/mob.lua index 455ffe2..fe0b292 100644 --- a/src/mob.lua +++ b/src/mob.lua @@ -145,7 +145,7 @@ end local function resolve_frame_target_for_mob(mob, mob_index) local last_frame_hex = mob.hex - mob.hex = pixel_to_hex(mob.position) + mob.hex = pixel_to_hex(mob.position, vec2(HEX_SIZE)) if mob.hex == HEX_GRID_CENTER then update_score(-mob.health) @@ -223,7 +223,7 @@ local function update_mob_spooder(mob, mob_index) local to = state.map.get(mob.frame_target.x, mob.frame_target.y) local rate = (math.abs(from.elevation - to.elevation) * 100) * mob.speed * am.delta_time - mob.position = mob.position + math.normalize(hex_to_pixel(mob.frame_target) - mob.position) * rate + mob.position = mob.position + math.normalize(hex_to_pixel(mob.frame_target, vec2(HEX_SIZE)) - mob.position) * rate mob.node.position2d = mob.position else mob.frame_target = false @@ -251,7 +251,7 @@ local function update_mob_beeper(mob, mob_index) local to = state.map.get(mob.frame_target.x, mob.frame_target.y) local rate = (4 * mob.speed - math.abs(to.elevation - from.elevation)) * am.delta_time - mob.position = mob.position + math.normalize(hex_to_pixel(mob.frame_target) - mob.position) * rate + mob.position = mob.position + math.normalize(hex_to_pixel(mob.frame_target, vec2(HEX_SIZE)) - mob.position) * rate mob.node.position2d = mob.position else mob.frame_target = false diff --git a/src/projectile.lua b/src/projectile.lua index 2c993a6..a7989c6 100644 --- a/src/projectile.lua +++ b/src/projectile.lua @@ -77,7 +77,7 @@ local function update_projectile_shell(projectile, projectile_index) end projectile.node.position2d = projectile.position - projectile.hex = pixel_to_hex(projectile.position) + projectile.hex = pixel_to_hex(projectile.position, vec2(HEX_SIZE)) projectile.props.z = projectile.props.z - SHELL_GRAVITY * am.delta_time -- check if we hit something @@ -137,7 +137,7 @@ local function update_projectile_laser(projectile, projectile_index) end projectile.node.position2d = projectile.position - projectile.hex = pixel_to_hex(projectile.position) + projectile.hex = pixel_to_hex(projectile.position, vec2(HEX_SIZE)) -- check if we hit something -- get a list of hexes that could have something we could hit on them diff --git a/src/tower.lua b/src/tower.lua index b90f319..e14994a 100644 --- a/src/tower.lua +++ b/src/tower.lua @@ -37,7 +37,7 @@ TOWER_SPECS = { cost = 20, range = 10, fire_rate = 4, - size = 1, + size = 0, height = 1, }, [TOWER_TYPE.REDEYE] = { @@ -49,7 +49,7 @@ TOWER_SPECS = { cost = 20, range = 12, fire_rate = 1, - size = 1, + size = 0, height = 1, }, [TOWER_TYPE.MOAT] = { @@ -85,7 +85,7 @@ TOWER_SPECS = { cost = 20, range = 8, fire_rate = 1, - size = 1, + size = 0, height = 1, }, } @@ -132,9 +132,9 @@ local function make_tower_node(tower_type) elseif tower_type == TOWER_TYPE.HOWITZER then return am.group{ - pack_texture_into_sprite(TEXTURES.HEX_FLOWER, HEX_FLOWER_DIMENSIONS.x, HEX_FLOWER_DIMENSIONS.y), + pack_texture_into_sprite(TEXTURES.HEX_FLOWER, HEX_PIXEL_WIDTH, HEX_PIXEL_HEIGHT), am.rotate(state.time or 0) ^ am.group{ - pack_texture_into_sprite(TEXTURES.CANNON1, 100, 100) + pack_texture_into_sprite(TEXTURES.CANNON1, 50, 50) } } elseif tower_type == TOWER_TYPE.LIGHTHOUSE then @@ -371,7 +371,7 @@ function update_tower_howitzer(tower, tower_index) end end end - tower.node("rotate").angle = math.wrapf(tower.node("rotate").angle + 0.2 * am.delta_time, math.pi*2) + tower.node("rotate").angle = math.wrapf(tower.node("rotate").angle + 0.1 * am.delta_time, math.pi*2) else -- we should have a target if MOBS[tower.target_index] == false then