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
|
Player = Tile:extend {
image = 'data/player-null.png',
onNew = function(self)
the.player = self
self.movementScale = self.height / 32
--print(self.movementScale)
--self.scale = self.scaleHeight / self.height
--self.width = self.height * .826
--self.width = self.width * self.scale
--self:updateQuad()
end,
onStartFrame = function(self)
local ms = self.movementScale
if the.keys:pressed('up') then
self.velocity.y = -100 * ms
elseif the.keys:pressed('down') then
self.velocity.y = 100 * ms
else
self.velocity.y = 0
end
if the.keys:pressed('right') then
self.velocity.x = 100 * ms
elseif the.keys:pressed('left') then
self.velocity.x = -100 * ms
else
self.velocity.x = 0
end
end,
onUpdate = function(self, dt)
self:collide(the.view)
end,
onEndFrame = function(self)
if self.y < self.minY then
self.y = self.minY
end
if self.y > self.maxY then
self.y = self.maxY
end
end
}
|