-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
132 lines (107 loc) · 2.83 KB
/
main.lua
File metadata and controls
132 lines (107 loc) · 2.83 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
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
require "src/dependancies"
VIRTUAL_WIDTH = 640
VIRTUAL_HEIGHT = 360
WINDOW_WIDTH = 1280
WINDOW_HEIGHT = 720
PLAYER_WALKING_SPEED = 120
COLLIDABLE = {
643, 728, 645, 647, 765, 766, 687, 726, 686, 727, 764, 565,
566, 567, 525, 526, 527, 485, 486, 487, 192, 193, 153, 152,
601, 564, 523, 562, 522, 603, 604, 524, 602, 641, 561, 642,
644, 646, 685, 723, 725, 681, 721, 683, 205, 204, 206, 491,
490, 450, 451, 168, 167, 127, 128, 87, 88, 89, 49, 48, 47,
8, 9, 7, 10, 50, 90, 130, 170, 129, 171, 131, 91, 51, 11,
208, 445, 405, 446, 447, 407, 361, 362, 442, 443, 441,
367, 285, 324, 325, 323, 283, 41, 82, 81, 42, 44, 43, 83,
339, 379, 341, 299, 260, 810, 770, 730, 690, 691, 731, 771,
811, 284, 296, 254, 298, 337
}
COLLIDABLE_TOP = {
442
}
COLLIDABLE_RIGHT = {
367, 407
}
COLLIDABLE_LEFT = {
365, 405
}
COLLIDABLE_BOTTOM = {
446
}
width = 64
height = 55
startX = 0
startY = 10
jumpY = 15
jumpX = 0
function love.load()
math.randomseed(os.time())
love.graphics.setDefaultFilter('nearest', 'nearest')
love.window.setTitle('Exeler')
push:setupScreen(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT, {
fullscreen = false,
vsync = true,
resizable = true
})
gStateMachine = StateMachine{
["start"] = function() return StartState() end,
["play"] = function() return PlayState() end,
}
gStateMachine:change("start")
love.keyboard.keysPressed = {}
end
function love.resize(w, h)
push:resize(w, h)
end
function love.keypressed(key)
if key == "escape" then
love.event.quit()
end
love.keyboard.keysPressed[key] = true
table.insert(love.keyboard.keysPressed, key)
end
function love.draw()
push:start()
gStateMachine:render()
push:finish()
end
function love.update(dt)
Timer.update(dt)
gStateMachine:update(dt)
love.keyboard.keysPressed = {}
end
function conf(t)
t.console = true
end
function love.textinput(t)
text = t
end
function quadVisualizer(width, height, atlas, startX, startY, jumpX, jumpY)
startX = startX or 0
startY = startY or 0
jumpX = jumpX or 0
jumpY = jumpY or 0
local cols = math.floor((atlas:getWidth() + jumpX) / (width + jumpX))
local rows = math.floor((atlas:getHeight() + jumpY) / (height + jumpY))
for y = 0, rows - 1 do
for x = 0, cols - 1 do
local posX = startX + x * (width + jumpX)
local posY = startY + y * (height + jumpY)
love.graphics.setColor(1, 1, 1, 1)
love.graphics.rectangle("line", posX, posY, width, height)
end
end
end
function keyPressed()
return #love.keyboard.keysPressed >= 1
end
function wasPressed(key)
return love.keyboard.keysPressed[key]
end
function getText(prev)
if text then
return prev .. text
else
return prev
end
end