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