/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-09 04:06:46 UTC
  • Revision ID: josh@9ix.org-20130309040646-2hvgxi5b87baez5g
make player an animation

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
require 'zoetrope'
5
5
 
6
 
Player = Tile:extend {
 
6
Player = Animation:extend {
7
7
   image = 'data/player.png',
 
8
   height = 32,
 
9
   width = 32,
 
10
   sequences = {
 
11
      stand = { frames = { 1 }, fps = 1 },
 
12
      walk = { frames = { 2, 3 }, fps = 5 },
 
13
      jump = { frames = { 4 }, fps = 1 }
 
14
   },
8
15
   onNew = function (self)
9
16
              self.velocity.y = 0
10
17
              self.maxVelocity.y = 400
18
25
 
19
26
                     if the.keys:pressed('left') then
20
27
                        self.velocity.x = -200
 
28
                        self:play('walk')
21
29
                     elseif the.keys:pressed('right') then
22
30
                        self.velocity.x = 200
 
31
                        self:play('walk')
 
32
                     else
 
33
                        self:play('stand')
23
34
                     end
24
35
 
25
36
                     if the.keys:justPressed('up') then