-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.lua
86 lines (70 loc) · 2.06 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
require "isoTerrain"
require "block"
require "avatar"
require "isoCreator"
ic = {}
alert = ""
c = {}
function love.load()
love.graphics.setBackgroundColor(100, 100, 100)
ic = IsoCreator.create()
ic:creatorLoad()
ic.newTerrain:loadGridAndAvatars("grid2.txt", "avatars.txt")
local spritesheet = love.graphics.newImage("spritesheet.png");
local anim = newAnimation(spritesheet, 62, 66, 0.2, 0)
c = ic.newTerrain:getAvatarById(1)
c:addAnimation("test", anim)
c.animating = true
ic.newTerrain:loadBlockTypes("types.txt")
end
function love.update(dt)
c = ic.newTerrain:getAvatarById(1)
c:update(dt)
end
function love.draw()
ic:draw()
love.graphics.print(alert, 0, 100)
-- if the user is pressing CTRL-S
if (love.keyboard.isDown("lctrl") or love.keyboard.isDown("rctrl") ) and love.keyboard.isDown("s") then
-- save the grid and avatars
ic.newTerrain:saveGridAndAvatars("grid2.txt", "avatars.txt")
ic.newTerrain:saveBlockTypes("types.txt")
end
end
function love.keypressed(key, unicode)
if key == "left" then
ic.blueprint:translate(-100, 0)
ic.newTerrain:translate(-100, 0)
elseif key == "right" then
ic.blueprint:translate(100, 0)
ic.newTerrain:translate(100, 0)
elseif key == "up" then
ic.blueprint:translate(0, -100)
ic.newTerrain:translate(0, -100)
elseif key == "down" then
ic.blueprint:translate(0, 100)
ic.newTerrain:translate(0, 100)
end
if table.getn(ic.newTerrain.avatarModel) >= 1 then
local avatar = ic.newTerrain:getAvatarById(1)
if key == "w" then
ic.newTerrain:moveAvatar(avatar, 0, -1)
elseif key == "a" then
ic.newTerrain:moveAvatar(avatar, 1, 0)
elseif key == "s" then
ic.newTerrain:moveAvatar(avatar, 0, 1)
elseif key == "d" then
ic.newTerrain:moveAvatar(avatar, -1, 0)
end
end
ic:keypressed(key, unicode)
end
function love.mousepressed(x, y, button)
ic:mousepressed(x, y, button)
end
function love.mousereleased(x, y, button)
ic:mousereleased(x, y, button)
end
function love.quit()
print("Thanks for playing! Come back soon!")
end