bzr branch
http://9ix.org/bzr/zoeplat
2
by Josh C
basic tiles, map, player, movement |
1 |
STRICT = true |
2 |
DEBUG = true |
|
3 |
||
4 |
require 'zoetrope' |
|
5 |
||
6 |
Player = Tile:extend { |
|
7 |
image = 'data/player.png', |
|
3
by Josh C
jump |
8 |
onNew = function (self) |
9 |
self.velocity.y = 0 |
|
5
by Josh C
use built-in maxVelocity system |
10 |
self.maxVelocity.y = 400 |
3
by Josh C
jump |
11 |
end, |
4
by Josh C
fix jitter caused by focus shift happening in the wrong order. Looks |
12 |
onStartFrame = function (self) |
13 |
-- this is all in startframe so it happens before |
|
14 |
-- physics calc at beginning of update |
|
3
by Josh C
jump |
15 |
|
6
by Josh C
whitespace cleanup |
16 |
self.velocity.x = 0 |
17 |
self.acceleration.y = 800 |
|
18 |
||
19 |
if the.keys:pressed('left') then |
|
20 |
self.velocity.x = -200 |
|
21 |
elseif the.keys:pressed('right') then |
|
22 |
self.velocity.x = 200 |
|
23 |
end |
|
24 |
||
25 |
if the.keys:justPressed('up') then |
|
26 |
self.velocity.y = -400 |
|
27 |
end |
|
28 |
end, |
|
4
by Josh C
fix jitter caused by focus shift happening in the wrong order. Looks |
29 |
onUpdate = function (self) |
30 |
-- this is called after physics, so this makes sense here |
|
31 |
the.view.map:subdisplace(self) |
|
2
by Josh C
basic tiles, map, player, movement |
32 |
end |
33 |
} |
|
34 |
||
35 |
GameView = View:extend { |
|
36 |
onNew = function (self) |
|
37 |
self:loadLayers('data/map.lua') |
|
38 |
self.focus = the.player |
|
39 |
self:clampTo(self.map) |
|
4
by Josh C
fix jitter caused by focus shift happening in the wrong order. Looks |
40 |
end |
2
by Josh C
basic tiles, map, player, movement |
41 |
} |
42 |
||
43 |
the.app = App:new { |
|
44 |
onRun = function (self) |
|
45 |
self.view = GameView:new() |
|
46 |
end, |
|
47 |
onUpdate = function (self, dt) |
|
48 |
if the.keys:justPressed('escape') then |
|
49 |
love.event.quit() |
|
50 |
end |
|
51 |
end |
|
52 |
} |