/traderous

To get this branch, use:
bzr branch /bzr/traderous

« back to all changes in this revision

Viewing changes to main.lua

  • Committer: Josh C
  • Date: 2013-05-13 22:25:16 UTC
  • Revision ID: josh@9ix.org-20130513222516-wem0v29pit3ivc6w
rocks!

Show diffs side-by-side

added added

removed removed

13
13
require 'enemy'
14
14
require 'cursor'
15
15
require 'bullet'
 
16
require 'rock'
16
17
 
17
18
util = {
18
19
   signOf = function(value)
25
26
}
26
27
 
27
28
GameView = View:extend {
 
29
   lastRock = 0,
 
30
   rockInterval = 1,
 
31
   gameStart = 0,
28
32
   onNew = function (self)
29
33
              -- for x = 1,30 do
30
34
              --    for y = 1,30 do
58
62
              --self:loadLayers('data/map.lua')
59
63
              self.focus = the.player
60
64
              --self:clampTo(self.map)
 
65
 
 
66
              self.gameStart = love.timer.getTime()
61
67
           end,
 
68
   onUpdate = function(self, dt)
 
69
                 if love.timer.getTime() > self.lastRock + self.rockInterval then
 
70
                    local rock = Rock:new{
 
71
                       x = math.random(the.bg.width),
 
72
                       y = math.random(the.bg.height),
 
73
                       velocity = {
 
74
                          x = math.random(-300, 300),
 
75
                          y = math.random(-300, 300),
 
76
                          rotation = math.random(-7, 7)
 
77
                       },
 
78
                       scale = math.random() + 0.5
 
79
                    }
 
80
                    self:add(rock)
 
81
 
 
82
                    self.lastRock = love.timer.getTime()
 
83
                 end
 
84
              end,
62
85
   draw = function (self, x, y)
63
86
             View.draw(self, x, y)
64
87
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
82
105
the.app = App:new {
83
106
   onRun = function (self)
84
107
              print('Version: ' .. VERSION)
 
108
 
 
109
              math.randomseed(os.time())
 
110
 
85
111
              self.view = GameView:new()
86
112
              if DEBUG then
87
113
                 self.console:watch('VERSION', 'VERSION')