skybox template, bug fixed :D now units and troops are handled differently!

This commit is contained in:
UndeadMaelys 2021-03-24 04:16:48 +01:00
parent e6756ccda7
commit e1384e7729
11 changed files with 94 additions and 95 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,2 +0,0 @@
# Made in Blockbench 3.7.4
newmtl none

View File

@ -1,50 +1,50 @@
# Made in Blockbench 3.7.4
mtllib box.mtl
o cube
v 0.0625 0.0625 0.0625
v 0.0625 0.0625 0
v 0.0625 0 0.0625
v 0.0625 0 0
v 0 0.0625 0
v 0 0.0625 0.0625
v 0 0 0
v 0 0 0.0625
vt 0 1
vt 0 0.9375
vt 0.0625 1
vt 0 0.9375
vt 0.0625 0.9375
vt 0.0625 1
vt 0 1
vt 0 0.9375
vt 0.0625 1
vt 0 0.9375
vt 0.0625 0.9375
vt 0.0625 1
vt 0 1
vt 0 0.9375
vt 0.0625 1
vt 0 0.9375
vt 0.0625 0.9375
vt 0.0625 1
vt 0 1
vt 0 0.9375
vt 0.0625 1
vt 0 0.9375
vt 0.0625 0.9375
vt 0.0625 1
vt 0 1
vt 0 0.9375
vt 0.0625 1
vt 0 0.9375
vt 0.0625 0.9375
vt 0.0625 1
vt 0 1
vt 0 0.9375
vt 0.0625 1
vt 0 0.9375
vt 0.0625 0.9375
vt 0.0625 1
v 0.5 1 0.5
v 0.5 1 -0.5
v 0.5 0 0.5
v 0.5 0 -0.5
v -0.5 1 -0.5
v -0.5 1 0.5
v -0.5 0 -0.5
v -0.5 0 0.5
vt 0.5 0.6666666666666667
vt 0.5 0.33333333333333337
vt 0.75 0.6666666666666667
vt 0.5 0.33333333333333337
vt 0.75 0.33333333333333337
vt 0.75 0.6666666666666667
vt 0 0.6666666666666667
vt 0 0.33333333333333337
vt 0.25 0.6666666666666667
vt 0 0.33333333333333337
vt 0.25 0.33333333333333337
vt 0.25 0.6666666666666667
vt 0.25 1
vt 0.25 0.6666666666666667
vt 0.5 1
vt 0.25 0.6666666666666667
vt 0.5 0.6666666666666667
vt 0.5 1
vt 0.25 0.33333333333333337
vt 0.25 0
vt 0.5 0.33333333333333337
vt 0.25 0
vt 0.5 0
vt 0.5 0.33333333333333337
vt 0.25 0.6666666666666667
vt 0.25 0.33333333333333337
vt 0.5 0.6666666666666667
vt 0.25 0.33333333333333337
vt 0.5 0.33333333333333337
vt 0.5 0.6666666666666667
vt 0.75 0.6666666666666667
vt 0.75 0.33333333333333337
vt 1 0.6666666666666667
vt 0.75 0.33333333333333337
vt 1 0.33333333333333337
vt 1 0.6666666666666667
vn 1 0 0
vn 1 0 0
vn 1 0 0
@ -81,21 +81,21 @@ vn 0 0 -1
vn 0 0 -1
vn 0 0 -1
vn 0 0 -1
usemtl none
usemtl m_0
f 1/1/1 3/2/2 2/3/3
f 3/4/4 4/5/5 2/6/6
usemtl none
usemtl m_0
f 5/7/7 7/8/8 6/9/9
f 7/10/10 8/11/11 6/12/12
usemtl none
usemtl m_0
f 5/13/13 6/14/14 2/15/15
f 6/16/16 1/17/17 2/18/18
usemtl none
usemtl m_0
f 8/19/19 7/20/20 3/21/21
f 7/22/22 4/23/23 3/24/24
usemtl none
usemtl m_0
f 6/25/25 8/26/26 1/27/27
f 8/28/28 3/29/29 1/30/30
usemtl none
usemtl m_0
f 2/31/31 4/32/32 5/33/33
f 4/34/34 7/35/35 5/36/36

View File

@ -1,4 +0,0 @@
# Made in Blockbench 3.7.4
newmtl m_0
map_Kd tile.png
newmtl none

View File

@ -1,4 +0,0 @@
# Made in Blockbench 3.7.4
newmtl m_0
map_Kd sive32.png
newmtl none

Binary file not shown.

Before

Width:  |  Height:  |  Size: 918 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 403 B

View File

@ -1,4 +0,0 @@
# Made in Blockbench 3.7.4
newmtl m_0
map_Kd sive32.png
newmtl none

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 B

After

Width:  |  Height:  |  Size: 410 KiB

View File

