-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
39 lines (32 loc) · 875 Bytes
/
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
require 'input'
require 'player'
require 'obstacle'
love.animation = require 'vendor/anim8'
local entities = {}
local player = Player:new(love, {x = 100, y = 100})
local obstacle = Obstacle:new(love, {x = 200, y = 200})
function love.load()
table.insert(entities, player)
table.insert(entities, obstacle)
love.input.bind('up', 'up')
love.input.bind('left', 'left')
love.input.bind('right', 'right')
love.input.bind('down', 'down')
end
function love.update(dt)
for _, entity in pairs(entities) do
entity:update(dt)
for _, other in pairs(entities) do
if other ~= entity then
if entity:collidingWith(other) then
entity:collide(other)
end
end
end
end
end
function love.draw()
for _, e in pairs(entities) do
e:draw()
end
end