Compare commits

...

5 Commits

Author SHA1 Message Date
Auri Collings 03aa30b528
Create README.md 2021-12-22 14:10:50 -08:00
Auri 4906995ffb Fix conveyors! 2021-12-21 16:47:39 -08:00
Auri c87736b60b Add inputs to map 2021-12-21 16:36:12 -08:00
Auri 137c07783d Fix spider spawning and map 2021-12-21 16:31:49 -08:00
Auri 1aebb07540 Fix map and placing machines 2021-12-21 16:21:29 -08:00
10 changed files with 147 additions and 25 deletions

13
README.md Normal file
View File

@ -0,0 +1,13 @@
# Tower Defense Game
Unfortunately, this ended up very unfinished. Time management is a bitch, right? Anyways, to play, **move the `map` file from the game folder into your your `worlds` folder and use that.**
KNOWN ISSUES I DIDNT HAVE TIME TO FIX
- Junctions don't work
- Turrets don't work
- Enemies spawn, but don't attack or get damaged. Instant-kill from punching
STUFF THAT DOES WORK
- Resources
- Cool custom hud
- Mining and conveyoring ores into the inputs

BIN
map/auth.sqlite Normal file

Binary file not shown.

View File

@ -3,5 +3,5 @@ lbm_introduction_times =
lbm_introduction_times_version = 1
last_clear_objects_time = 0
time_of_day = 12000
game_time = 12451
game_time = 13544
EnvArgsEnd

Binary file not shown.

BIN
map/players.sqlite Normal file

Binary file not shown.

Binary file not shown.

View File

@ -53,6 +53,91 @@ local conveyor_functions = {
item.object:set_velocity(obj_vel)
end
end,
vertical_mid = function(node_pos, item, delta)
local node = minetest.get_node(node_pos)
local dir = minetest.facedir_to_dir(node.param2)
local obj_pos = item.object:get_pos()
local obj_vel = item.object:get_velocity()
local obj_pos_rel = vector.subtract(obj_pos, node_pos)
-- Move the item along the conveyor's normal towards the middle.
local main_axis = dir.x ~= 0 and 'x' or 'z'
local norm_axis = dir.x == 0 and 'x' or 'z'
obj_vel.y = lexa.conveyor.speed
if obj_pos_rel[norm_axis] > 0.05 then
obj_vel[norm_axis] = -1 * lexa.conveyor.speed
elseif obj_pos_rel[norm_axis] < -0.05 then
obj_vel[norm_axis] = lexa.conveyor.speed
else
obj_vel[norm_axis] = 0
-- Move the item along the conveyor's direction.
obj_vel[main_axis] = dir[main_axis] * lexa.conveyor.speed
end
item.object:set_pos(obj_pos)
item.object:set_velocity(obj_vel)
end,
vertical_bottom = function(node_pos, item, delta)
local node = minetest.get_node(node_pos)
local dir = minetest.facedir_to_dir(node.param2)
local obj_pos = item.object:get_pos()
local obj_vel = item.object:get_velocity()
local obj_pos_rel = vector.subtract(obj_pos, node_pos)
-- Move the item along the conveyor's normal towards the middle.
local main_axis = dir.x ~= 0 and 'x' or 'z'
local norm_axis = dir.x == 0 and 'x' or 'z'
local across = obj_pos_rel[main_axis] * ((node.param2 == 3 or node.param2 == 2) and -1 or 1)
obj_vel.y = across > 0 and lexa.conveyor.speed or 0
if obj_pos_rel[norm_axis] > 0.05 then
obj_vel[norm_axis] = -1 * lexa.conveyor.speed
elseif obj_pos_rel[norm_axis] < -0.05 then
obj_vel[norm_axis] = lexa.conveyor.speed
else
obj_vel[norm_axis] = 0
-- Move the item along the conveyor's direction.
obj_vel[main_axis] = dir[main_axis] * lexa.conveyor.speed
end
item.object:set_pos(obj_pos)
item.object:set_velocity(obj_vel)
end,
vertical_top = function(node_pos, item, delta)
local node = minetest.get_node(node_pos)
local dir = minetest.facedir_to_dir(node.param2)
local obj_pos = item.object:get_pos()
local obj_vel = item.object:get_velocity()
local obj_pos_rel = vector.subtract(obj_pos, node_pos)
-- Move the item along the conveyor's normal towards the middle.
local main_axis = dir.x ~= 0 and 'x' or 'z'
local norm_axis = dir.x == 0 and 'x' or 'z'
local across = obj_pos_rel[main_axis] * ((node.param2 == 3 or node.param2 == 2) and -1 or 1)
obj_vel.y = across < 0 and lexa.conveyor.speed or 0
if obj_pos_rel[norm_axis] > 0.05 then
obj_vel[norm_axis] = -1 * lexa.conveyor.speed
elseif obj_pos_rel[norm_axis] < -0.05 then
obj_vel[norm_axis] = lexa.conveyor.speed
else
obj_vel[norm_axis] = 0
-- Move the item along the conveyor's direction.
obj_vel[main_axis] = dir[main_axis] * lexa.conveyor.speed
end
item.object:set_pos(obj_pos)
item.object:set_velocity(obj_vel)
end
}

