forked from LordZamy/pokemon-love
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
47 lines (35 loc) · 1.05 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
-- Include Simple-Tiled-Implementation
local sti = require "ext/sti"
-- Include anim8
local anim8 = require "ext/anim8/anim8"
-- Include the Player class
local Player = require "src/player/player"
-- Add PlayerController
local PlayerController = require "src/player/controller"
-- Add InputController
local InputController = require "src/input/controller"
-- globals
GRID_SZ = 16
function love.load()
-- Load Maps
map = sti.new("assets/maps/build/town1.lua")
-- add custom sprite layer
spriteLayer = map:addCustomLayer("Sprites", 3)
-- create and init player
player = Player:new()
PlayerController:init(player)
-- init InputController by passing other controllers
InputController:init({PlayerController = PlayerController})
end
function love.update(dt)
map:update(dt)
player.currentAnimation:update(dt)
PlayerController:update(dt)
end
function love.draw()
map:draw()
player.currentAnimation:draw(player:sheet(), player.pos.x, player.pos.y)
end
function love.keypressed(key)
InputController.handler(key)
end