/spacey

To get this branch, use:
bzr branch http://9ix.org/bzr/spacey

« back to all changes in this revision

Viewing changes to main.lua

  • Committer: Josh C
  • Date: 2013-05-13 21:40:14 UTC
  • Revision ID: josh@9ix.org-20130513214014-cpvr4zqooyl6nxf3
don't fire from top-left corner of the ship.  ...  fire from center of 
ship for now.  :)

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
require 'enemy'
14
14
require 'cursor'
15
15
require 'bullet'
16
 
require 'rock'
17
16
 
18
17
util = {
19
18
   signOf = function(value)
26
25
}
27
26
 
28
27
GameView = View:extend {
29
 
   lastRock = 0,
30
 
   rockInterval = 1,
31
 
   gameStart = 0,
32
28
   onNew = function (self)
33
29
              -- for x = 1,30 do
34
30
              --    for y = 1,30 do
62
58
              --self:loadLayers('data/map.lua')
63
59
              self.focus = the.player
64
60
              --self:clampTo(self.map)
65
 
 
66
 
              self.gameStart = love.timer.getTime()
67
61
           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,
85
62
   draw = function (self, x, y)
86
63
             View.draw(self, x, y)
87
64
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
105
82
the.app = App:new {
106
83
   onRun = function (self)
107
84
              print('Version: ' .. VERSION)
108
 
 
109
 
              math.randomseed(os.time())
110
 
 
111
85
              self.view = GameView:new()
112
86
              if DEBUG then
113
87
                 self.console:watch('VERSION', 'VERSION')