-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
143 lines (125 loc) · 3.57 KB
/
main.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
require "screen"
require "camera"
require "buffer"
require "physics"
require "entities"
require "map"
require "env"
require "gui"
require "hud"
require "game"
--require "client"
function love.load()
player = nil
love.graphics.setDefaultImageFilter( "nearest", "nearest" )
--love.graphics.setMode(screen.width, screen.height, false, true, 0) --set the window dimensions to 650 by 650 with no fullscreen, vsync on, and no antialiasing
imagefont2 = love.graphics.newImage("images/imagefont2.png")
font2 = love.graphics.newImageFont(imagefont2,
" abcdefghijklmnopqrstuvwxyz" ..
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0" ..
"123456789.,!?-+/():;%&`'*#=[]\"")
imagefont = love.graphics.newImage("images/font.png")
font = love.graphics.newImageFont(imagefont," abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,!?-+/():;%&`'*#=[]\"")
love.graphics.setFont(font)
camera.scale(screen.scale)
gui.load()
end
function love.keypressed(key)
if key == "escape" then
love.event.push("quit")
end
if key == "h" then
if hud.enabled then
hud.enabled = false
else
hud.enabled = true
end
end
if key == "b" then
if buffer.enabled then
buffer.enabled = false
else
buffer.enabled = true
end
end
if key == "p" then
if physics.enabled then
physics.enabled = false
else
physics.enabled = true
end
end
if key == "m" then
map.unload()
end
if key == "q" then
map.load("test")
end
if key == "w" then
map.load("house1", "bedside")
end
if key == "s" then
game.start()
end
if key == "d" then
map.load("cubicles", "", "isometropolis")
end
if key == "e" then
--entities.new("coin", math.random(127.91, 128.19), math.random(127.91, 128.19), 32)
--entities.new("coin", math.random(127.91, 128.19), math.random(127.91, 128.19), 32)
--entities.new("coin", math.random(127.91, 128.19), math.random(127.91, 128.19), 32)
--entities.new("coin", math.random(127.91, 128.19), math.random(127.91, 128.19), 32)
--entities.new("coin", math.random(127.91, 128.19), math.random(127.91, 128.19), 32)
--entities.new("coin", math.random(127.91, 128.19), math.random(127.91, 128.19), 32)
--entities.new("coin", math.random(127.91, 128.19), math.random(127.91, 128.19), 32)
entities.new("coin", player.getX() + math.random(-0.20, 0.20), player.getY() + math.random(-0.20, 0.20), 32)
entities.new("coin", player.getX() + math.random(-0.20, 0.20), player.getY() + math.random(-0.20, 0.20), 32)
entities.new("coin", player.getX() + math.random(-0.20, 0.20), player.getY() + math.random(-0.20, 0.20), 32)
--entities.new("eyeball", player.getX() + math.random(-0.20, 0.20), player.getY() + math.random(-0.20, 0.20), 32)
--entities.new("ghost", player.getX() + math.random(-0.20, 0.20), player.getY() + math.random(-0.20, 0.20), 32)
--entities.new("eyeball_friend", player.getX() + math.random(-0.20, 0.20), player.getY() + math.random(-0.20, 0.20), 32)
end
if key == "n" then
poop = #entities.data
table.insert(entities.remove, poop)
entities.refresh = true
end
if key == "1" then
ACTIVE_PLAYER = 1
end
if key == "2" then
ACTIVE_PLAYER = 2
end
if key == "3" then
ACTIVE_PLAYER = 3
end
if key == "4" then
ACTIVE_PLAYER = 4
end
if key == "0" then
screen.scaleToggle()
end
end
function love.update(dt)
physics.update(dt)
entities.update(dt)
camera.update()
env.update(dt)
map.update(camera.x, camera.y)
end
function love.draw()
camera.set()
-- Draw the sprite buffer
if next(buffer.data) == nil then
entities.draw()
map.draw()
end
buffer:draw()
-- Draw env stuff
env.draw()
-- Draw the GUI
gui.draw()
-- Draw the HUD
hud.draw()
camera.unset()
end