9
image = 'data/player.png',
10
onNew = function (self)
13
onStartFrame = function (self)
14
-- this is all in startframe so it happens before
15
-- physics calc at beginning of update
18
-- TODO: this can be replaced with sprite.maxVel.y
19
if self.velocity.y >= TERM_VEL then
20
self.velocity.y = TERM_VEL
21
self.acceleration.y = 0
23
self.acceleration.y = 800
26
if the.keys:pressed('left') then
27
self.velocity.x = -200
28
elseif the.keys:pressed('right') then
32
if the.keys:justPressed('up') then
33
self.velocity.y = -400
36
onUpdate = function (self)
37
-- this is called after physics, so this makes sense here
38
the.view.map:subdisplace(self)
42
GameView = View:extend {
43
onNew = function (self)
44
self:loadLayers('data/map.lua')
45
self.focus = the.player
46
self:clampTo(self.map)
51
onRun = function (self)
52
self.view = GameView:new()
54
onUpdate = function (self, dt)
55
if the.keys:justPressed('escape') then
b'\\ No newline at end of file'