/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 20:41:14 UTC
  • Revision ID: josh@9ix.org-20130513204114-wtg735gs4b38wad4
extract wrapping behavior, wrap bullets

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
--__ = require 'underscore'
6
6
vector = require 'vector'
7
7
 
8
 
require 'group'
9
 
 
10
8
require 'version'
11
9
require 'wrap_tile'
12
10
require 'player'
13
11
require 'enemy'
14
12
require 'cursor'
15
13
require 'bullet'
16
 
require 'rock'
17
14
 
18
15
util = {
19
16
   signOf = function(value)
26
23
}
27
24
 
28
25
GameView = View:extend {
29
 
   lastRock = 0,
30
 
   rockInterval = 1,
31
 
   gameStart = 0,
32
26
   onNew = function (self)
33
27
              -- for x = 1,30 do
34
28
              --    for y = 1,30 do
62
56
              --self:loadLayers('data/map.lua')
63
57
              self.focus = the.player
64
58
              --self:clampTo(self.map)
65
 
 
66
 
              self.gameStart = love.timer.getTime()
67
59
           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
60
   draw = function (self, x, y)
86
61
             View.draw(self, x, y)
87
62
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
105
80
the.app = App:new {
106
81
   onRun = function (self)
107
82
              print('Version: ' .. VERSION)
108
 
 
109
 
              math.randomseed(os.time())
110
 
 
111
83
              self.view = GameView:new()
112
84
              if DEBUG then
113
85
                 self.console:watch('VERSION', 'VERSION')
117
89
                 self.console:watch('the.app.width', 'the.app.width')
118
90
                 self.console:watch('the.app.height', 'the.app.height')
119
91
                 --self.console:watch('drawTook', 'the.drawTook')
120
 
 
121
 
                 -- back off that dark overlay a bit
122
 
                 self.console.fill.fill[4] = 75
123
92
              end
124
93
           end,
125
94
   onUpdate = function (self, dt)