/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 22:25:16 UTC
  • Revision ID: josh@9ix.org-20130513222516-wem0v29pit3ivc6w
rocks!

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
 
8
10
require 'version'
 
11
require 'wrap_tile'
9
12
require 'player'
10
13
require 'enemy'
11
14
require 'cursor'
12
15
require 'bullet'
 
16
require 'rock'
13
17
 
14
18
util = {
15
19
   signOf = function(value)
22
26
}
23
27
 
24
28
GameView = View:extend {
 
29
   lastRock = 0,
 
30
   rockInterval = 1,
 
31
   gameStart = 0,
25
32
   onNew = function (self)
26
33
              -- for x = 1,30 do
27
34
              --    for y = 1,30 do
32
39
              --    end
33
40
              -- end
34
41
 
35
 
              local bg = Tile:new{
36
 
                 image = 'data/stars2.png',
37
 
                 width = 102400,
38
 
                 height = 76800,
39
 
                 x = -51200,
40
 
                 y = -38400
 
42
              the.bg = Tile:new{
 
43
                 image = 'data/stars3.png',
 
44
                 -- 1366x768 * 3
 
45
                 width = 4098,
 
46
                 height = 2304
41
47
              }
42
 
              self:add(bg)
 
48
              self:add(the.bg)
43
49
 
44
50
              --the.player = CrystalPlayer:new{x=400,y=300}
45
 
              the.player = SpacePlayer:new{x=400,y=300}
 
51
              the.player = SpacePlayer:new{x=1366,y=768}
46
52
              self:add(the.player)
47
53
 
48
54
              self:add(Enemy:new{x=400, y=300})
56
62
              --self:loadLayers('data/map.lua')
57
63
              self.focus = the.player
58
64
              --self:clampTo(self.map)
 
65
 
 
66
              self.gameStart = love.timer.getTime()
59
67
           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,
60
85
   draw = function (self, x, y)
61
86
             View.draw(self, x, y)
62
87
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
80
105
the.app = App:new {
81
106
   onRun = function (self)
82
107
              print('Version: ' .. VERSION)
 
108
 
 
109
              math.randomseed(os.time())
 
110
 
83
111
              self.view = GameView:new()
84
112
              if DEBUG then
85
113
                 self.console:watch('VERSION', 'VERSION')
86
114
                 self.console:watch('updateTook', 'the.updateTook')
 
115
                 self.console:watch('the.player.x', 'the.player.x')
 
116
                 self.console:watch('the.player.y', 'the.player.y')
 
117
                 self.console:watch('the.app.width', 'the.app.width')
 
118
                 self.console:watch('the.app.height', 'the.app.height')
87
119
                 --self.console:watch('drawTook', 'the.drawTook')
 
120
 
 
121
                 -- back off that dark overlay a bit
 
122
                 self.console.fill.fill[4] = 75
88
123
              end
89
124
           end,
90
125
   onUpdate = function (self, dt)