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', |
|
8 |
onUpdate = function (self) |
|
9 |
self.velocity.x = 0 |
|
10 |
self.velocity.y = 0 |
|
11 |
||
12 |
if the.keys:pressed('left') then |
|
13 |
self.velocity.x = -200 |
|
14 |
elseif the.keys:pressed('right') then |
|
15 |
self.velocity.x = 200 |
|
16 |
end |
|
17 |
end |
|
18 |
} |
|
19 |
||
20 |
GameView = View:extend { |
|
21 |
onNew = function (self) |
|
22 |
self:loadLayers('data/map.lua') |
|
23 |
self.focus = the.player |
|
24 |
self:clampTo(self.map) |
|
25 |
end, |
|
26 |
||
27 |
onUpdate = function (self, dt) |
|
28 |
self.map:subdisplace(the.player) |
|
29 |
end |
|
30 |
} |
|
31 |
||
32 |
the.app = App:new { |
|
33 |
onRun = function (self) |
|
34 |
self.view = GameView:new() |
|
35 |
end, |
|
36 |
onUpdate = function (self, dt) |
|
37 |
if the.keys:justPressed('escape') then |
|
38 |
love.event.quit() |
|
39 |
end |
|
40 |
end |
|
41 |
} |