some fixes?

This commit is contained in:
UndeadMaelys 2021-03-20 11:17:05 +01:00
parent 3989afb04f
commit 21e6c3d640
6 changed files with 58 additions and 50 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 759 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 B

View File

@ -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

31
scripts/drawing_UI.lua Normal file
View File

@ -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 --------

View File

@ -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")
}
}

View File

@ -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")
]]--
table.insert(nu.troops,archdemon)
table.insert(units,nu)