diff --git a/main.lua b/main.lua index 8f0255e..018ff0f 100644 --- a/main.lua +++ b/main.lua @@ -5,6 +5,15 @@ math.random() math.random() math.random() +-- Globals +WIN = am.window{ + width = 1920, + height = 1080, + title = "hexyz", + highdpi = true, + letterbox = true +} + -- assets/non-or-trivial code require "color" require "sound" @@ -15,21 +24,12 @@ require "src/extra" require "src/geometry" require "src/hexyz" require "src/grid" +WIN.clear_color = color_at(0) require "src/mob" require "src/projectile" require "src/tower" --- Globals -WIN = am.window{ - width = 1920, - height = 1080, - title = "hexyz", - highdpi = true, - letterbox = true, - clear_color = color_at(0) -} - OFF_SCREEN = vec2(WIN.width * 2) -- arbitrary pixel position that is garunteed to be off screen PERF_STATS = false -- result of am.perf_stats() -- should be called every frame @@ -47,7 +47,7 @@ MUSIC_VOLUME = 0.1 SFX_VOLUME = 0.1 -- game stuff -SELECTED_TOWER_TYPE = TOWER_TYPE.REDEYE +SELECTED_TOWER_TYPE = 1 -- top right display types local TRDTS = { @@ -65,7 +65,6 @@ local TRDT = TRDTS.SEED local function select_hex(hex) local tower = tower_on_hex(hex) local tile = HEX_MAP.get(hex.x, hex.y) - log(tile) end local function can_do_build(hex, tile, tower_type) @@ -118,6 +117,9 @@ local function game_action(scene) elseif WIN:key_pressed"f1" then TRDT = (TRDT + 1) % #table.keys(TRDTS) + elseif WIN:key_pressed"f2" then + WORLD"flow_field".hidden = not WORLD"flow_field".hidden + elseif WIN:key_pressed"tab" then local num_of_types = #table.keys(TOWER_TYPE) if WIN:key_down"lshift" then @@ -129,15 +131,15 @@ local function game_action(scene) elseif WIN:key_pressed"1" then select_tower_type(TOWER_TYPE.REDEYE) elseif WIN:key_pressed"2" then select_tower_type(2) elseif WIN:key_pressed"3" then select_tower_type(3) - elseif WIN:key_pressed"4" then --select_tower_type(4) - elseif WIN:key_pressed"5" then --select_tower_type(5) - elseif WIN:key_pressed"6" then --select_tower_type(6) - elseif WIN:key_pressed"7" then --select_tower_type(7) - elseif WIN:key_pressed"8" then --select_tower_type(8) - elseif WIN:key_pressed"9" then --select_tower_type(9) - elseif WIN:key_pressed"0" then --select_tower_type(10) - elseif WIN:key_pressed"-" then --select_tower_type(1) - elseif WIN:key_pressed"=" then --select_tower_type(1) + elseif WIN:key_pressed"4" then select_tower_type(4) + elseif WIN:key_pressed"5" then select_tower_type(5) + elseif WIN:key_pressed"6" then select_tower_type(6) + elseif WIN:key_pressed"7" then select_tower_type(7) + elseif WIN:key_pressed"8" then select_tower_type(8) + elseif WIN:key_pressed"9" then select_tower_type(9) + elseif WIN:key_pressed"0" then select_tower_type(10) + elseif WIN:key_pressed"minus" then select_tower_type(11) + elseif WIN:key_pressed"equals" then select_tower_type(12) end if tile and hot then @@ -175,7 +177,7 @@ local function game_action(scene) WIN.scene"coords".text = str end - --do_day_night_cycle() + do_day_night_cycle() end function do_day_night_cycle() @@ -203,12 +205,22 @@ function update_money(diff) MONEY = MONEY + diff end +function get_tower_tooltip_text(tower_type) + return string.format( + "%s\n%s\n%s\ncost: %d" + , get_tower_name(tower_type) + , get_tower_placement_rules_text(tower_type) + , get_tower_short_description(tower_type) + , get_tower_base_cost(tower_type) + ) +end + local function toolbelt() + -- init the toolbelt local toolbelt_height = hex_height(HEX_SIZE) * 2 - local tower_tooltip = am.translate(WIN.left + 10, WIN.bottom + toolbelt_height + 20) - ^ am.text(tower_type_tostring(SELECTED_TOWER_TYPE), "left"):tag"tower_tooltip" local toolbelt = am.group{ - tower_tooltip, + am.translate(WIN.left + 10, WIN.bottom + toolbelt_height + 20) + ^ am.text(get_tower_tooltip_text(SELECTED_TOWER_TYPE), "left", "bottom"):tag"tower_tooltip", am.rect(WIN.left, WIN.bottom, WIN.right, WIN.bottom + toolbelt_height, COLORS.TRANSPARENT) }:tag"toolbelt" @@ -216,21 +228,24 @@ local function toolbelt() local size = toolbelt_height - padding local half_size = size/2 local offset = vec2(WIN.left + padding*3, WIN.bottom + padding/3) - - local tab_button = am.translate(vec2(0, half_size) + offset) - ^ am.group{ - pack_texture_into_sprite(TEX_WIDER_BUTTON1, 54, 32), - pack_texture_into_sprite(TEX_TAB_ICON, 25, 25) - } + local tab_button = am.translate(vec2(0, half_size) + offset) ^ am.group{ + pack_texture_into_sprite(TEXTURES.WIDER_BUTTON1, 54, 32), + pack_texture_into_sprite(TEXTURES.TAB_ICON, 25, 25) + } toolbelt:append(tab_button) - local tower_select_square = ( am.translate(vec2(size + padding, half_size) + offset) ^ am.rect(-size/2-3, -size/2-3, size/2+3, size/2+3, COLORS.SUNRAY) ):tag"tower_select_square" toolbelt:append(tower_select_square) - local tower_type_values = table.values(TOWER_TYPE) + -- fill in the other tower options + local tower_type_values = { + TOWER_TYPE.REDEYE, + TOWER_TYPE.LIGHTHOUSE, + TOWER_TYPE.WALL, + TOWER_TYPE.MOAT + } local keys = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=' } for i = 1, #keys do if tower_type_values[i] then @@ -238,14 +253,14 @@ local function toolbelt() am.translate(vec2(size + padding, 0) * i + offset) ^ am.group{ am.translate(0, half_size) - ^ pack_texture_into_sprite(TEX_BUTTON1, size, size), + ^ pack_texture_into_sprite(TEXTURES.BUTTON1, size, size), am.translate(0, half_size) ^ pack_texture_into_sprite(get_tower_texture(tower_type_values[i]), size, size), am.translate(vec2(half_size)) ^ am.group{ - pack_texture_into_sprite(TEX_BUTTON1, half_size, half_size), + pack_texture_into_sprite(TEXTURES.BUTTON1, half_size, half_size), am.scale(2) ^ am.text(keys[i], COLORS.BLACK) } @@ -256,11 +271,11 @@ local function toolbelt() am.translate(vec2(size + padding, 0) * i + offset) ^ am.group{ am.translate(0, half_size) - ^ pack_texture_into_sprite(TEX_BUTTON1, size, size), + ^ pack_texture_into_sprite(TEXTURES.BUTTON1, size, size), am.translate(vec2(half_size)) ^ am.group{ - pack_texture_into_sprite(TEX_BUTTON1, half_size, half_size), + pack_texture_into_sprite(TEXTURES.BUTTON1, half_size, half_size), am.scale(2) ^ am.text(keys[i], COLORS.BLACK) } @@ -271,12 +286,13 @@ local function toolbelt() select_tower_type = function(tower_type) SELECTED_TOWER_TYPE = tower_type - WIN.scene"tower_tooltip".text = tower_type_tostring(tower_type) + if TOWER_SPECS[SELECTED_TOWER_TYPE] then + WIN.scene"tower_tooltip".text = get_tower_tooltip_text(tower_type) + local new_position = vec2((size + padding) * tower_type, size/2) + offset + WIN.scene"tower_select_square":action(am.tween(0.1, { position2d = new_position })) - local new_position = vec2((size + padding) * tower_type, size/2) + offset - WIN.scene"tower_select_square":action(am.tween(0.1, { position2d = new_position })) - - WIN.scene:action(am.play(am.sfxr_synth(SOUNDS.SELECT1), false, 1, SFX_VOLUME)) + WIN.scene:action(am.play(am.sfxr_synth(SOUNDS.SELECT1), false, 1, SFX_VOLUME)) + end end return toolbelt @@ -314,7 +330,6 @@ function game_scene() return scene end -load_textures() WIN.scene = am.group(am.scale(vec2(1)) ^ game_scene()) noglobals() diff --git a/res/mountain1.png b/res/mountain1.png new file mode 100644 index 0000000..78fe79e Binary files /dev/null and b/res/mountain1.png differ diff --git a/res/mountain2.png b/res/mountain2.png new file mode 100644 index 0000000..d2503e4 Binary files /dev/null and b/res/mountain2.png differ diff --git a/res/tower_lighthouse.png b/res/tower_lighthouse.png index d5cc07c..42ea3d4 100644 Binary files a/res/tower_lighthouse.png and b/res/tower_lighthouse.png differ diff --git a/res/tower_wall1.png b/res/tower_wall1.png new file mode 100644 index 0000000..8db2b96 Binary files /dev/null and b/res/tower_wall1.png differ diff --git a/res/tower_wall2.png b/res/tower_wall2.png new file mode 100644 index 0000000..2132740 Binary files /dev/null and b/res/tower_wall2.png differ diff --git a/res/tower_wall3.png b/res/tower_wall3.png new file mode 100644 index 0000000..e43af90 Binary files /dev/null and b/res/tower_wall3.png differ diff --git a/res/tower_wall4.png b/res/tower_wall4.png new file mode 100644 index 0000000..e43af90 Binary files /dev/null and b/res/tower_wall4.png differ diff --git a/res/tower_wall5.png b/res/tower_wall5.png new file mode 100644 index 0000000..e43af90 Binary files /dev/null and b/res/tower_wall5.png differ diff --git a/res/tower_wall6.png b/res/tower_wall6.png new file mode 100644 index 0000000..e43af90 Binary files /dev/null and b/res/tower_wall6.png differ diff --git a/src/grid.lua b/src/grid.lua index 26068dd..40481e6 100644 --- a/src/grid.lua +++ b/src/grid.lua @@ -57,10 +57,6 @@ local function tile_is_medium_elevation(tile) return tile.elevation >= -0.5 and tile.elevation < 0.5 end -function tilehex_is_buildable(tile, hex) - return tile_is_medium_elevation(tile) and hex ~= HEX_GRID_CENTER -end - -- map elevation to appropriate color function color_at(elevation) if elevation < -0.5 then -- lowest elevation @@ -83,16 +79,33 @@ end function grid_cost(map, from, to) local t1, t2 = map.get(from.x, from.y), map.get(to.x, to.y) - local epsilon = HEX_GRID_MAXIMUM_ELEVATION - HEX_GRID_MINIMUM_ELEVATION - return epsilon + 10 * math.abs(math.abs(t1.elevation)^0.5 - - math.abs(t2.elevation)^0.5) + + local elevation_epsilon = HEX_GRID_MAXIMUM_ELEVATION - HEX_GRID_MINIMUM_ELEVATION + local elevation_cost = 1 * math.abs(math.abs(t1.elevation)^0.5 + - math.abs(t2.elevation)^0.5) + + local epsilon = elevation_epsilon + local cost = elevation_cost + + return epsilon - cost end function generate_and_apply_flow_field(map, start, world) - local flow_field = dijkstra(map, start, nil, grid_cost) + local flow + if false then + flow = flow_field(map, start, world) + else + flow = dijkstra(map, start, nil, grid_cost) + end + + local flow_field_hidden = world and world"flow_field" and world"flow_field".hidden + if world and world"flow_field" then + world:remove"flow_field" + end + local overlay_group = am.group():tag"flow_field" - for i,_ in pairs(flow_field) do - for j,f in pairs(flow_field[i]) do + for i,_ in pairs(flow) do + for j,f in pairs(flow[i]) do if f then map[i][j].priority = f.priority @@ -100,7 +113,7 @@ function generate_and_apply_flow_field(map, start, world) ^ am.text(string.format("%.1f", f.priority * 10))) else -- should fire exactly once per goal hex - --log('no priority') + -- log('no priority') end end end @@ -109,22 +122,9 @@ function generate_and_apply_flow_field(map, start, world) map[HEX_GRID_CENTER.x][HEX_GRID_CENTER.y].priority = -1 overlay_group:append(am.translate(hex_to_pixel(vec2(HEX_GRID_CENTER.x, HEX_GRID_CENTER.y))) ^ am.text(string.format("%.1f", -10))) - - if world then world:append(overlay_group) end -end - -function redraw_flow_field_overlay(flow_field) - local overlay_group = am.group():tag"flow_field" - for i,_ in pairs(flow_field) do - for j,f in pairs(flow_field[i]) do - if f then - overlay_group:append(am.translate(hex_to_pixel(vec2(i, j))) - ^ am.text(string.format("%.1f", f.priority * 10))) - else - -- should fire exactly once per goal hex - --log('no priority') - end - end + if world then + overlay_group.hidden = flow_field_hidden + world:append(overlay_group) end end @@ -154,7 +154,7 @@ function random_map(seed) else -- scale noise to be closer to 0 the closer we are to the center -- @NOTE i don't know if this 100% of the time makes the center tile passable, but it seems to 99.9+% of the time - -- @NOTE it doesn't. seed: 1835 + -- @NOTE it doesn't. seed: 1835, 2227? local nx, ny = evenq.x/HEX_GRID_WIDTH - 0.5, -evenq.y/HEX_GRID_HEIGHT - 0.5 local d = (nx^2 + ny^2)^0.5 / 0.5^0.5 noise = noise * d^0.125 -- arbitrary, seems to work good @@ -187,7 +187,7 @@ function random_map(seed) generate_and_apply_flow_field(map, HEX_GRID_CENTER, world) world:append(am.translate(hex_to_pixel(HEX_GRID_CENTER)) - ^ pack_texture_into_sprite(TEX_SATELLITE, HEX_PIXEL_WIDTH, HEX_PIXEL_HEIGHT)) + ^ pack_texture_into_sprite(TEXTURES.SATELLITE, HEX_PIXEL_WIDTH, HEX_PIXEL_HEIGHT)) return map, am.translate(WORLDSPACE_COORDINATE_OFFSET) ^ world end diff --git a/src/hexyz.lua b/src/hexyz.lua index a960a35..f89ddfe 100644 --- a/src/hexyz.lua +++ b/src/hexyz.lua @@ -247,6 +247,9 @@ end local function map_get(t, x, y) return t[x] and t[x][y] end +function hex_map_get(t, x, y) + return map_get(t, x, y) +end local function map_set(t, x, y, v) if t[x] then @@ -258,6 +261,9 @@ local function map_set(t, x, y, v) return t end +function hex_map_set(t, x, y, v) + return map_set(t, x, y, v) +end local function map_traverse(t, callback) for i,_ in pairs(t) do diff --git a/src/mob.lua b/src/mob.lua index 7d154f6..0294e92 100644 --- a/src/mob.lua +++ b/src/mob.lua @@ -94,14 +94,22 @@ local function update_mob(mob, mob_index) if last_frame_hex ~= mob.hex or not mob.frame_target then local frame_target, tile = nil, nil if mob.path then - log('A*') + --log('A*') -- we have an explicitly stored target local path_entry = mob.path[mob.hex.x] and mob.path[mob.hex.x][mob.hex.y] + + if not path_entry then + -- we should be just about to reach the target, delete the path. + mob.path = nil + mob.frame_target = nil + return + end + mob.frame_target = path_entry.hex -- check if our target is valid, and if it's not we aren't going to move this frame. -- recalculate our path. - if last_frame_hex ~= mob.hex and not mob_can_pass_through(mob, frame_target) then + if last_frame_hex ~= mob.hex and not mob_can_pass_through(mob, mob.frame_target) then log('recalc') mob.path = get_mob_path(mob, HEX_MAP, mob.hex, HEX_GRID_CENTER) mob.frame_target = nil @@ -134,11 +142,13 @@ local function update_mob(mob, mob_index) end if mob.frame_target and mob.frame_target == last_frame_hex then - log('backpedaling') - log(mob.frame_target) - log(mob.hex) - log(last_frame_hex) - --WIN.scene.paused = true + --log('backpedaling') + -- backpedaling or failing to find anywhere to go, run Astar and hope it works + --local made_it + --mob.path, made_it = Astar(HEX_MAP, mob.hex, HEX_GRID_CENTER, grid_heuristic, grid_cost) + --if not made_it then + -- log('stuck!') + --end end -- do movement @@ -164,7 +174,7 @@ end local function make_and_register_mob(mob_type) local mob = make_basic_entity( get_spawn_hex(), - am.rotate(TIME) ^ pack_texture_into_sprite(TEX_MOB_BEEPER, MOB_SIZE, MOB_SIZE), + am.rotate(TIME) ^ pack_texture_into_sprite(TEXTURES.MOB_BEEPER, MOB_SIZE, MOB_SIZE), update_mob ) @@ -172,7 +182,7 @@ local function make_and_register_mob(mob_type) mob.health = 10 mob.speed = 10 mob.bounty = 5 - mob.hurtbox_radius = MOB_SIZE + mob.hurtbox_radius = MOB_SIZE/2 register_entity(MOBS, mob) end diff --git a/src/projectile.lua b/src/projectile.lua index 83b4a69..19b8187 100644 --- a/src/projectile.lua +++ b/src/projectile.lua @@ -28,6 +28,8 @@ function update_projectile(projectile, projectile_index) -- check if we hit something -- get a list of hexes that could have something we could hit on them + -- right now, it's just the hex we're on and all of its neighbours. + -- this is done to avoid having to check every mob on screen, though maybe it's not necessary. local search_hexes = spiral_map(projectile.hex, 1) local hit_mob_count = 0 local hit_mobs = {} diff --git a/src/tower.lua b/src/tower.lua index 813b73b..26fd029 100644 --- a/src/tower.lua +++ b/src/tower.lua @@ -1,60 +1,70 @@ ---[[ -tower(entity) structure: -{ - -- @NOTE these should probably be wrapped in a 'weapon' struct or something, so towers can have multiple weapons - range - number - distance it can shoot - last_shot_time - number - timestamp (seconds) of last time it shot - target_index - number - index of entity it is currently shooting -} ---]] TOWER_TYPE = { - REDEYE = 1, - WALL = 2, - MOAT = 3, + REDEYE = 1, + LIGHTHOUSE = 2, + WALL = 3, + MOAT = 4, } -function get_tower_build_cost(tower_type) - if tower_type == TOWER_TYPE.REDEYE then return 25 - elseif tower_type == TOWER_TYPE.WALL then return 5 - elseif tower_type == TOWER_TYPE.MOAT then return 15 - end -end - -function can_afford_tower(money, tower_type) - local cost = get_tower_build_cost(tower_type) +TOWER_SPECS = { + [TOWER_TYPE.REDEYE] = { + name = "Redeye", + placement_rules_text = "Place on mountains or on Walls", + short_description = "Long range laser tower", + texture = TEXTURES.TOWER_REDEYE, + base_cost = 25, + }, + [TOWER_TYPE.LIGHTHOUSE] = { + name = "Lighthouse", + placement_rules_text = "Place next to - but not on - water or moats", + short_description = "Attracts and distracts mobs", + texture = TEXTURES.TOWER_LIGHTHOUSE, + base_cost = 25 + }, + [TOWER_TYPE.WALL] = { + name = "Wall", + placement_rules_text = "Place on grass or dirt", + short_description = "Restricts movement", + texture = TEXTURES.TOWER_WALL, + base_cost = 5, + }, + [TOWER_TYPE.MOAT] = { + name = "Moat", + placement_rules_text = "Place on grass or dirt", + short_description = "Restricts movement", + texture = TEXTURES.TOWER_MOAT, + base_cost = 5, + } +} - if tower_type == TOWER_TYPE.REDEYE then return (money - cost) > 0 - elseif tower_type == TOWER_TYPE.WALL then return (money - cost) > 0 - elseif tower_type == TOWER_TYPE.MOAT then return (money - cost) > 0 - end +function get_tower_name(tower_type) + return TOWER_SPECS[tower_type] and TOWER_SPECS[tower_type].name +end +function get_tower_placement_rules_text(tower_type) + return TOWER_SPECS[tower_type] and TOWER_SPECS[tower_type].placement_rules_text +end +function get_tower_short_description(tower_type) + return TOWER_SPECS[tower_type] and TOWER_SPECS[tower_type].short_description end - function get_tower_texture(tower_type) - if tower_type == TOWER_TYPE.REDEYE then return TEX_TOWER_REDEYE - elseif tower_type == TOWER_TYPE.WALL then return TEX_TOWER_WALL - elseif tower_type == TOWER_TYPE.MOAT then return TEX_TOWER_MOAT - end + return TOWER_SPECS[tower_type] and TOWER_SPECS[tower_type].texture +end +function get_tower_base_cost(tower_type) + return TOWER_SPECS[tower_type] and TOWER_SPECS[tower_type].base_cost end -function tower_type_tostring(tower_type) - if tower_type == TOWER_TYPE.REDEYE then return "Redeye Tower" - elseif tower_type == TOWER_TYPE.WALL then return "Wall" - elseif tower_type == TOWER_TYPE.MOAT then return "Moat" - end +function can_afford_tower(money, tower_type) + local cost = get_tower_base_cost(tower_type) + return (money - cost) >= 0 end local function get_tower_update_function(tower_type) if tower_type == TOWER_TYPE.REDEYE then return update_tower_redeye - end -end - -function update_wall_texture(hex) - for _,n in pairs(hex_neighbours(hex)) do - local tile = HEX_MAP.get(hex.x, hex.y) + elseif tower_type == TOWER_TYPE.LIGHTHOUSE then + return update_tower_lighthouse end end @@ -71,11 +81,23 @@ end function tower_is_buildable_on(hex, tile, tower_type) if hex == HEX_GRID_CENTER then return false end - local blocked = #mobs_on_hex(hex) ~= 0 + local blocked = tower_on_hex(hex) or #mobs_on_hex(hex) ~= 0 if tower_type == TOWER_TYPE.REDEYE then return not blocked and tile.elevation > 0.5 + elseif tower_type == TOWER_TYPE.LIGHTHOUSE then + local has_water_neighbour = false + for _,h in pairs(hex_neighbours(hex)) do + local tile = HEX_MAP.get(h.x, h.y) + + if tile and tile.elevation < -0.5 then + has_water_neighbour = true + break + end + end + return not blocked and tile.elevation <= 0.5 and tile.elevation > -0.5 and has_water_neighbour + elseif tower_type == TOWER_TYPE.WALL then return not blocked and tile.elevation <= 0.5 and tile.elevation > -0.5 @@ -116,6 +138,23 @@ function update_tower_redeye(tower, tower_index) end end +function update_tower_lighthouse(tower, tower_index) + -- check if there's a mob on a hex in our perimeter + for _,h in pairs(tower.perimeter) do + local mobs = mobs_on_hex(h) + + for _,m in pairs(mobs) do + if not m.path then + local path, made_it = Astar(HEX_MAP, tower.hex, m.hex, grid_heuristic, grid_cost) + + if made_it then + m.path = path + end + end + end + end +end + function make_and_register_tower(hex, tower_type) local tower = make_basic_entity( hex, @@ -123,19 +162,33 @@ function make_and_register_tower(hex, tower_type) get_tower_update_function(tower_type) ) - tower.range = 7 - tower.last_shot_time = tower.TOB - tower.target_index = false + tower.type = tower_type + if tower_type == TOWER_TYPE.REDEYE then + tower.range = 7 + tower.last_shot_time = tower.TOB + tower.target_index = false + + HEX_MAP[hex.x][hex.y].elevation = 2 + + elseif tower_type == TOWER_TYPE.LIGHTHOUSE then + tower.range = 4 + tower.perimeter = ring_map(tower.hex, tower.range) + + elseif tower_type == TOWER_TYPE.WALL then + HEX_MAP[hex.x][hex.y].elevation = 1 + + elseif tower_type == TOWER_TYPE.MOAT then + HEX_MAP[hex.x][hex.y].elevation = 0 + + end - -- make this cell impassable - HEX_MAP[hex.x][hex.y].elevation = 2 - generate_and_apply_flow_field(HEX_MAP, HEX_GRID_CENTER) + generate_and_apply_flow_field(HEX_MAP, HEX_GRID_CENTER, WORLD) register_entity(TOWERS, tower) end function build_tower(hex, tower_type) - update_money(-get_tower_build_cost(tower_type)) + update_money(-get_tower_base_cost(tower_type)) make_and_register_tower(hex, tower_type) vplay_sfx(SOUNDS.EXPLOSION4) end diff --git a/texture.lua b/texture.lua index 4e46ce4..7cfc4d1 100644 --- a/texture.lua +++ b/texture.lua @@ -1,18 +1,21 @@ -function load_textures() - TEX_BUTTON1 = am.texture2d("res/button1.png") - TEX_WIDER_BUTTON1 = am.texture2d("res/wider_button1.png") - TEX_TAB_ICON = am.texture2d("res/tab_icon.png") - TEX_SATELLITE = am.texture2d("res/satelite.png") +TEXTURES = { + BUTTON1 = am.texture2d("res/button1.png"), + WIDER_BUTTON1 = am.texture2d("res/wider_button1.png"), + TAB_ICON = am.texture2d("res/tab_icon.png"), + SATELLITE = am.texture2d("res/satelite.png"), - TEX_TOWER_WALL = am.texture2d("res/tower_wall.png") - TEX_TOWER_MOAT = am.texture2d("res/tower_moat.png") - TEX_TOWER_REDEYE = am.texture2d("res/tower_redeye.png") - TEX_TOWER_LIGHTHOUSE = am.texture2d("res/tower_lighthouse.png") + TOWER_REDEYE = am.texture2d("res/tower_redeye.png"), + TOWER_LIGHTHOUSE = am.texture2d("res/tower_lighthouse.png"), + TOWER_WALL = am.texture2d("res/tower_wall.png"), + TOWER_MOAT = am.texture2d("res/tower_moat.png"), - TEX_MOB_BEEPER = am.texture2d("res/mob_beeper.png") -end + MOUNTAIN1 = am.texture2d("res/mountain1.png"), + MOUNTAIN2 = am.texture2d("res/mountain2.png"), + + MOB_BEEPER = am.texture2d("res/mob_beeper.png"), +} function pack_texture_into_sprite(texture, width, height) return am.sprite{