-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgame.lua
70 lines (53 loc) · 1.48 KB
/
game.lua
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
_G.source_directory = "src."
local sd = _G.source_directory
_G.library_directory = "libs."
local libd = _G.library_directory
local inspect = require(libd .. "inspect")
local Dungeon = require(sd .. "dungeon")
local Items = require(sd .. "items")
local Player = require(sd .. "player")
local Solids = require(sd .. "solids")
local Tiles = require(sd .. "tiles")
local CameraSystem = require(sd .. "camerasystem")
local tileSize = Tiles.tileSize
local game = {}
function game.load()
love.graphics.setBackgroundColor(1,142,14)
Dungeon:initialize()
Player:initialize(Dungeon:getRandomRoomPosition())
local map = Dungeon.Map
local width, height = Dungeon.MapWidth, Dungeon.MapHeight
Solids:generateSolids(map, width, height)
CameraSystem:initialize(1.5, .01, true)
end
function game.update(dt)
Player:update(dt)
for i = 1, #Solids.solids do
local solid = Solids.solids[i]
Player:collideWithSolids(solid)
end
print(#Items)
CameraSystem:update(dt, Player.x, Player.y)
end
function game.draw()
CameraSystem:draw(function()
Dungeon:draw()
Player:draw()
Player:drawBullets()
Items:draw()
--black overlay
-- love.graphics.setColor(0,0,0, 60)
-- local width = love.graphics.getWidth()
-- local height = love.graphics.getHeight()
-- love.graphics.rectangle("fill", 0, 0, width, height)
end)
end
function game.mousepressed(x, y, button)
end
function game.keypressed(key)
Player:actionKey(key)
end
function game.keyreleased(key)
Player:releaseActionKey(key)
end
return game