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[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
|
||||
|
||||
-- update the camera's in the shader
|
||||
|
|
130
main.lua
|
@ -7,7 +7,7 @@ function love.load()
|
|||
-- GOOD PIXEL
|
||||
love.graphics.setDefaultFilter("nearest")
|
||||
-- FONTS
|
||||
DefaultFont = love.graphics.newImageFont("default_font.png",
|
||||
DefaultFont = love.graphics.newImageFont("assets/default_font.png",
|
||||
" abcdefghijklmnopqrstuvwxyz" ..
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0" ..
|
||||
"123456789.,!?-+/():;%&`'*#=[]\"")
|
||||
|
@ -27,14 +27,19 @@ function love.load()
|
|||
g3d.camera.zoom = 10
|
||||
speed = 0
|
||||
|
||||
-- player
|
||||
player = {
|
||||
id = 1
|
||||
}
|
||||
-- enums
|
||||
require "enums"
|
||||
require "scripts/enums"
|
||||
|
||||
--objects
|
||||
require "objects"
|
||||
require "scripts/objects"
|
||||
require "scripts/units"
|
||||
|
||||
-- levels
|
||||
require "levels"
|
||||
require "scripts/levels"
|
||||
current_level = levels.main_menu
|
||||
|
||||
end
|
||||
|
@ -53,14 +58,9 @@ function love.update(dt)
|
|||
fps_count = fps_count + 1
|
||||
|
||||
-- camera: slow, fast, medium?
|
||||
if love.keyboard.isDown("lshift") then
|
||||
speed = 2
|
||||
elseif love.keyboard.isDown("lctrl") then
|
||||
speed = 6
|
||||
else
|
||||
speed = 4
|
||||
end
|
||||
speed = g3d.camera.zoom/2
|
||||
|
||||
-- do camera
|
||||
if not game_pause then
|
||||
g3d.camera.strategyViewMovement(dt,speed,is_scrolling)
|
||||
-- movement: w,a,s,d,
|
||||
|
@ -82,12 +82,13 @@ function love.update(dt)
|
|||
end
|
||||
|
||||
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)
|
||||
is_scrolling = true
|
||||
end
|
||||
|
||||
function love.keypressed(key)
|
||||
-- pause the game and free the mouse
|
||||
-- pause the game
|
||||
if key == "escape" then
|
||||
if game_pause then
|
||||
game_pause = false
|
||||
|
@ -96,6 +97,14 @@ function love.keypressed(key)
|
|||
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
|
||||
|
||||
function love.draw()
|
||||
|
@ -103,13 +112,54 @@ function love.draw()
|
|||
game_width = love.graphics.getWidth()
|
||||
game_height = love.graphics.getHeight()
|
||||
|
||||
-- draw every model
|
||||
-- draw every model in entities
|
||||
local ent_count = 0
|
||||
for _, entity in pairs(current_level.entities) do
|
||||
ent_count = ent_count + 1
|
||||
if entity.model ~= nil then
|
||||
draw_entity(entity)
|
||||
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
|
||||
|
||||
-- do animated models
|
||||
-- draw selection
|
||||
if selecting_troops == true then
|
||||
love.graphics.rectangle("line",sel_pos_x,sel_pos_y, love.mouse.getX() - sel_pos_x, love.mouse.getY() - sel_pos_y)
|
||||
else
|
||||
|
||||
end
|
||||
-- print coords
|
||||
if game_pause then
|
||||
draw_pause_menu(30,30)
|
||||
else
|
||||
draw_debug()
|
||||
draw_combat_ui()
|
||||
end
|
||||
|
||||
for _, entity in pairs(current_level.entities) do
|
||||
if entity.model ~= nil then
|
||||
if entity.is_animated then
|
||||
love.graphics.print("["..entity.name.."] frame: "..entity.anim_frame.."/"..entity.anim_frames..", rm: \""..entity.rotate_mode.."\"",20,20)
|
||||
love.graphics.print("["..entity.name.."] animation: "..entity.anim_path,20,40)
|
||||
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)
|
||||
love.graphics.setColor(1,1,1,0.3)
|
||||
love.graphics.rectangle("fill", x, y, game_width-2*x, game_height-2*y)
|
||||
love.graphics.setColor(1,1,1,1)
|
||||
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
|
||||
|
@ -123,7 +173,7 @@ function love.draw()
|
|||
entity.model.mesh:setTexture(entity.anim_imgs[entity.anim_frame])
|
||||
end
|
||||
|
||||
-- do rotating models
|
||||
-- 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
|
||||
|
||||
|
@ -139,37 +189,37 @@ function love.draw()
|
|||
end
|
||||
|
||||
entity.model:draw()
|
||||
else
|
||||
else -- simple loaded entities dont require so much fuss
|
||||
entity:draw()
|
||||
end
|
||||
end
|
||||
|
||||
-- draw selection
|
||||
if selecting_troops == true then
|
||||
love.graphics.rectangle("line",sel_pos_x,sel_pos_y, love.mouse.getX() - sel_pos_x, love.mouse.getY() - sel_pos_y)
|
||||
else
|
||||
|
||||
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
|
||||
-- print coords
|
||||
if game_pause then
|
||||
draw_pause_menu(30,30)
|
||||
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)
|
||||
end
|
||||
|
||||
for _, entity in pairs(current_level.entities) do
|
||||
if entity.model ~= nil then
|
||||
if entity.is_animated then
|
||||
love.graphics.print("["..entity.name.."] frame: "..entity.anim_frame.."/"..entity.anim_frames..", rm: \""..entity.rotate_mode.."\"",20,20)
|
||||
love.graphics.print("["..entity.name.."] animation: "..entity.anim_path,20,40)
|
||||
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_pause_menu(x,y)
|
||||
love.graphics.setColor(1,1,1,0.3)
|
||||
love.graphics.rectangle("fill", x, y, game_width-2*x, game_height-2*y)
|
||||
love.graphics.setColor(1,1,1,1)
|
||||
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 = {
|
||||
elementalAir = nil,
|
||||
elementalArcane = nil,
|
||||
elementalEarth = nil,
|
||||
elementalFire = nil,
|
||||
elementalIce = nil,
|
||||
elementalMagma = nil,
|
||||
elementalPsychic = nil,
|
||||
elementalStorm = nil,
|
||||
elementalWater = nil,
|
||||
militia = nil,
|
||||
pikeman = nil,
|
||||
crossbow = nil,
|
||||
eliteCrossbow = nil,
|
||||
gryphon = nil,
|
||||
ancientGryphon = nil,
|
||||
swordman = nil,
|
||||
humanCaptain = nil,
|
||||
monk = nil,
|
||||
priest = nil,
|
||||
horseman = nil,
|
||||
cavailer = nil,
|
||||
knight = nil,
|
||||
paladin = nil,
|
||||
impling = nil,
|
||||
imp = nil,
|
||||
gog = nil,
|
||||
magog = nil,
|
||||
hellhound = nil,
|
||||
hellbeast = nil,
|
||||
demon = nil,
|
||||
archdemon = nil,
|
||||
pitfiend = nil,
|
||||
elitePitfiend = nil,
|
||||
efreet = nil,
|
||||
eliteEfreet = nil,
|
||||
devil = nil,
|
||||
theDevil = nil,
|
||||
skeleton = nil,
|
||||
skeletonRisen = nil,
|
||||
zombie = nil,
|
||||
zombieRisen = nil,
|
||||
spider = nil,
|
||||
spiderMatriarch = nil,
|
||||
spirit = nil,
|
||||
ghost = nil,
|
||||
vampire = nil,
|
||||
bloodlinePatriarch = nil,
|
||||
necromancer = nil,
|
||||
lich = nil,
|
||||
bloodknight = nil,
|
||||
deathknight = nil,
|
||||
dwarf1 = nil,
|
||||
dwarf2 = nil,
|
||||
pixie = nil,
|
||||
fairie = nil,
|
||||
satyrArcher = nil,
|
||||
satyrWarrior = nil,
|
||||
elvenHunter = nil,
|
||||
elvenCaptain = nil,
|
||||
deerWhite = nil,
|
||||
deerBrown = nil,
|
||||
spellweaver = nil,
|
||||
druid = nil,
|
||||
treant = nil,
|
||||
ent = nil
|
||||
_ariel = "assets/textures/characters/imp_ariel/portrait.png",
|
||||
elementalAir = "assets/textures/characters/elemental_air/portrait.png",
|
||||
elementalArcane = "assets/textures/characters/elemental_arcane/portrait.png",
|
||||
elementalEarth = "assets/textures/characters/elemental_earth/portrait.png",
|
||||
elementalFire = "assets/textures/characters/elemental_fire/portrait.png",
|
||||
elementalIce = "assets/textures/characters/elemental_ice/portrait.png",
|
||||
elementalMagma = "assets/textures/characters/elemental_magma/portrait.png",
|
||||
elementalPsychic = "assets/textures/characters/elemental_psychic/portrait.png",
|
||||
elementalStorm = "assets/textures/characters/elemental_storm/portrait.png",
|
||||
elementalWater = "assets/textures/characters/elemental_water/portrait.png",
|
||||
militia = "assets/textures/characters/militia/portrait.png",
|
||||
pikeman = "assets/textures/characters/pikeman/portrait.png",
|
||||
crossbow = "assets/textures/characters/crossbow/portrait.png",
|
||||
eliteCrossbow = "assets/textures/characters/elite_crossbow/portrait.png",
|
||||
gryphon = "assets/textures/characters/gryphon/portrait.png",
|
||||
ancientGryphon = "assets/textures/characters/ancient_gryphon/portrait.png",
|
||||
swordman = "assets/textures/characters/swordman/portrait.png",
|
||||
humanCaptain = "assets/textures/characters/human_captain/portrait.png",
|
||||
monk = "assets/textures/characters/monk/portrait.png",
|
||||
priest = "assets/textures/characters/priest/portrait.png",
|
||||
horseman = "assets/textures/characters/horseman/portrait.png",
|
||||
cavailer = "assets/textures/characters/cavailer/portrait.png",
|
||||
knight = "assets/textures/characters/knight/portrait.png",
|
||||
paladin = "assets/textures/characters/paladin/portrait.png",
|
||||
impling = "assets/textures/characters/impling/portrait.png",
|
||||
imp = "assets/textures/characters/imp/portrait.png",
|
||||
gog = "assets/textures/characters/gog/portrait.png",
|
||||
magog = "assets/textures/characters/magog/portrait.png",
|
||||
hellhound = "assets/textures/characters/hellhound/portrait.png",
|
||||
hellbeast = "assets/textures/characters/hellbeast/portrait.png",
|
||||
demon = "assets/textures/characters/demon/portrait.png",
|
||||
archdemon = "assets/textures/characters/archdemon/portrait.png",
|
||||
pitfiend = "assets/textures/characters/pitfiend/portrait.png",
|
||||
elitePitfiend = "assets/textures/characters/elite_pitfiend/portrait.png",
|
||||
efreet = "assets/textures/characters/efreet/portrait.png",
|
||||
eliteEfreet = "assets/textures/characters/elite_efreet/portrait.png",
|
||||
devil = "assets/textures/characters/devil/portrait.png",
|
||||
theDevil = "assets/textures/characters/the_devil/portrait.png",
|
||||
skeleton = "assets/textures/characters/skeleton/portrait.png",
|
||||
skeletonRisen = "assets/textures/characters/risen_skeleton/portrait.png",
|
||||
zombie = "assets/textures/characters/zombie/portrait.png",
|
||||
zombieRisen = "assets/textures/characters/risen_zombie/portrait.png",
|
||||
spider = "assets/textures/characters/spider/portrait.png",
|
||||
spiderMatriarch = "assets/textures/characters/spider_matriarch/portrait.png",
|
||||
spirit = "assets/textures/characters/spirit/portrait.png",
|
||||
ghost = "assets/textures/characters/ghost/portrait.png",
|
||||
vampire = "assets/textures/characters/vampire/portrait.png",
|
||||
bloodlinePatriarch = "assets/textures/characters/bloodline_patriarch/portrait.png",
|
||||
necromancer = "assets/textures/characters/necromancer/portrait.png",
|
||||
lich = "assets/textures/characters/lich/portrait.png",
|
||||
bloodknight = "assets/textures/characters/bloodknight/portrait.png",
|
||||
deathknight = "assets/textures/characters/deathknight/portrait.png",
|
||||
dwarf1 = "assets/textures/characters/dwarf1/portrait.png",
|
||||
dwarf2 = "assets/textures/characters/dwarf2/portrait.png",
|
||||
pixie = "assets/textures/characters/pixie/portrait.png",
|
||||
faerie = "assets/textures/characters/faerie/portrait.png",
|
||||
satyrArcher = "assets/textures/characters/satyr_archer/portrait.png",
|
||||
satyrWarrior = "assets/textures/characters/satyr_warrior/portrait.png",
|
||||
elvenHunter = "assets/textures/characters/elven_hunter/portrait.png",
|
||||
elvenCaptain = "assets/textures/characters/elven_captain/portrait.png",
|
||||
deerWhite = "assets/textures/characters/deer_white/portrait.png",
|
||||
deerBrown = "assets/textures/characters/deer_brown/portrait.png",
|
||||
spellweaver = "assets/textures/characters/spellweaver/portrait.png",
|
||||
druid = "assets/textures/characters/druid/portrait.png",
|
||||
treant = "assets/textures/characters/treant/portrait.png",
|
||||
ent = "assets/textures/characters/ent/portrait.png"
|
||||
}
|
||||
|
||||
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 = {
|
||||
idle = nil,
|
||||
walk = nil,
|
||||
|
@ -268,10 +276,10 @@ animation = {
|
|||
},
|
||||
impling = {
|
||||
idle = "assets/textures/characters/impling/idle",
|
||||
walk = nil,
|
||||
attack = nil,
|
||||
hit = nil,
|
||||
death = nil
|
||||
walk = "assets/textures/characters/impling/walk",
|
||||
attack = "assets/textures/characters/impling/attack",
|
||||
hit = "assets/textures/characters/impling/hit",
|
||||
death = "assets/textures/characters/impling/death"
|
||||
},
|
||||
imp = {
|
||||
idle = nil,
|
||||
|
@ -303,10 +311,10 @@ animation = {
|
|||
},
|
||||
hellbeast = {
|
||||
idle = "assets/textures/characters/hellbeast/idle",
|
||||
walk = nil,
|
||||
attack = nil,
|
||||
hit = nil,
|
||||
death = nil
|
||||
walk = "assets/textures/characters/hellbeast/walk",
|
||||
attack = "assets/textures/characters/hellbeast/attack",
|
||||
hit = "assets/textures/characters/hellbeast/hit",
|
||||
death = "assets/textures/characters/hellbeast/death"
|
||||
},
|
||||
demon = {
|
||||
idle = nil,
|
||||
|
@ -317,10 +325,10 @@ animation = {
|
|||
},
|
||||
archdemon = {
|
||||
idle = "assets/textures/characters/archdemon/idle",
|
||||
walk = nil,
|
||||
attack = nil,
|
||||
hit = nil,
|
||||
death = nil
|
||||
walk = "assets/textures/characters/archdemon/walk",
|
||||
attack = "assets/textures/characters/archdemon/attack",
|
||||
hit = "assets/textures/characters/archdemon/hit",
|
||||
death = "assets/textures/characters/archdemon/death"
|
||||
},
|
||||
pitfiend = {
|
||||
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.main_menu = {
|
||||
entities = {}
|
||||
entities = {},
|
||||
units = {}
|
||||
}
|
||||
|
||||
local entities = levels.main_menu.entities
|
||||
local units = levels.main_menu.units
|
||||
|
||||
-- campfire
|
||||
entities.campfire = {
|
||||
|
@ -28,23 +30,55 @@ end end
|
|||
|
||||
math.randomseed(3)
|
||||
-- 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
|
||||
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)
|
||||
table.insert(entities,imp)
|
||||
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
|
||||
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)
|
||||
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)
|
||||
end end
|
||||
creat_unit
|
||||
table.insert(units,"hellbeast")
|
||||
|
||||
-- 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")
|
||||
]]--
|
|
@ -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
|