/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-14 00:15:01 UTC
  • Revision ID: josh@9ix.org-20130514001501-z14e702ncp21s0yr
try to not spawn rocks where you can see them.  not working if screen 
crosses game boundaries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
DEBUG = true
3
3
 
4
4
require 'zoetrope'
 
5
--__ = require 'underscore'
5
6
vector = require 'vector'
6
7
 
7
8
require 'group'
14
15
require 'cursor'
15
16
require 'bullet'
16
17
require 'rock'
17
 
require 'boom'
18
18
 
19
19
util = {
20
20
   signOf = function(value)
83
83
              --    end
84
84
              -- end
85
85
 
86
 
              the.rockColliders = Group:new()
87
 
              the.bullets = Group:new()
88
 
              the.mirrors = Group:new()
89
 
              the.rocks = Group:new()
90
 
 
91
86
              the.bg = Tile:new{
92
87
                 image = 'data/stars3.png',
93
88
                 -- 1366x768 * 3
102
97
 
103
98
              --self:add(Enemy:new{x=400, y=300})
104
99
 
105
 
              self:add(the.bullets)
106
 
              self:add(the.rockColliders)
107
 
              self:add(the.mirrors)
108
 
              self:add(the.rocks)
109
 
 
110
100
              the.cursor = Cursor:new()
111
101
              self:add(the.cursor)
112
102
 
113
 
              the.score = Text:new{
114
 
                 width = the.app.width,
115
 
                 align = 'center',
116
 
                 font = 25}
117
 
              self:add(the.score)
118
 
 
119
103
              love.mouse.setGrab(true)
120
104
              love.mouse.setVisible(false)
121
 
              love.mouse.setPosition(the.app.width / 2, the.app.height / 2)
122
105
 
123
106
              --self:loadLayers('data/map.lua')
124
107
              self.focus = the.player
150
133
                        end
151
134
                    end
152
135
 
153
 
                    the.rocks:add(unseenRock)
 
136
                    self:add(unseenRock)
154
137
 
155
138
                    self.lastRock = love.timer.getTime()
156
139
                 end
157
 
 
158
 
                 the.bullets:collide(the.rockColliders)
159
140
              end,
160
 
   onEndFrame = function(self)
161
 
                   if the.player.active then
162
 
                      local t = love.timer.getTime() - self.gameStart
163
 
                      local m = t / 60
164
 
                      local s = t % 60
165
 
 
166
 
                      the.score.text = string.format('Score: %d:%02d', m, s)
167
 
                      the.score.y = the.player.y - the.app.height / 2 + the.player.height
168
 
                      the.score.x = the.player.x - the.app.width / 2
169
 
                   end
170
 
                end,
171
141
   draw = function (self, x, y)
172
142
             View.draw(self, x, y)
173
143
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)