View File

@ -13,25 +13,28 @@ minetest.register_entity('lexa_enemy:spider', {
self.object:remove()
end,
on_step = function(self, dtime, collision)
-- if not self.path then
-- if not navigation.graph then return end
if not self.path then
self.object:remove()
return
end
-- if not lexa.match.state.graph then return end
-- local start = minetest.get_us_time()
-- self.path = navigation.find_path(
-- navigation.graph, vector.round(self.object:get_pos()), navigation.graph.player_spawn)
-- minetest.chat_send_all('Pathfinding took ' .. (minetest.get_us_time() - start) / 1000)
-- local start = minetest.get_us_time()
-- self.path = lexa.nav.find_path(
-- lexa.match.state.graph, vector.round(self.object:get_pos()), lexa.match.state.graph.player_spawn)
-- minetest.chat_send_all('Pathfinding took ' .. (minetest.get_us_time() - start) / 1000)
-- if not self.path then return end
-- self.path_index = #self.path - 1
-- if not self.path then return end
-- self.path_index = #self.path - 1
-- for _, node in ipairs(self.path) do
-- minetest.add_particle({
-- pos = node,
-- size = 16,
-- expirationtime = 3,
-- texture = 'navigation_indicator.png'
-- })
-- end
-- for _, node in ipairs(self.path) do
-- minetest.add_particle({
-- pos = node,
-- size = 16,
-- expirationtime = 3,
-- texture = 'navigation_indicator.png'
-- })
-- end
-- end
local pos_2d = self.object:get_pos()

View File

@ -25,10 +25,22 @@ minetest.register_craftitem('lexa_hud:item_placeholder', {
local inv = player:get_inventory()
local item = inv:get_stack('menu_category_' .. menu.selected._, menu.selected[menu.selected._])
local def = minetest.registered_items[item:get_name()]
if def.on_place then
def.on_place(item, player, target)
else
minetest.item_place(item, player, target)
local above = minetest.get_node(target.above).name
local above_def = minetest.registered_nodes[above]
if above_def and above_def._navigation and above_def._navigation.placeable then
minetest.set_node(target.above, { name = 'air' })
if def.on_place then
def.on_place(item, player, target)
else
minetest.item_place(item, player, target)
end
if minetest.get_node(target.above).name == 'air' then
minetest.set_node(target.above, { name = above })
end
local meta = minetest:get_meta(target.above)
meta:set_string('nav_node', above)
end
end,
on_drop = function(stack)
@ -36,6 +48,11 @@ minetest.register_craftitem('lexa_hud:item_placeholder', {
end
})
minetest.register_on_dignode(function(pos)
local node = minetest:get_meta(pos):get_string('nav_node')
if node then minetest.set_node(pos, { name = node }) end
end)
local function get_list_background(size)
local str = '[combine:' .. (size * 19) .. 'x19'
for i = 0, size - 1 do

View File

@ -100,7 +100,7 @@ minetest.register_on_joinplayer(function()
if lexa.match.state then return end
lexa.match.start_match({
waves = 10,
wait = 10,
wait = 180,
enemies_initial = 10,
enemies_mult = 5,
materials = {
@ -161,20 +161,24 @@ minetest.register_globalstep(function(delta)
lexa.match.state.status.wait = math.max(0, lexa.match.state.status.wait - delta)
lexa.hud.refresh_bar()
if lexa.match.state.status.wait == 0 and lexa.match.state.status.enemies ~= 0 then
if lexa.match.state.status.wait == 0 and lexa.match.state.status.enemies == 0 then
lexa.match.spawn_wave()
end
end)
function lexa.match.spawn_wave()
for _, spawn in lexa.match.status.graph.enemy_spawns do
print(dump(lexa.match.state.graph.enemy_spawns))
for _, spawn in pairs(lexa.match.state.graph.enemy_spawns) do
local path = lexa.nav.find_path(lexa.match.state.graph, spawn, lexa.match.state.map_meta.spawn)
for i = 0, 10 do
minetest.after(i, function()
minetest.chat_send_all('Spawning enemy at ... ' .. minetest.pos_to_string(spawn))
local ent = minetest.add_entity(spawn, 'lexa_enemy:spider', '')
ent.path = path
ent:get_luaentity().path = path
ent:get_luaentity().path_index = #path - 1
end)
end
end
lexa.match.state.status.enemies = 10
end