/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 22:06:58 UTC
  • Revision ID: josh@9ix.org-20130305220658-92yptjso9z57vzly
use zoetrope 288:a82a08660477 2013-02-23

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
STRICT = true
 
2
DEBUG = true
 
3
 
 
4
require 'zoetrope'
 
5
 
 
6
Player = Tile:extend {
 
7
   image = 'data/player.png',
 
8
   onNew = function (self)
 
9
              self.velocity.y = 0
 
10
              self.maxVelocity.y = 400
 
11
           end,
 
12
   onStartFrame = function (self)
 
13
                     -- this is all in startframe so it happens before
 
14
                     -- physics calc at beginning of update
 
15
 
 
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,
 
29
   onUpdate = function (self)
 
30
                 -- this is called after physics, so this makes sense here
 
31
                 the.view.map:subdisplace(self)
 
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)
 
40
           end
 
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
}
 
 
b'\\ No newline at end of file'