bzr branch
http://9ix.org/bzr/ld26
5
by Josh C
load a level, move a player around |
1 |
Player = Tile:extend { |
9
by Josh C
levels hash, scale player |
2 |
image = 'data/player-null.png', |
18
by Josh C
village, lake |
3 |
minY = 0, maxY = 600, |
5
by Josh C
load a level, move a player around |
4 |
onNew = function(self) |
9
by Josh C
levels hash, scale player |
5 |
the.player = self |
6 |
||
7 |
self.movementScale = self.height / 32 |
|
12
by Josh C
area transitions |
8 |
--print(self.movementScale) |
9
by Josh C
levels hash, scale player |
9 |
|
10 |
--self.scale = self.scaleHeight / self.height |
|
11 |
--self.width = self.height * .826 |
|
12 |
--self.width = self.width * self.scale |
|
13 |
--self:updateQuad() |
|
5
by Josh C
load a level, move a player around |
14 |
end, |
15 |
onStartFrame = function(self) |
|
10
by Josh C
scale movement with player size |
16 |
local ms = self.movementScale |
15
by Josh C
more transitions and collisions |
17 |
if DEBUG and the.console.visible then |
18 |
ms = ms * 4 |
|
19 |
end |
|
10
by Josh C
scale movement with player size |
20 |
|
5
by Josh C
load a level, move a player around |
21 |
if the.keys:pressed('up') then |
10
by Josh C
scale movement with player size |
22 |
self.velocity.y = -100 * ms |
5
by Josh C
load a level, move a player around |
23 |
elseif the.keys:pressed('down') then |
10
by Josh C
scale movement with player size |
24 |
self.velocity.y = 100 * ms |
5
by Josh C
load a level, move a player around |
25 |
else |
26 |
self.velocity.y = 0 |
|
27 |
end |
|
28 |
||
29 |
if the.keys:pressed('right') then |
|
10
by Josh C
scale movement with player size |
30 |
self.velocity.x = 100 * ms |
5
by Josh C
load a level, move a player around |
31 |
elseif the.keys:pressed('left') then |
10
by Josh C
scale movement with player size |
32 |
self.velocity.x = -100 * ms |
5
by Josh C
load a level, move a player around |
33 |
else |
34 |
self.velocity.x = 0 |
|
35 |
end |
|
11
by Josh C
player min/maxY on a level |
36 |
end, |
12
by Josh C
area transitions |
37 |
onUpdate = function(self, dt) |
38 |
self:collide(the.view) |
|
39 |
end, |
|
11
by Josh C
player min/maxY on a level |
40 |
onEndFrame = function(self) |
41 |
if self.y < self.minY then |
|
42 |
self.y = self.minY |
|
43 |
end |
|
44 |
if self.y > self.maxY then |
|
45 |
self.y = self.maxY |
|
46 |
end |
|
47 |
end |
|
5
by Josh C
load a level, move a player around |
48 |
} |