/traderous

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

« back to all changes in this revision

Viewing changes to main.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:
83
83
              --    end
84
84
              -- end
85
85
 
 
86
              the.storage = Storage:new{filename = 'scores.lua'}
 
87
              the.storage:load()
 
88
              if not the.storage.data.highScore then
 
89
                 print('initializing storage')
 
90
                 the.storage.data = {highScore = 0}
 
91
              end
 
92
 
86
93
              the.rockColliders = Group:new()
87
94
              the.bullets = Group:new()
88
95
              the.mirrors = Group:new()
116
123
                 font = 25}
117
124
              self:add(the.score)
118
125
 
 
126
              local hs = the.storage.data.highScore
 
127
              local m = hs / 60
 
128
              local s = hs % 60
 
129
 
 
130
              the.highScore = Text:new{
 
131
                 width = the.app.width,
 
132
                 align = 'right',
 
133
                 font = 25,
 
134
                 text = string.format('High Score: %d:%02d', m, s)
 
135
              }
 
136
              self:add(the.highScore)
 
137
 
119
138
              love.mouse.setGrab(true)
120
139
              love.mouse.setVisible(false)
121
140
              love.mouse.setPosition(the.app.width / 2, the.app.height / 2)
167
186
                      the.score.y = the.player.y - the.app.height / 2 + the.player.height
168
187
                      the.score.x = the.player.x - the.app.width / 2
169
188
                   end
 
189
 
 
190
                   the.highScore.y = the.player.y - the.app.height / 2 + the.player.height
 
191
                   the.highScore.x = the.player.x - the.app.width / 2
170
192
                end,
171
193
   draw = function (self, x, y)
172
194
             View.draw(self, x, y)