/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,
192
189
              self.gameStart = love.timer.getTime()
193
190
           end,
194
191
   onUpdate = function(self, dt)
195
 
                 the.bullets:collide(the.planets)
196
 
 
197
 
                 -- this should really go somewhere else...
198
 
                 for _, planet in ipairs(the.planets.sprites) do
 
192
                 if false and the.player.active and love.timer.getTime() > self.lastRock + self.rockInterval then
 
193
                    local unseenRock = nil
 
194
                    while not unseenRock do
 
195
                       local rock = Rock:new{
 
196
                          x = math.random(the.app.width / 2,
 
197
                                          the.bg.width - the.app.width / 2),
 
198
                          y = math.random(the.app.height / 2,
 
199
                                          the.bg.height - the.app.height / 2),
 
200
                          velocity = {
 
201
                             x = math.random(-300, 300),
 
202
                             y = math.random(-300, 300),
 
203
                             rotation = math.random(-7, 7)
 
204
                          },
 
205
                          scale = math.random() + 0.5
 
206
                       }
 
207
 
 
208
                       local rockToPlayer = util.shortestVector(rock, the.player)
 
209
                       if math.abs(rockToPlayer.x) > the.app.width / 2 + rock.width * rock.scale and
 
210
                           math.abs(rockToPlayer.y) > the.app.height / 2 + rock.height * rock.scale then
 
211
                         unseenRock = rock
 
212
                        end
 
213
                    end
 
214
 
 
215
                    the.rocks:add(unseenRock)
 
216
 
 
217
                    self.lastRock = love.timer.getTime()
199
218
                 end
200
219
 
 
220
                 the.bullets:collide(the.rockColliders)
 
221
 
201
222
                 -- for _, mirror in ipairs(the.mirrors.sprites) do
202
223
                 --    if not mirror.of then
203
224
                 --       print('mirror:' .. inspect(mirror))
253
274
 
254
275
              self.view = GameView:new()
255
276
 
 
277
              -- should fail silently if it can't go to fullscreen...
 
278
              love.graphics.toggleFullscreen()
 
279
 
256
280
              if DEBUG then
257
281
                 self.console:watch('VERSION', 'VERSION')
258
282
                 self.console:watch('updateTook', 'the.updateTook')
295
319
               end
296
320
            end
297
321
}
298
 
 
299
 
realRun = love.run
300
 
function love.run()
301
 
   -- should fail silently if it can't go to fullscreen...
302
 
   love.graphics.toggleFullscreen()
303
 
 
304
 
   realRun()
305
 
end
 
 
b'\\ No newline at end of file'