/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-12 17:37:55 UTC
  • Revision ID: josh@9ix.org-20130512173755-cpc9gqzglyurezzb
starry background

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
39
32
              --    end
40
33
              -- end
41
34
 
42
 
              the.bg = Tile:new{
43
 
                 image = 'data/stars3.png',
44
 
                 -- 1366x768 * 3
45
 
                 width = 4098,
46
 
                 height = 2304
 
35
              local bg = Tile:new{
 
36
                 image = 'data/stars2.png',
 
37
                 width = 102400,
 
38
                 height = 76800,
 
39
                 x = -51200,
 
40
                 y = -38400
47
41
              }
48
 
              self:add(the.bg)
 
42
              self:add(bg)
49
43
 
50
44
              --the.player = CrystalPlayer:new{x=400,y=300}
51
 
              the.player = SpacePlayer:new{x=1366,y=768}
 
45
              the.player = SpacePlayer:new{x=400,y=300}
52
46
              self:add(the.player)
53
47
 
54
48
              self:add(Enemy:new{x=400, y=300})
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')
114
86
                 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')
119
87
                 --self.console:watch('drawTook', 'the.drawTook')
120
 
 
121
 
                 -- back off that dark overlay a bit
122
 
                 self.console.fill.fill[4] = 75
123
88
              end
124
89
           end,
125
90
   onUpdate = function (self, dt)