-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
74 lines (69 loc) · 2 KB
/
Copy pathmain.lua
File metadata and controls
74 lines (69 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
-- Main
require("requirement")
-- Init Player
local player = love.filesystem.getInfo('player')
if player == nil then
-- Create First Character
player = Player:new("Wei-Player")
player:addChar(Char:new("Wei-Char"))
end
-- Load World and Constant Entities
local StartTime = math.floor(love.timer.getTime())
local panel = Panel:new(10, 10)
local log = Panel:new(600, 10)
local control = {}
local world = {}
local agent = {}
function love.load()
love.window.setTitle("CIRCLE")
love.graphics.setBackgroundColor(0, 0, 0)
-- Init Control
control = Control:keyboard()
-- Init World
Physics:load()
Shader:load()
world = World:new({id=2, log=log, control=control})
world:initLevel()
-- Select Char
agent = Agent:get(world, player.chars[1])
world:addObj(agent)
end
function love.update(dt)
-- Switch World
if world.port > 0 then
world:clear()
world.id = world.port
world.port = 0
world:initLevel()
agent:resetPosition()
Camera:setObj(world, agent)
end
-- Update Control, World and Physics
control:update(dt)
world:update(dt)
Physics:update(dt)
-- Update Panel
panel:update("Time:" .. tostring(math.floor(love.timer.getTime()) - StartTime) .. " FPS:" .. tostring(love.timer.getFPS()))
panel:add("Window - W:" .. tostring(world.w) .. " H:" .. tostring(world.h) .. " DT:" .. tostring(dt))
panel:add("Circle - X:" .. tostring(agent.x) .. " Y:" .. tostring(agent.y) .. " HP:" .. tostring(agent.hp))
panel:add("Obj Count:" .. tostring(#world.objs))
-- Update Log
log:trim()
for n, a, b, c, d, e, f in love.event.poll() do
log:add("Event: " .. n .. " " .. tostring(a))
end
-- Update Camera
Camera:follow(world, agent)
Camera:update(dt)
end
function love.draw()
-- Shader on Camera to World
Shader:set({screen={world.w, world.h}})
Camera:set()
world:draw()
Camera:unset()
Shader:unset()
-- Draw Panel
panel:draw()
log:draw()
end