units, display, enums
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 511 B After Width: | Height: | Size: 511 B |
Before Width: | Height: | Size: 429 B After Width: | Height: | Size: 429 B |
Before Width: | Height: | Size: 390 B After Width: | Height: | Size: 390 B |
Before Width: | Height: | Size: 457 B After Width: | Height: | Size: 457 B |
Before Width: | Height: | Size: 284 B After Width: | Height: | Size: 284 B |
Before Width: | Height: | Size: 310 B After Width: | Height: | Size: 310 B |
Before Width: | Height: | Size: 311 B After Width: | Height: | Size: 311 B |
Before Width: | Height: | Size: 284 B After Width: | Height: | Size: 284 B |
Before Width: | Height: | Size: 374 B After Width: | Height: | Size: 374 B |
Before Width: | Height: | Size: 482 B After Width: | Height: | Size: 482 B |
Before Width: | Height: | Size: 288 B After Width: | Height: | Size: 289 B |
After Width: | Height: | Size: 759 B |
|
@ -209,7 +209,7 @@ function camera.strategyViewMovement(dt,speed,is_scrolling)
|
||||||
|
|
||||||
|
|
||||||
camera.position[1] = camera.pivot[1] + math.cos(camera.pitch)*camera.zoom
|
camera.position[1] = camera.pivot[1] + math.cos(camera.pitch)*camera.zoom
|
||||||
camera.position[2] = camera.pivot[2] - math.sin(-30)*camera.zoom
|
camera.position[2] = camera.pivot[2] - math.sin(45)*camera.zoom
|
||||||
camera.position[3] = camera.pivot[3] + math.sin(camera.pitch)*camera.zoom
|
camera.position[3] = camera.pivot[3] + math.sin(camera.pitch)*camera.zoom
|
||||||
|
|
||||||
-- update the camera's in the shader
|
-- update the camera's in the shader
|
||||||
|
|
150
main.lua
|
@ -7,7 +7,7 @@ function love.load()
|
||||||
-- GOOD PIXEL
|
-- GOOD PIXEL
|
||||||
love.graphics.setDefaultFilter("nearest")
|
love.graphics.setDefaultFilter("nearest")
|
||||||
-- FONTS
|
-- FONTS
|
||||||
DefaultFont = love.graphics.newImageFont("default_font.png",
|
DefaultFont = love.graphics.newImageFont("assets/default_font.png",
|
||||||
" abcdefghijklmnopqrstuvwxyz" ..
|
" abcdefghijklmnopqrstuvwxyz" ..
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0" ..
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0" ..
|
||||||
"123456789.,!?-+/():;%&`'*#=[]\"")
|
"123456789.,!?-+/():;%&`'*#=[]\"")
|
||||||
|
@ -27,14 +27,19 @@ function love.load()
|
||||||
g3d.camera.zoom = 10
|
g3d.camera.zoom = 10
|
||||||
speed = 0
|
speed = 0
|
||||||
|
|
||||||
|
-- player
|
||||||
|
player = {
|
||||||
|
id = 1
|
||||||
|
}
|
||||||
-- enums
|
-- enums
|
||||||
require "enums"
|
require "scripts/enums"
|
||||||
|
|
||||||
--objects
|
--objects
|
||||||
require "objects"
|
require "scripts/objects"
|
||||||
|
require "scripts/units"
|
||||||
|
|
||||||
-- levels
|
-- levels
|
||||||
require "levels"
|
require "scripts/levels"
|
||||||
current_level = levels.main_menu
|
current_level = levels.main_menu
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -53,14 +58,9 @@ function love.update(dt)
|
||||||
fps_count = fps_count + 1
|
fps_count = fps_count + 1
|
||||||
|
|
||||||
-- camera: slow, fast, medium?
|
-- camera: slow, fast, medium?
|
||||||
if love.keyboard.isDown("lshift") then
|
speed = g3d.camera.zoom/2
|
||||||
speed = 2
|
|
||||||
elseif love.keyboard.isDown("lctrl") then
|
|
||||||
speed = 6
|
|
||||||
else
|
|
||||||
speed = 4
|
|
||||||
end
|
|
||||||
|
|
||||||
|
-- do camera
|
||||||
if not game_pause then
|
if not game_pause then
|
||||||
g3d.camera.strategyViewMovement(dt,speed,is_scrolling)
|
g3d.camera.strategyViewMovement(dt,speed,is_scrolling)
|
||||||
-- movement: w,a,s,d,
|
-- movement: w,a,s,d,
|
||||||
|
@ -82,12 +82,13 @@ function love.update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.wheelmoved(_, y)
|
function love.wheelmoved(_, y)
|
||||||
|
-- get scroll to do zoom, and call camera update
|
||||||
g3d.camera.zoom = math.min(math.max(3,g3d.camera.zoom-y/1.5),30)
|
g3d.camera.zoom = math.min(math.max(3,g3d.camera.zoom-y/1.5),30)
|
||||||
is_scrolling = true
|
is_scrolling = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.keypressed(key)
|
function love.keypressed(key)
|
||||||
-- pause the game and free the mouse
|
-- pause the game
|
||||||
if key == "escape" then
|
if key == "escape" then
|
||||||
if game_pause then
|
if game_pause then
|
||||||
game_pause = false
|
game_pause = false
|
||||||
|
@ -96,6 +97,14 @@ function love.keypressed(key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- select all units button
|
||||||
|
if key == "f1" then
|
||||||
|
for _, unit in pairs(current_level.units) do
|
||||||
|
if unit.faction == player.id then
|
||||||
|
unit.is_selected = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.draw()
|
function love.draw()
|
||||||
|
@ -103,46 +112,15 @@ function love.draw()
|
||||||
game_width = love.graphics.getWidth()
|
game_width = love.graphics.getWidth()
|
||||||
game_height = love.graphics.getHeight()
|
game_height = love.graphics.getHeight()
|
||||||
|
|
||||||
-- draw every model
|
-- draw every model in entities
|
||||||
local ent_count = 0
|
local ent_count = 0
|
||||||
for _, entity in pairs(current_level.entities) do
|
for _, entity in pairs(current_level.entities) do
|
||||||
ent_count = ent_count + 1
|
draw_entity(entity)
|
||||||
if entity.model ~= nil then
|
|
||||||
|
|
||||||
-- do animated models
|
|
||||||
if entity.is_animated == true and entity.anim_path ~= nil and game_pause ~= true then
|
|
||||||
-- try to animate
|
|
||||||
entity.anim_subframe = entity.anim_subframe + 1
|
|
||||||
if entity.anim_subframe >= entity.anim_speed then
|
|
||||||
entity.anim_frame = entity.anim_frame + 1
|
|
||||||
entity.anim_subframe = entity.anim_subframe - entity.anim_speed
|
|
||||||
end
|
|
||||||
-- cycle
|
|
||||||
if entity.anim_frame >= entity.anim_frames+1 then entity.anim_frame = entity.anim_frame - entity.anim_frames end
|
|
||||||
-- change
|
|
||||||
entity.model.mesh:setTexture(entity.anim_imgs[entity.anim_frame])
|
|
||||||
end
|
|
||||||
|
|
||||||
-- do rotating models
|
|
||||||
if entity.rotate_mode ~= nil and entity.rotate_mode ~= "none" and game_pause ~= true then
|
|
||||||
local rm = entity.rotate_mode
|
|
||||||
|
|
||||||
if rm == "cam_xz" then
|
|
||||||
|
|
||||||
local sin = g3d.camera.position[1]-entity.model.translation[1]
|
|
||||||
local cos = g3d.camera.position[3]-entity.model.translation[3]
|
|
||||||
|
|
||||||
local angle = math.atan2(sin,cos)-math.rad(180)
|
|
||||||
|
|
||||||
entity.model:setRotation(0,angle,0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
entity.model:draw()
|
|
||||||
else
|
|
||||||
entity:draw()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
-- draw every unit's troops
|
||||||
|
for _, unit in pairs(current_level.units) do for _, entity in pairs(unit.troops) do
|
||||||
|
draw_entity(entity)
|
||||||
|
end end
|
||||||
|
|
||||||
-- draw selection
|
-- draw selection
|
||||||
if selecting_troops == true then
|
if selecting_troops == true then
|
||||||
|
@ -154,7 +132,8 @@ function love.draw()
|
||||||
if game_pause then
|
if game_pause then
|
||||||
draw_pause_menu(30,30)
|
draw_pause_menu(30,30)
|
||||||
else
|
else
|
||||||
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)
|
draw_debug()
|
||||||
|
draw_combat_ui()
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, entity in pairs(current_level.entities) do
|
for _, entity in pairs(current_level.entities) do
|
||||||
|
@ -167,9 +146,80 @@ function love.draw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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(x,y)
|
||||||
love.graphics.setColor(1,1,1,0.3)
|
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", x, y, game_width-2*x, game_height-2*y)
|
||||||
love.graphics.setColor(1,1,1,1)
|
love.graphics.setColor(1,1,1,1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function draw_entity(entity)
|
||||||
|
if entity.model ~= nil then
|
||||||
|
-- do animated models if animated, if anim_path and if game playing
|
||||||
|
if entity.is_animated == true and entity.anim_path ~= nil and game_pause ~= true then
|
||||||
|
-- try to animate
|
||||||
|
entity.anim_subframe = entity.anim_subframe + 1
|
||||||
|
if entity.anim_subframe >= entity.anim_speed then
|
||||||
|
entity.anim_frame = entity.anim_frame + 1
|
||||||
|
entity.anim_subframe = entity.anim_subframe - entity.anim_speed
|
||||||
|
end
|
||||||
|
-- cycle
|
||||||
|
if entity.anim_frame >= entity.anim_frames+1 then entity.anim_frame = entity.anim_frame - entity.anim_frames end
|
||||||
|
-- change
|
||||||
|
entity.model.mesh:setTexture(entity.anim_imgs[entity.anim_frame])
|
||||||
|
end
|
||||||
|
|
||||||
|
-- do rotating models if animated, if has to rotate and if game playing
|
||||||
|
if entity.rotate_mode ~= nil and entity.rotate_mode ~= "none" and game_pause ~= true then
|
||||||
|
local rm = entity.rotate_mode
|
||||||
|
|
||||||
|
if rm == "cam_xz" then
|
||||||
|
|
||||||
|
local sin = g3d.camera.position[1]-entity.model.translation[1]
|
||||||
|
local cos = g3d.camera.position[3]-entity.model.translation[3]
|
||||||
|
|
||||||
|
local angle = math.atan2(sin,cos)-math.rad(180)
|
||||||
|
|
||||||
|
entity.model:setRotation(0,angle,0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
entity.model:draw()
|
||||||
|
else -- simple loaded entities dont require so much fuss
|
||||||
|
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
|
|
@ -37,74 +37,82 @@ icon = {
|
||||||
}
|
}
|
||||||
|
|
||||||
portrait = {
|
portrait = {
|
||||||
elementalAir = nil,
|
_ariel = "assets/textures/characters/imp_ariel/portrait.png",
|
||||||
elementalArcane = nil,
|
elementalAir = "assets/textures/characters/elemental_air/portrait.png",
|
||||||
elementalEarth = nil,
|
elementalArcane = "assets/textures/characters/elemental_arcane/portrait.png",
|
||||||
elementalFire = nil,
|
elementalEarth = "assets/textures/characters/elemental_earth/portrait.png",
|
||||||
elementalIce = nil,
|
elementalFire = "assets/textures/characters/elemental_fire/portrait.png",
|
||||||
elementalMagma = nil,
|
elementalIce = "assets/textures/characters/elemental_ice/portrait.png",
|
||||||
elementalPsychic = nil,
|
elementalMagma = "assets/textures/characters/elemental_magma/portrait.png",
|
||||||
elementalStorm = nil,
|
elementalPsychic = "assets/textures/characters/elemental_psychic/portrait.png",
|
||||||
elementalWater = nil,
|
elementalStorm = "assets/textures/characters/elemental_storm/portrait.png",
|
||||||
militia = nil,
|
elementalWater = "assets/textures/characters/elemental_water/portrait.png",
|
||||||
pikeman = nil,
|
militia = "assets/textures/characters/militia/portrait.png",
|
||||||
crossbow = nil,
|
pikeman = "assets/textures/characters/pikeman/portrait.png",
|
||||||
eliteCrossbow = nil,
|
crossbow = "assets/textures/characters/crossbow/portrait.png",
|
||||||
gryphon = nil,
|
eliteCrossbow = "assets/textures/characters/elite_crossbow/portrait.png",
|
||||||
ancientGryphon = nil,
|
gryphon = "assets/textures/characters/gryphon/portrait.png",
|
||||||
swordman = nil,
|
ancientGryphon = "assets/textures/characters/ancient_gryphon/portrait.png",
|
||||||
humanCaptain = nil,
|
swordman = "assets/textures/characters/swordman/portrait.png",
|
||||||
monk = nil,
|
humanCaptain = "assets/textures/characters/human_captain/portrait.png",
|
||||||
priest = nil,
|
monk = "assets/textures/characters/monk/portrait.png",
|
||||||
horseman = nil,
|
priest = "assets/textures/characters/priest/portrait.png",
|
||||||
cavailer = nil,
|
horseman = "assets/textures/characters/horseman/portrait.png",
|
||||||
knight = nil,
|
cavailer = "assets/textures/characters/cavailer/portrait.png",
|
||||||
paladin = nil,
|
knight = "assets/textures/characters/knight/portrait.png",
|
||||||
impling = nil,
|
paladin = "assets/textures/characters/paladin/portrait.png",
|
||||||
imp = nil,
|
impling = "assets/textures/characters/impling/portrait.png",
|
||||||
gog = nil,
|
imp = "assets/textures/characters/imp/portrait.png",
|
||||||
magog = nil,
|
gog = "assets/textures/characters/gog/portrait.png",
|
||||||
hellhound = nil,
|
magog = "assets/textures/characters/magog/portrait.png",
|
||||||
hellbeast = nil,
|
hellhound = "assets/textures/characters/hellhound/portrait.png",
|
||||||
demon = nil,
|
hellbeast = "assets/textures/characters/hellbeast/portrait.png",
|
||||||
archdemon = nil,
|
demon = "assets/textures/characters/demon/portrait.png",
|
||||||
pitfiend = nil,
|
archdemon = "assets/textures/characters/archdemon/portrait.png",
|
||||||
elitePitfiend = nil,
|
pitfiend = "assets/textures/characters/pitfiend/portrait.png",
|
||||||
efreet = nil,
|
elitePitfiend = "assets/textures/characters/elite_pitfiend/portrait.png",
|
||||||
eliteEfreet = nil,
|
efreet = "assets/textures/characters/efreet/portrait.png",
|
||||||
devil = nil,
|
eliteEfreet = "assets/textures/characters/elite_efreet/portrait.png",
|
||||||
theDevil = nil,
|
devil = "assets/textures/characters/devil/portrait.png",
|
||||||
skeleton = nil,
|
theDevil = "assets/textures/characters/the_devil/portrait.png",
|
||||||
skeletonRisen = nil,
|
skeleton = "assets/textures/characters/skeleton/portrait.png",
|
||||||
zombie = nil,
|
skeletonRisen = "assets/textures/characters/risen_skeleton/portrait.png",
|
||||||
zombieRisen = nil,
|
zombie = "assets/textures/characters/zombie/portrait.png",
|
||||||
spider = nil,
|
zombieRisen = "assets/textures/characters/risen_zombie/portrait.png",
|
||||||
spiderMatriarch = nil,
|
spider = "assets/textures/characters/spider/portrait.png",
|
||||||
spirit = nil,
|
spiderMatriarch = "assets/textures/characters/spider_matriarch/portrait.png",
|
||||||
ghost = nil,
|
spirit = "assets/textures/characters/spirit/portrait.png",
|
||||||
vampire = nil,
|
ghost = "assets/textures/characters/ghost/portrait.png",
|
||||||
bloodlinePatriarch = nil,
|
vampire = "assets/textures/characters/vampire/portrait.png",
|
||||||
necromancer = nil,
|
bloodlinePatriarch = "assets/textures/characters/bloodline_patriarch/portrait.png",
|
||||||
lich = nil,
|
necromancer = "assets/textures/characters/necromancer/portrait.png",
|
||||||
bloodknight = nil,
|
lich = "assets/textures/characters/lich/portrait.png",
|
||||||
deathknight = nil,
|
bloodknight = "assets/textures/characters/bloodknight/portrait.png",
|
||||||
dwarf1 = nil,
|
deathknight = "assets/textures/characters/deathknight/portrait.png",
|
||||||
dwarf2 = nil,
|
dwarf1 = "assets/textures/characters/dwarf1/portrait.png",
|
||||||
pixie = nil,
|
dwarf2 = "assets/textures/characters/dwarf2/portrait.png",
|
||||||
fairie = nil,
|
pixie = "assets/textures/characters/pixie/portrait.png",
|
||||||
satyrArcher = nil,
|
faerie = "assets/textures/characters/faerie/portrait.png",
|
||||||
satyrWarrior = nil,
|
satyrArcher = "assets/textures/characters/satyr_archer/portrait.png",
|
||||||
elvenHunter = nil,
|
satyrWarrior = "assets/textures/characters/satyr_warrior/portrait.png",
|
||||||
elvenCaptain = nil,
|
elvenHunter = "assets/textures/characters/elven_hunter/portrait.png",
|
||||||
deerWhite = nil,
|
elvenCaptain = "assets/textures/characters/elven_captain/portrait.png",
|
||||||
deerBrown = nil,
|
deerWhite = "assets/textures/characters/deer_white/portrait.png",
|
||||||
spellweaver = nil,
|
deerBrown = "assets/textures/characters/deer_brown/portrait.png",
|
||||||
druid = nil,
|
spellweaver = "assets/textures/characters/spellweaver/portrait.png",
|
||||||
treant = nil,
|
druid = "assets/textures/characters/druid/portrait.png",
|
||||||
ent = nil
|
treant = "assets/textures/characters/treant/portrait.png",
|
||||||
|
ent = "assets/textures/characters/ent/portrait.png"
|
||||||
}
|
}
|
||||||
|
|
||||||
animation = {
|
animation = {
|
||||||
|
_ariel = {
|
||||||
|
idle = "assets/textures/characters/imp_ariel/idle",
|
||||||
|
walk = "assets/textures/characters/imp_ariel/walk",
|
||||||
|
attack = "assets/textures/characters/imp_ariel/attack",
|
||||||
|
hit = "assets/textures/characters/imp_ariel/hit",
|
||||||
|
death = "assets/textures/characters/imp_ariel/death"
|
||||||
|
},
|
||||||
elementalAir = {
|
elementalAir = {
|
||||||
idle = nil,
|
idle = nil,
|
||||||
walk = nil,
|
walk = nil,
|
||||||
|
@ -268,10 +276,10 @@ animation = {
|
||||||
},
|
},
|
||||||
impling = {
|
impling = {
|
||||||
idle = "assets/textures/characters/impling/idle",
|
idle = "assets/textures/characters/impling/idle",
|
||||||
walk = nil,
|
walk = "assets/textures/characters/impling/walk",
|
||||||
attack = nil,
|
attack = "assets/textures/characters/impling/attack",
|
||||||
hit = nil,
|
hit = "assets/textures/characters/impling/hit",
|
||||||
death = nil
|
death = "assets/textures/characters/impling/death"
|
||||||
},
|
},
|
||||||
imp = {
|
imp = {
|
||||||
idle = nil,
|
idle = nil,
|
||||||
|
@ -303,10 +311,10 @@ animation = {
|
||||||
},
|
},
|
||||||
hellbeast = {
|
hellbeast = {
|
||||||
idle = "assets/textures/characters/hellbeast/idle",
|
idle = "assets/textures/characters/hellbeast/idle",
|
||||||
walk = nil,
|
walk = "assets/textures/characters/hellbeast/walk",
|
||||||
attack = nil,
|
attack = "assets/textures/characters/hellbeast/attack",
|
||||||
hit = nil,
|
hit = "assets/textures/characters/hellbeast/hit",
|
||||||
death = nil
|
death = "assets/textures/characters/hellbeast/death"
|
||||||
},
|
},
|
||||||
demon = {
|
demon = {
|
||||||
idle = nil,
|
idle = nil,
|
||||||
|
@ -317,10 +325,10 @@ animation = {
|
||||||
},
|
},
|
||||||
archdemon = {
|
archdemon = {
|
||||||
idle = "assets/textures/characters/archdemon/idle",
|
idle = "assets/textures/characters/archdemon/idle",
|
||||||
walk = nil,
|
walk = "assets/textures/characters/archdemon/walk",
|
||||||
attack = nil,
|
attack = "assets/textures/characters/archdemon/attack",
|
||||||
hit = nil,
|
hit = "assets/textures/characters/archdemon/hit",
|
||||||
death = nil
|
death = "assets/textures/characters/archdemon/death"
|
||||||
},
|
},
|
||||||
pitfiend = {
|
pitfiend = {
|
||||||
idle = nil,
|
idle = nil,
|
||||||
|
@ -562,3 +570,16 @@ animation = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
statTable = {
|
||||||
|
implings = {
|
||||||
|
health = 10,
|
||||||
|
speed = 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
img = {
|
||||||
|
hud = {
|
||||||
|
unit_show = love.graphics.newImage("assets/textures/hud/units.png")
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +1,12 @@
|
||||||
levels = {}
|
levels = {}
|
||||||
|
|
||||||
levels.main_menu = {
|
levels.main_menu = {
|
||||||
entities = {}
|
entities = {},
|
||||||
|
units = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
local entities = levels.main_menu.entities
|
local entities = levels.main_menu.entities
|
||||||
|
local units = levels.main_menu.units
|
||||||
|
|
||||||
-- campfire
|
-- campfire
|
||||||
entities.campfire = {
|
entities.campfire = {
|
||||||
|
@ -28,23 +30,55 @@ end end
|
||||||
|
|
||||||
math.randomseed(3)
|
math.randomseed(3)
|
||||||
-- bunch of implings (40)
|
-- bunch of implings (40)
|
||||||
|
|
||||||
|
local nu = Unit:newUnit("Ariel Army",player.id,portrait._ariel,statTable.implings)
|
||||||
|
|
||||||
|
local xx, yy, zz = 3, 0, 0
|
||||||
|
for i = 1, 8, 1 do for j = 1, 5, 1 do
|
||||||
|
local imp = Object:new2DAnimated("implings",portrait._ariel,xx+0.5*(i+1),yy+0,zz+0.5*(j+1),16,16)
|
||||||
|
load_animation(imp,animation._ariel.idle,4,8)
|
||||||
|
table.insert(nu.troops,imp)
|
||||||
|
end end
|
||||||
|
table.insert(units,nu)
|
||||||
|
|
||||||
|
local nu = Unit:newUnit("Implings",player.id,portrait.impling,statTable.implings)
|
||||||
|
|
||||||
local xx, yy, zz = 3, 0, 3
|
local xx, yy, zz = 3, 0, 3
|
||||||
for i = 1, 8, 1 do for j = 1, 5, 1 do
|
for i = 1, 8, 1 do for j = 1, 5, 1 do
|
||||||
local imp = Object:new2DAnimated("imp",portrait.impling,xx+0.5*(i+1),yy+0,zz+0.5*(j+1),16,16)
|
local imp = Object:new2DAnimated("implings",portrait.impling,xx+0.5*(i+1),yy+0,zz+0.5*(j+1),16,16)
|
||||||
load_animation(imp,animation.impling.idle,4,8)
|
load_animation(imp,animation.impling.idle,4,8)
|
||||||
table.insert(entities,imp)
|
table.insert(nu.troops,imp)
|
||||||
end end
|
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)
|
||||||
|
load_animation(imp,animation.impling.idle,4,8)
|
||||||
|
table.insert(nu.troops,imp)
|
||||||
|
end end
|
||||||
|
table.insert(units,nu)
|
||||||
|
|
||||||
|
|
||||||
|
--[[
|
||||||
-- bunch of hellbeast pack (6)
|
-- bunch of hellbeast pack (6)
|
||||||
local xx, yy, zz = -3, 0, 3
|
local xx, yy, zz = -3, 0, 3
|
||||||
|
|
||||||
for i = 1, 3, 1 do for j = 1, 2, 1 do
|
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)
|
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)
|
load_animation(hellbeast,animation.hellbeast.idle,4,8)
|
||||||
table.insert(entities,hellbeast)
|
table.insert(entities,hellbeast)
|
||||||
end end
|
end end
|
||||||
|
creat_unit
|
||||||
|
table.insert(units,"hellbeast")
|
||||||
|
|
||||||
-- hero archdemon (1)
|
-- hero archdemon (1)
|
||||||
local xx, yy, zz = 0, 0, 3
|
local xx, yy, zz = 0, 0, 3
|
||||||
local archdemon = Object:new2DAnimated("archdemon",portrait.archdemon,xx,yy,zz,16,16)
|
local archdemon = Object:new2DAnimated("archdemon",portrait.archdemon,xx,yy,zz,16,16)
|
||||||
load_animation(archdemon,animation.archdemon.idle,4,8)
|
load_animation(archdemon,animation.archdemon.idle,4,8)
|
||||||
table.insert(entities,archdemon)
|
table.insert(entities,archdemon)
|
||||||
|
table.insert(units,archdemon)
|
||||||
|
table.insert(units,"archdemon")
|
||||||
|
]]--
|
|
@ -0,0 +1,28 @@
|
||||||
|
Unit = {
|
||||||
|
class = "Unit",
|
||||||
|
faction = 0,
|
||||||
|
troops = {},
|
||||||
|
is_selected = false,
|
||||||
|
portrait = nil,
|
||||||
|
stat = {
|
||||||
|
health = nil,
|
||||||
|
speed = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function Unit:newUnit(name,faction,portrait,stat_table)
|
||||||
|
o = {
|
||||||
|
-- ids
|
||||||
|
name = name,
|
||||||
|
faction = faction,
|
||||||
|
portrait = love.graphics.newImage(portrait),
|
||||||
|
-- stats
|
||||||
|
stat = {
|
||||||
|
health = stat_table.health,
|
||||||
|
speed = stat_table.speed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setmetatable(o, self)
|
||||||
|
self.__index = self
|
||||||
|
return o
|
||||||
|
end
|