@ -70,8 +70,10 @@ function love.update(dt)
-- do camera
if not game_pause then
g3d.camera.strategyViewMovement(dt,speed,is_scrolling)
local pos = {g3d.camera.position[1]-5000/16,g3d.camera.position[2]-5000/16,g3d.camera.position[3]-5000/16}
skybox:setTransform(pos)
local center = -500
local pos = {g3d.camera.position[1],g3d.camera.position[2]+center,g3d.camera.position[3]}
current_level.skybox:setTransform(pos)
-- movement: w,a,s,d,
-- rotate: q,e
-- move by screen: 20 px: sides, forward, backwards
@ -127,13 +129,15 @@ function love.keypressed(key)
has_troops_selected = true
end
for _, u in pairs(current_level.units) do for _, entity in pairs(u.troops) do
if has_troops_selected then
entity.is_selected = false
entity.selected_model = nil
else
entity.is_selected = true
entity.selected_model = g3d.newModel("assets/objects/horizontal_plane.obj",img.effects.is_selected,{entity.pos[1],entity.pos[2]+0.5,entity.pos[3]},{0,0,0},{16,16,16})
for _, u in pairs(current_level.units) do for _, entity in pairs(current_level.entities) do
if entity.unit ~= nil and entity.unit == u.id then
if has_troops_selected then
entity.is_selected = false
entity.selected_model = nil
else
entity.is_selected = true
entity.selected_model = g3d.newModel("assets/objects/horizontal_plane.obj",img.effects.is_selected,{entity.pos[1],entity.pos[2]+0.5,entity.pos[3]},{0,0,0},{16,16,16})
end
end
end end
end
@ -149,17 +153,17 @@ function love.draw()
game_height = love.graphics.getHeight()
-- LAYER 1: THE WORLD
draw_entity(skybox)
draw_entity(current_level.skybox)
-- draw every model in entities
local ent_count = 0
for _, entity in pairs(current_level.entities) do
draw_entity(entity)
if entity.unit == nil then draw_entity(entity) end
end
-- draw every unit's troops
for _, u in pairs(current_level.units) do for _, entity in pairs(u.troops) do
draw_entity(entity)
for _, u in pairs(current_level.units) do for _, entity in pairs(current_level.entities) do
if entity.unit ~= nil and entity.unit == u.id then draw_entity(entity) end
end end
-- LAYER 2: THE USER INTERFACE
@ -188,17 +192,19 @@ function draw_debug()
-- draw selected entities data (scrolleable?!)
uc = 0
for _, u in pairs(current_level.units) do for _, entity in pairs(u.troops) do
uc = uc + 1
if entity.model ~= nil then
if entity.is_animated and entity.is_selected == true then
love.graphics.setColor(0,0,0,0.3)
love.graphics.rectangle("fill",15,-85+80*uc+scroll,game_width-30,70)
love.graphics.setColor(1,1,1)
love.graphics.print("["..u.name..", model: "..entity.name.." (id: "..entity.num..")] (level id: "..entity.tnum..")",20,-80+80*uc+scroll)
love.graphics.print("frame: "..entity.anim_frame.."/"..entity.anim_frames..", rm: \""..entity.rotate_mode.."\"",40,-60+80*uc+scroll)
love.graphics.print("animation: "..entity.anim_path,40,-40+80*uc+scroll)
for _, u in pairs(current_level.units) do for _, entity in pairs(current_level.entities) do
if entity.unit ~= nil and entity.unit == u.id then
uc = uc + 1
if entity.model ~= nil then
if entity.is_animated and entity.is_selected == true then
love.graphics.setColor(0,0,0,0.3)
love.graphics.rectangle("fill",15,-85+80*uc+scroll,game_width-30,70)
love.graphics.setColor(1,1,1)
love.graphics.print("["..u.name..", model: "..entity.name.." (id: "..entity.num..")] (level id: "..entity.tnum..")",20,-80+80*uc+scroll)
love.graphics.print("frame: "..entity.anim_frame.."/"..entity.anim_frames..", rm: \""..entity.rotate_mode.."\"",40,-60+80*uc+scroll)
love.graphics.print("animation: "..entity.anim_path,40,-40+80*uc+scroll)
end
end
end
end end

View File

@ -1,18 +1,16 @@
levels = {}
levels.main_menu = {
skybox = nil,
skybox = g3d.newModel("assets/objects/box.obj","assets/textures/misc/skybox.png", {0,0,0}, {0,0,0}, { 1000, 1000, 1000}),
entities = {},
units = {}
}
total_model_count = 0
unit_count = 0
skybox = levels.main_menu.skybox
local entities = levels.main_menu.entities
local units = levels.main_menu.units
-- skybox
skybox = g3d.newModel("assets/objects/box.obj","assets/textures/misc/skybox.png", {0,0,0}, {0,0,0}, { 10000, 10000, 10000})
-- grass ground
@ -32,6 +30,8 @@ math.randomseed(3)
-- bunch of implings (40)
local nu = Unit:newUnit("Succubi Army",player.id,portrait._ariel,statTable.implings)
unit_count = unit_count + 1
nu.id = unit_count
local xx, yy, zz = 3, 0, 0
local model_count = 0
@ -43,10 +43,11 @@ for i = 1, 8, 1 do for j = 1, 5, 1 do
local imp = Object:new2DAnimated("ariel",portrait._ariel,xx+0.5*(i+1),yy+0,zz+0.5*(j+1),16,16)
imp.num = model_count
imp.tnum = total_model_count
imp.unit = unit_count
load_animation(imp,animation._ariel.idle,4,8)
-- add to unit
addToUnit(nu,imp)
table.insert(entities,imp)
end end
table.insert(units,nu)
@ -92,14 +93,19 @@ table.insert(units,nu)]]
-- create class
local nu = Unit:newUnit("Hero Azifer",player.id,portrait._yari,statTable.implings)
unit_count = unit_count + 1
nu.id = unit_count
local xx, yy, zz = 0, 0, 3
-- create and define
total_model_count = total_model_count + 1
local azifer = Object:new2DAnimated("Azifer",portrait._yari,xx,yy,zz,16,16)
azifer.num = 1
total_model_count = total_model_count + 1
azifer.tnum = total_model_count
azifer.unit = unit_count
load_animation(azifer,animation._yari.idle,4,8)
addToUnit(nu,azifer)
table.insert(entities,azifer)
table.insert(units,nu)