/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-04 23:27:03 UTC
  • Revision ID: josh@9ix.org-20130304232703-nob2mg5wbo5co5is
basic tiles, map, player, movement

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
   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
}
 
 
b'\\ No newline at end of file'