/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:22:30 UTC
  • Revision ID: josh@9ix.org-20130516022230-9mqgevjra6wmt3vf
keep score, center mouse on start

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
 
 
93
86
              the.rockColliders = Group:new()
94
87
              the.bullets = Group:new()
95
88
              the.mirrors = Group:new()
123
116
                 font = 25}
124
117
              self:add(the.score)
125
118
 
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
 
 
138
119
              love.mouse.setGrab(true)
139
120
              love.mouse.setVisible(false)
140
121
              love.mouse.setPosition(the.app.width / 2, the.app.height / 2)
186
167
                      the.score.y = the.player.y - the.app.height / 2 + the.player.height
187
168
                      the.score.x = the.player.x - the.app.width / 2
188
169
                   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
192
170
                end,
193
171
   draw = function (self, x, y)
194
172
             View.draw(self, x, y)