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
|
STRICT = true
DEBUG = true
require 'zoetrope'
deque = require 'deque'
--inspect = require 'inspect'
require 'sprite'
require 'util'
require 'version'
require 'player'
require 'clone'
require 'goal'
require 'goal_person'
dirs = {'left', 'right', 'up', 'down'}
GameView = View:extend {
onNew = function (self)
self:loadLayers('data/map.lua')
local tw = math.floor(the.app.width / 16)
local th = math.floor(the.app.height / 16)
the.player = Player:new{
x = math.random(2, tw-2) * 16,
y = math.random(2, th-2) * 16
}
self:add(the.player)
the.goalPerson = GoalPerson:new{
x = math.random(2, tw-2) * 16,
y = math.random(2, th-2) * 16
}
self:add(the.goalPerson)
the.clones = Group:new()
self:add(the.clones)
for _ = 1, 15 do
the.clones:add(Clone:new {
x = math.random(2, tw-2) * 16,
y = math.random(2, th-2) * 16
})
end
end,
onUpdate = function(self, dt)
if the.player.moved then
-- this should encapsulate
the.clones:collide(the.player)
the.goalPerson:collide(the.player)
the.goalPerson:doMove()
for _, np in ipairs(the.clones.sprites) do
np:doMove()
end
-- yeah, again. once for flip, twice for displace
the.clones:collide(the.player)
the.clones:collide(self.map)
the.player:collide(self.map)
the.goalPerson:collide(self.map)
the.clones:collide()
if math.random(1,5) == 1 then
local c = the.clones.sprites[math.random(the.clones:count())]
if not c.cured then
c.image = 'data/goal.png'
end
end
the.player.moved = false
end
if the.keys:justPressed('escape', 'q') then
the.app:quit()
end
end,
}
the.app = App:new {
name = "LD28",
fps = 30,
onRun = function (self)
print('Version: ' .. VERSION)
self.view = GameView:new()
if DEBUG then
self.console:watch('VERSION', 'VERSION')
-- back off that dark overlay a bit
self.console.fill.fill[4] = 75
end
end,
onUpdate = function (self, dt)
if the.keys:justPressed('f1') then
local ss = love.graphics.newScreenshot()
ss:encode('screenshot-' ..love.timer.getTime()..'.png')
end
end
}
|