/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-13 20:26:30 UTC
  • Revision ID: josh@9ix.org-20130513202630-jd3tf1rr5zp3gbcm
move player around looping world

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