/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-06-10 21:37:59 UTC
  • Revision ID: josh@9ix.org-20130610213759-drnecjpritehmz3t
bigger area, more planets

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
              --the.rocks = Group:new()
98
98
              the.interface = Group:new()
99
99
              the.planets = Group:new()
100
 
              the.indicators = Group:new()
101
100
 
102
101
              the.bg = Tile:new{
103
102
                 image = 'data/stars3.png',
119
118
              --self:add(the.rockColliders)
120
119
              self:add(the.mirrors)
121
120
              --self:add(the.rocks)
122
 
              self:add(the.indicators)
123
121
              self:add(the.interface)
124
122
 
125
123
              for _ = 1, math.random(6) do
132
130
                    rotation = math.random() * math.pi
133
131
                 }
134
132
                 the.planets:add(planet)
135
 
 
136
 
                 planet.indicator = Tile:new{
137
 
                    image = 'data/planet1ind.png',
138
 
                 }
139
 
                 the.indicators:add(planet.indicator)
140
133
              end
141
134
 
142
135
              the.cursor = Cursor:new()
148
141
                 width = the.app.width,
149
142
                 --align = 'center',
150
143
                 font = 25}
151
 
              --the.interface:add(the.score)
 
144
              the.interface:add(the.score)
152
145
 
153
146
              local hs = the.storage.data.highScore
154
147
              local m = hs / 60
162
155
                 font = 25,
163
156
                 text = string.format('High Score: %d:%02d', m, s)
164
157
              }
165
 
              --the.interface:add(the.highScore)
 
158
              the.interface:add(the.highScore)
166
159
 
167
160
              the.over = Text:new{
168
161
                 y = the.app.height / 2,
226
219
 
227
220
                 the.bullets:collide(the.rockColliders)
228
221
 
229
 
                 -- this should really go somewhere else...
230
 
                 for _, planet in ipairs(the.planets.sprites) do
231
 
                    local indx, indy
232
 
                    local pvec = vector.new(
233
 
                       planet.x - the.player.x + planet.width / 2,
234
 
                       planet.y - the.player.y + planet.height / 2 )
235
 
 
236
 
                    -- TODO: is there a better way to specify the
237
 
                    -- screen rectangle?
238
 
                    if planet:intersects(the.player.x - the.app.width / 2,
239
 
                                         the.player.y - the.app.height / 2,
240
 
                                         the.app.width,
241
 
                                         the.app.height) then
242
 
                       -- planet is on the screen
243
 
                       planet.indicator.visible = false
244
 
                    else
245
 
                       planet.indicator.visible = true
246
 
 
247
 
                       if math.abs(pvec.x) / math.abs(pvec.y) > the.app.width / the.app.height then
248
 
                          indx = (the.app.width / 2 - 10) * util.signOf(pvec.x) + 8
249
 
                          indy = (the.app.width / 2 - 10) * pvec.y / math.abs(pvec.x)
250
 
                       else
251
 
                          indy = (the.app.height / 2 - 10) * util.signOf(pvec.y) + 8
252
 
                          indx = (the.app.height / 2 - 10) * pvec.x / math.abs(pvec.y)
253
 
                       end
254
 
 
255
 
                       planet.indicator.x = the.player.x + indx
256
 
                       planet.indicator.y = the.player.y + indy
257
 
                    end
258
 
                 end
259
 
 
260
222
                 -- for _, mirror in ipairs(the.mirrors.sprites) do
261
223
                 --    if not mirror.of then
262
224
                 --       print('mirror:' .. inspect(mirror))
312
274
 
313
275
              self.view = GameView:new()
314
276
 
 
277
              -- should fail silently if it can't go to fullscreen...
 
278
              love.graphics.toggleFullscreen()
 
279
 
315
280
              if DEBUG then
316
281
                 self.console:watch('VERSION', 'VERSION')
317
282
                 self.console:watch('updateTook', 'the.updateTook')
354
319
               end
355
320
            end
356
321
}
357
 
 
358
 
realRun = love.run
359
 
function love.run()
360
 
   -- should fail silently if it can't go to fullscreen...
361
 
   love.graphics.toggleFullscreen()
362
 
 
363
 
   realRun()
364
 
end
 
 
b'\\ No newline at end of file'