/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:
16
16
require 'bullet'
17
17
require 'rock'
18
18
require 'boom'
19
 
require 'planet'
20
19
 
21
20
util = {
22
21
   signOf = function(value)
98
97
              --the.rocks = Group:new()
99
98
              the.interface = Group:new()
100
99
              the.planets = Group:new()
101
 
              the.indicators = Group:new()
102
100
 
103
101
              the.bg = Tile:new{
104
102
                 image = 'data/stars3.png',
110
108
              self:add(the.planets)
111
109
 
112
110
              --the.player = CrystalPlayer:new{x=400,y=300}
113
 
              the.player = SpacePlayer:new{x=the.bg.width / 2, y=the.bg.height / 2}
 
111
              the.player = SpacePlayer:new{x=1366,y=768}
114
112
              self:add(the.player)
115
113
              self:add(the.player.thrust)
116
114
 
120
118
              --self:add(the.rockColliders)
121
119
              self:add(the.mirrors)
122
120
              --self:add(the.rocks)
123
 
              self:add(the.indicators)
124
121
              self:add(the.interface)
125
122
 
126
123
              for _ = 1, math.random(6) do
127
 
                 local planet = Planet:new{
 
124
                 local planet = Tile:new{
 
125
                    image = 'data/planet1.png',
128
126
                    x = math.random(the.app.width / 2,
129
127
                                    the.bg.width - the.app.width / 2),
130
128
                    y = math.random(the.app.height / 2,
143
141
                 width = the.app.width,
144
142
                 --align = 'center',
145
143
                 font = 25}
146
 
              --the.interface:add(the.score)
 
144
              the.interface:add(the.score)
147
145
 
148
146
              local hs = the.storage.data.highScore
149
147
              local m = hs / 60
157
155
                 font = 25,
158
156
                 text = string.format('High Score: %d:%02d', m, s)
159
157
              }
160
 
              --the.interface:add(the.highScore)
 
158
              the.interface:add(the.highScore)
161
159
 
162
160
              the.over = Text:new{
163
161
                 y = the.app.height / 2,
221
219
 
222
220
                 the.bullets:collide(the.rockColliders)
223
221
 
224
 
                 -- this should really go somewhere else...
225
 
                 for _, planet in ipairs(the.planets.sprites) do
226
 
                    local indx, indy
227
 
                    local pvec = vector.new(
228
 
                       planet.x - the.player.x + planet.width / 2,
229
 
                       planet.y - the.player.y + planet.height / 2 )
230
 
 
231
 
                    -- TODO: is there a better way to specify the
232
 
                    -- screen rectangle?
233
 
                    if planet:intersects(the.player.x - the.app.width / 2,
234
 
                                         the.player.y - the.app.height / 2,
235
 
                                         the.app.width,
236
 
                                         the.app.height) then
237
 
                       -- planet is on the screen
238
 
                       planet.indicator.visible = false
239
 
                    else
240
 
                       planet.indicator.visible = true
241
 
 
242
 
                       if math.abs(pvec.x) / math.abs(pvec.y) > the.app.width / the.app.height then
243
 
                          indx = (the.app.width / 2 - 10) * util.signOf(pvec.x) + 8
244
 
                          indy = (the.app.width / 2 - 10) * pvec.y / math.abs(pvec.x)
245
 
                       else
246
 
                          indy = (the.app.height / 2 - 10) * util.signOf(pvec.y) + 8
247
 
                          indx = (the.app.height / 2 - 10) * pvec.x / math.abs(pvec.y)
248
 
                       end
249
 
 
250
 
                       planet.indicator.x = the.player.x + indx
251
 
                       planet.indicator.y = the.player.y + indy
252
 
                    end
253
 
                 end
254
 
 
255
222
                 -- for _, mirror in ipairs(the.mirrors.sprites) do
256
223
                 --    if not mirror.of then
257
224
                 --       print('mirror:' .. inspect(mirror))
307
274
 
308
275
              self.view = GameView:new()
309
276
 
 
277
              -- should fail silently if it can't go to fullscreen...
 
278
              love.graphics.toggleFullscreen()
 
279
 
310
280
              if DEBUG then
311
281
                 self.console:watch('VERSION', 'VERSION')
312
282
                 self.console:watch('updateTook', 'the.updateTook')
349
319
               end
350
320
            end
351
321
}
352
 
 
353
 
realRun = love.run
354
 
function love.run()
355
 
   -- should fail silently if it can't go to fullscreen...
356
 
   love.graphics.toggleFullscreen()
357
 
 
358
 
   realRun()
359
 
end
 
 
b'\\ No newline at end of file'