From 21e6c3d64091af028fdc8b57b03b79955f0499d7 Mon Sep 17 00:00:00 2001 From: UndeadMaelys Date: Sat, 20 Mar 2021 11:17:05 +0100 Subject: [PATCH] some fixes? --- assets/textures/hud/units.png | Bin 759 -> 0 bytes assets/textures/ui/unit_portrait.png | Bin 0 -> 612 bytes main.lua | 41 +++++++-------------------- scripts/drawing_UI.lua | 31 ++++++++++++++++++++ scripts/enums.lua | 2 +- scripts/levels.lua | 34 +++++++++++----------- 6 files changed, 58 insertions(+), 50 deletions(-) delete mode 100644 assets/textures/hud/units.png create mode 100644 assets/textures/ui/unit_portrait.png create mode 100644 scripts/drawing_UI.lua diff --git a/assets/textures/hud/units.png b/assets/textures/hud/units.png deleted file mode 100644 index a380ee8e7227b86118a1ca2e7f60f97f65ceea38..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 759 zcmV1m<~00001b5ch_0Itp) z=>Px%u}MThRCt{2oWE|HP!z^L5Uo|o>?od+ya7|&(dt7~d4W#2>d>X0-K9e%{0>!? zZW$YoO((wvk$2mwtSF*`xnS@;hRDDr_4k|je-587aKEGLYsI%g48<@6W~2P_Fx;-s zM!g?a8MEu7tr>uX^C z{&(xitgl-SS&D5sfv%EkF^@OE+CUPIHwJ>1z!oFm6gPD7*E50Rx!Ife!@^)D=MM&h z=keU6#dt06AJ_6h(S>ee%#<3nW_DG?4qyU2D*~Yl+Qf(_}8K)9dw0kD*r*pfCayMu5Ty*r}N! zDW03O7>bjjv~b`DNA-NW`YEsSNfx2I){wYsJ6DV%X@QRJx(MC10Nu3=-L(d#1$({% zmC6psuv)Dexo*GTZ{)fPwip2lBS2vUD2xEh4jNc?(4e%i;Rj|j=^`vUXkghvfMo{( zmK_9Gc93D&K?BPUB~Tav3L`*a1SpIE-L(d~YYlYQhoHOG@RT9*hlYAQ$6+9c_HoF( z1l_d&-L(wewFbKD5-5zo(W4!X8XehT*kS}Ii~!xW2D)nvbk~QVyVk%zr0b!(mY};9 zpu3i#yVj6%*X+k+r2QC*vQIh{6Z`;C6y~NPs^js>iLN@5yHh)rO!rh*9+h%T`Y$Sn pv>#KqD0_ib@G3Nr$02m$`~!KjD8fjeJ^TOw002ovPDHLkV1kggWCs8M diff --git a/assets/textures/ui/unit_portrait.png b/assets/textures/ui/unit_portrait.png new file mode 100644 index 0000000000000000000000000000000000000000..72b0cc67f454abb1d10d4f0656c524149895700a GIT binary patch literal 612 zcmeAS@N?(olHy`uVBq!ia0vp^Za^Hu!3HGl4ID*)6k~CayA#8@b22X(7?|WdT^vIy z=DfYL(eF@z#Lo^KCmys^Gs&$UfzY33}aZ%3{%w`dhg`%jL=GR=ci zxr#|XzpgEAS!&F}pz?y};iEOj58VEm{dV)3<6GZPy40wJ2Z$Zb-ORY=?YZ-Lf0I9`zB{m}eZTCt z{T}Q$*Y4A1y0GT(iY@$*5Fxa&~iwC zmW&rws{SvlmR``~-xd-hyt3Q%^c|;*qIsfS*-EMN4+(rMO15>Xm?o`YmzN?vDKf9& zaa)+r(x-0ECA8QYZXT-YDcB+QF^6%>tZj!|mRvpaDC1~FO!uSz5BA1H_6p4l3s%4H dwVCw;chT-y9`_TjI{=dngQu&X%Q~loCIHy@5p4hf literal 0 HcmV?d00001 diff --git a/main.lua b/main.lua index 4b9b555..f3d25cb 100644 --- a/main.lua +++ b/main.lua @@ -34,6 +34,9 @@ function love.load() -- enums require "scripts/enums" + -- functions + require "scripts/drawing_UI" + --objects require "scripts/objects" require "scripts/units" @@ -146,17 +149,21 @@ function love.draw() end end +------ DEBUG ------ function draw_debug() love.graphics.print("time: "..fps_total..", fps: "..fps_draw..", frametime: "..fps_dt..", x: "..math.floor(g3d.camera.position[1])..", y: "..math.floor(g3d.camera.position[2])..", z: "..math.floor(g3d.camera.position[3]), x, y) end -function draw_pause_menu(x,y) +function draw_pause_menu(w,h) love.graphics.setColor(1,1,1,0.3) - love.graphics.rectangle("fill", x, y, game_width-2*x, game_height-2*y) + love.graphics.rectangle("fill", w, h, game_width-2*w, game_height-2*h) love.graphics.setColor(1,1,1,1) end +-------------------- + +------ MODELS ------ function draw_entity(entity) if entity.model ~= nil then -- do animated models if animated, if anim_path and if game playing @@ -193,33 +200,5 @@ function draw_entity(entity) entity:draw() end end +-------------------- -function draw_combat_ui() - local unit_count = 0 - -- count how much units - for _, unit in pairs(current_level.units) do - if unit.faction == player.id then - unit_count = unit_count + 1 - end - end - local unit_total = unit_count - -- position units accordingly - unit_count = 0 - for _, unit in pairs(current_level.units) do - unit_count = unit_count + 1 - if unit.faction == player.id then - draw_portrait(unit,unit_count,unit_total) - end - end -end - -function draw_portrait(u,unit_count,unit_total) - --$-- temporal - --love.graphics.line(game_width/2,0,game_width/2,game_height) - --$-- - local pos_x = game_width/2-(74*unit_total)+74*unit_count+74/2 - local pos_y = game_height-83 - - love.graphics.draw(img.hud.unit_show, pos_x-2, pos_y, 0, 1) - love.graphics.draw(u.portrait, pos_x, pos_y+14, 0, 4) -end \ No newline at end of file diff --git a/scripts/drawing_UI.lua b/scripts/drawing_UI.lua new file mode 100644 index 0000000..d81d787 --- /dev/null +++ b/scripts/drawing_UI.lua @@ -0,0 +1,31 @@ +-------- combat -------- +function draw_combat_ui() + local unit_count = 0 + -- count how much units + for _, unit in pairs(current_level.units) do + if unit.faction == player.id then + unit_count = unit_count + 1 + end + end + local unit_total = unit_count + -- position units accordingly + unit_count = 0 + for _, unit in pairs(current_level.units) do + unit_count = unit_count + 1 + if unit.faction == player.id then + draw_portrait(unit,unit_count,unit_total) + end + end +end + +function draw_portrait(u,uc,ut) + --$-- temporal + love.graphics.line(game_width/2,0,game_width/2,game_height) + --$-- + local pos_x = (game_width/2)+((72)*ut)/2-(72)*uc + local pos_y = (game_height-86) + + love.graphics.draw(img.hud.unit_show, pos_x-2, pos_y, 0, 1) + love.graphics.draw(u.portrait, pos_x, pos_y+14, 0, 4) +end +-------- combat -------- \ No newline at end of file diff --git a/scripts/enums.lua b/scripts/enums.lua index b393b1b..ae5fbd0 100644 --- a/scripts/enums.lua +++ b/scripts/enums.lua @@ -580,6 +580,6 @@ statTable = { img = { hud = { - unit_show = love.graphics.newImage("assets/textures/hud/units.png") + unit_show = love.graphics.newImage("assets/textures/ui/unit_portrait.png") } } diff --git a/scripts/levels.lua b/scripts/levels.lua index b229ed2..d4de335 100644 --- a/scripts/levels.lua +++ b/scripts/levels.lua @@ -8,13 +8,6 @@ levels.main_menu = { local entities = levels.main_menu.entities local units = levels.main_menu.units --- campfire -entities.campfire = { - model = g3d.newModel("assets/objects/campfire.obj","assets/textures/campfire.png", {0,0,0}, {0,0,0}, {1,1,1}), - is_animated = false, - animated_texture = nil -} - -- grass ground local radius = math.random(50,50) for r1 = 0, radius, 1 do for r2= 0, radius, 1 do @@ -42,7 +35,6 @@ end end table.insert(units,nu) local nu = Unit:newUnit("Implings",player.id,portrait.impling,statTable.implings) - local xx, yy, zz = 3, 0, 3 for i = 1, 8, 1 do for j = 1, 5, 1 do local imp = Object:new2DAnimated("implings",portrait.impling,xx+0.5*(i+1),yy+0,zz+0.5*(j+1),16,16) @@ -61,24 +53,30 @@ for i = 1, 8, 1 do for j = 1, 5, 1 do end end table.insert(units,nu) - ---[[ -- bunch of hellbeast pack (6) +local nu = Unit:newUnit("Hellbeast Pack",player.id,portrait.hellbeast,statTable.implings) local xx, yy, zz = -3, 0, 3 - for i = 1, 3, 1 do for j = 1, 2, 1 do local hellbeast = Object:new2DAnimated("hellbeast",portrait.hellbeast,xx+1*(i+1),yy+0,zz+1*(j+1),16,16) load_animation(hellbeast,animation.hellbeast.idle,4,8) - table.insert(entities,hellbeast) + table.insert(nu.troops,hellbeast) end end -creat_unit -table.insert(units,"hellbeast") +table.insert(units,nu) +-- bunch of hellbeast pack (6) +local nu = Unit:newUnit("Hellbeast Pack",player.id,portrait.hellbeast,statTable.implings) +local xx, yy, zz = -3, 0, -3 +for i = 1, 3, 1 do for j = 1, 2, 1 do + local hellbeast = Object:new2DAnimated("hellbeast",portrait.hellbeast,xx+1*(i+1),yy+0,zz+1*(j+1),16,16) + load_animation(hellbeast,animation.hellbeast.idle,4,8) + table.insert(nu.troops,hellbeast) +end end +table.insert(units,nu) + +local nu = Unit:newUnit("Archdemon",player.id,portrait.archdemon,statTable.implings) -- hero archdemon (1) local xx, yy, zz = 0, 0, 3 local archdemon = Object:new2DAnimated("archdemon",portrait.archdemon,xx,yy,zz,16,16) load_animation(archdemon,animation.archdemon.idle,4,8) -table.insert(entities,archdemon) -table.insert(units,archdemon) -table.insert(units,"archdemon") -]]-- \ No newline at end of file +table.insert(nu.troops,archdemon) +table.insert(units,nu) \ No newline at end of file