/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-05-16 02:22:30 UTC
  • Revision ID: josh@9ix.org-20130516022230-9mqgevjra6wmt3vf
keep score, center mouse on start

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'
6
5
vector = require 'vector'
7
6
 
8
7
require 'group'
15
14
require 'cursor'
16
15
require 'bullet'
17
16
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
 
86
91
              the.bg = Tile:new{
87
92
                 image = 'data/stars3.png',
88
93
                 -- 1366x768 * 3
97
102
 
98
103
              --self:add(Enemy:new{x=400, y=300})
99
104
 
 
105
              self:add(the.bullets)
 
106
              self:add(the.rockColliders)
 
107
              self:add(the.mirrors)
 
108
              self:add(the.rocks)
 
109
 
100
110
              the.cursor = Cursor:new()
101
111
              self:add(the.cursor)
102
112
 
 
113
              the.score = Text:new{
 
114
                 width = the.app.width,
 
115
                 align = 'center',
 
116
                 font = 25}
 
117
              self:add(the.score)
 
118
 
103
119
              love.mouse.setGrab(true)
104
120
              love.mouse.setVisible(false)
 
121
              love.mouse.setPosition(the.app.width / 2, the.app.height / 2)
105
122
 
106
123
              --self:loadLayers('data/map.lua')
107
124
              self.focus = the.player
133
150
                        end
134
151
                    end
135
152
 
136
 
                    self:add(unseenRock)
 
153
                    the.rocks:add(unseenRock)
137
154
 
138
155
                    self.lastRock = love.timer.getTime()
139
156
                 end
 
157
 
 
158
                 the.bullets:collide(the.rockColliders)
140
159
              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,
141
171
   draw = function (self, x, y)
142
172
             View.draw(self, x, y)
143
173
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)