-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
66 lines (56 loc) · 1.46 KB
/
main.lua
File metadata and controls
66 lines (56 loc) · 1.46 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
class = require("middleclass")
require("player")
require("aabb")
require("vector")
require("stage")
require("tile")
require("inherit")
require("movingplatform")
require("gamecomponent")
require("gameobject")
require("camera")
require("tilemap")
local stage
function love.load()
--[[
For each tile, get its sprite property and put it in the spriteSheet
--]]
love.window.setTitle("Demo")
love.window.setMode(640, 480, {fullscreen = false})
local mapData = {
{0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,1,1,0,1,0,0,0,0,0,0,0},
{0,0,0,1,1,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,1,0,0,0,0,0,0,0},
{1,1,1,0,0,1,1,1,0,0,1,0,0,0},
{1,1,1,1,2,1,1,1,1,0,0,0,0,0},
{1,1,1,1,0,0,1,1,1,1,1,1,1,1}
}
local blockSprite = love.graphics.newImage("block.png")
stage = Stage:new()
stage:addTileMap(mapData, blockSprite, 32)
sprPlayer = love.graphics.newImage("player.png")
local playerObject = stage:addGameObject()
local playerBox = playerObject:addComponent(AABB)
playerBox.pos = Vector:new(60,30)
playerBox.width = 32
playerBox.height = 32
local playerScript = playerObject:addComponent(Player)
--set values here should use initializer function
playerScript.sprite = sprPlayer
playerScript.tileMap = stage.tileMap --bad
stage.camera:follow(playerBox.pos)
stage:load()
end
function love.keypressed(key, unicode)
if key == "escape" then
love.event.quit()
end
end
function love.update(dt)
stage:update()
end
function love.draw()
stage:draw()
end