/spacey

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

« back to all changes in this revision

Viewing changes to player.lua

  • Committer: Josh C
  • Date: 2013-05-16 02:41:58 UTC
  • Revision ID: josh@9ix.org-20130516024158-d5jtkfvd2qw709xo
record high scores

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
   maxVelocity = {x=velLimit,y=velLimit},
27
27
   minVelocity = {x=-velLimit, y=-velLimit},
28
28
   lastFired = 0,
29
 
   onNew = function(self)
30
 
              self.thrust = Tile:new{image = 'data/thrust.png'}
31
 
           end,
32
29
   onStartFrame = function(self)
33
30
                     --- TAKE 2
34
31
 
42
39
                     if mouseVec:len2() > 64^2 then
43
40
                        self.acceleration = vector.new(300, 0)
44
41
                        self.acceleration:rotate_inplace(self.rotation)
45
 
                        self.thrust.visible = true
46
42
                     else
47
43
                        self.acceleration = {x=0, y=0}
48
 
                        self.thrust.visible = false
49
44
                        if DEBUG and the.console.visible then
50
45
                           self.velocity = {x=0, y=0}
51
46
                        end
63
58
                     end
64
59
                  end,
65
60
   onUpdate = function(self)
66
 
                 self.thrust.x = self.x - self.width
67
 
                 self.thrust.y = self.y
68
 
                 self.thrust.rotation = self.rotation
69
61
              end,
70
62
   onEndFrame = function(self)
71
63
                   self:collide(the.rockColliders)
79
71
                                       })
80
72
 
81
73
                     self:die()
82
 
                     self.thrust:die()
83
 
 
84
 
                     the.over.visible = true
85
 
                     the.instructions.visible = true
86
 
                     the.app.view:updateScore()
87
 
 
 
74
 
 
75
                     local over = Text:new{
 
76
                        y = self.y,
 
77
                        x = self.x - the.app.width / 2,
 
78
                        width = the.app.width,
 
79
                        align = 'center',
 
80
                        font = 25,
 
81
                        text = "Game Over" }
 
82
                     the.app.view:add(over)
 
83
 
 
84
                     --the.storage.data.highScore
88
85
                     local score = love.timer.getTime() - the.app.view.gameStart
89
86
                     if score > the.storage.data.highScore then
90
87
                        the.storage.data.highScore = score