/zoeplat

To get this branch, use:
bzr branch http://9ix.org/bzr/zoeplat

« back to all changes in this revision

Viewing changes to main.lua

  • Committer: Josh C
  • Date: 2013-03-05 00:14:58 UTC
  • Revision ID: josh@9ix.org-20130305001458-206jxv29dgeenj3n
jump

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
STRICT = true
 
2
DEBUG = true
 
3
 
 
4
require 'zoetrope'
 
5
 
 
6
TERM_VEL = 400
 
7
 
 
8
Player = Tile:extend {
 
9
   image = 'data/player.png',
 
10
   onNew = function (self)
 
11
              self.velocity.y = 0
 
12
           end,
 
13
   onUpdate = function (self)
 
14
 
 
15
                 self.velocity.x = 0
 
16
                 if self.velocity.y >= TERM_VEL then
 
17
                    self.velocity.y = TERM_VEL
 
18
                    self.acceleration.y = 0
 
19
                 else
 
20
                    self.acceleration.y = 800
 
21
                 end
 
22
 
 
23
                 if the.keys:pressed('left') then
 
24
                    self.velocity.x = -200
 
25
                 elseif the.keys:pressed('right') then
 
26
                    self.velocity.x = 200
 
27
                 end
 
28
 
 
29
                 if the.keys:justPressed('up') then
 
30
                    self.velocity.y = -400
 
31
                 end
 
32
 
 
33
              end
 
34
}
 
35
 
 
36
GameView = View:extend {
 
37
   onNew = function (self)
 
38
              self:loadLayers('data/map.lua')
 
39
              self.focus = the.player
 
40
              self:clampTo(self.map)
 
41
           end,
 
42
 
 
43
   onEndFrame = function (self, dt)
 
44
                   self.map:subdisplace(the.player)
 
45
                end
 
46
}
 
47
 
 
48
the.app = App:new {
 
49
   onRun = function (self)
 
50
              self.view = GameView:new()
 
51
           end,
 
52
   onUpdate = function (self, dt)
 
53
                 if the.keys:justPressed('escape') then
 
54
                    love.event.quit()
 
55
                 end
 
56
              end
 
57
}
 
 
b'\\ No newline at end of file'