/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-20 01:09:55 UTC
  • Revision ID: josh@9ix.org-20130520010955-8kzcxxe7sa8pdk8e
don't keep spawning rocks after death.

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
              the.bullets = Group:new()
96
96
              the.mirrors = Group:new()
97
97
              the.rocks = Group:new()
98
 
              the.interface = Group:new()
99
98
 
100
99
              the.bg = Tile:new{
101
100
                 image = 'data/stars3.png',
115
114
              self:add(the.rockColliders)
116
115
              self:add(the.mirrors)
117
116
              self:add(the.rocks)
118
 
              self:add(the.interface)
119
117
 
120
118
              the.cursor = Cursor:new()
121
119
              self:add(the.cursor)
122
120
 
123
121
              the.score = Text:new{
124
 
                 x = 8,
125
 
                 y = 8,
126
122
                 width = the.app.width,
127
 
                 --align = 'center',
 
123
                 align = 'center',
128
124
                 font = 25}
129
 
              the.interface:add(the.score)
 
125
              self:add(the.score)
130
126
 
131
127
              local hs = the.storage.data.highScore
132
128
              local m = hs / 60
133
129
              local s = hs % 60
134
130
 
135
131
              the.highScore = Text:new{
136
 
                 x = -8,
137
 
                 y = 8,
138
132
                 width = the.app.width,
139
133
                 align = 'right',
140
134
                 font = 25,
141
135
                 text = string.format('High Score: %d:%02d', m, s)
142
136
              }
143
 
              the.interface:add(the.highScore)
144
 
 
145
 
              the.over = Text:new{
146
 
                 y = the.app.height / 2,
147
 
                 width = the.app.width,
148
 
                 align = 'center',
149
 
                 font = 25,
150
 
                 text = "Game Over",
151
 
                 visible = false
152
 
              }
153
 
              the.interface:add(the.over)
154
 
 
155
 
 
156
 
              the.instructions = Text:new{
157
 
                 y = the.app.height / 2 + 32,
158
 
                 width = the.app.width,
159
 
                 align = 'center',
160
 
                 font = 12,
161
 
                 text = "Press Enter to start a new game\nPress Q to quit",
162
 
                 visible = false
163
 
              }
164
 
              the.interface:add(the.instructions)
 
137
              self:add(the.highScore)
165
138
 
166
139
              love.mouse.setGrab(true)
167
140
              love.mouse.setVisible(false)
212
185
                 -- end
213
186
              end,
214
187
   onEndFrame = function(self)
215
 
                   the.interface.translate.x = the.player.x - the.app.width / 2 + the.player.width / 2
216
 
                   the.interface.translate.y = the.player.y - the.app.height / 2 + the.player.height / 2
217
 
 
218
188
                   if the.player.active then
219
 
                      self:updateScore()
 
189
                      local t = love.timer.getTime() - self.gameStart
 
190
                      local m = t / 60
 
191
                      local s = t % 60
 
192
 
 
193
                      the.score.text = string.format('Score: %d:%02d', m, s)
 
194
                      the.score.y = the.player.y - the.app.height / 2 + the.player.height
 
195
                      the.score.x = the.player.x - the.app.width / 2
220
196
                   end
 
197
 
 
198
                   the.highScore.y = the.player.y - the.app.height / 2 + the.player.height
 
199
                   the.highScore.x = the.player.x - the.app.width / 2
221
200
                end,
222
201
   draw = function (self, x, y)
223
202
             View.draw(self, x, y)
224
 
             --love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
225
 
          end,
226
 
   updateScore = function(self)
227
 
                    local t = love.timer.getTime() - self.gameStart
228
 
                    local m = t / 60
229
 
                    local s = t % 60
230
 
 
231
 
                    the.score.text = string.format('Score: %d:%02d', m, s)
232
 
                    --the.score.y = the.player.y - the.app.height / 2 + the.player.height
233
 
                    --the.score.x = the.player.x - the.app.width / 2 + the.player.width
234
 
 
235
 
                    --the.highScore.y = the.player.y - the.app.height / 2 + the.player.height
236
 
                    --the.highScore.x = the.player.x - the.app.width / 2
237
 
                 end
 
203
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
 
204
          end
238
205
}
239
206
 
240
207
MenuScreen = View:extend {