/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-06-25 19:56:26 UTC
  • Revision ID: josh@9ix.org-20130625195626-00x63mxdyk1k6ud7
last fix for saving

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
require 'trade_view'
21
21
require 'shield'
22
22
require 'pause_view'
23
 
require 'game_over'
24
 
require 'names'
25
 
require 'good'
26
23
 
27
24
util = {
28
25
   signOf = function(value)
46
43
              the.bullets = Group:new()
47
44
              the.interface = Group:new()
48
45
              the.planets = Group:new()
49
 
              the.planetLabels = Group:new()
50
46
              the.indicators = Group:new()
51
47
              the.enemies = Group:new()
52
48
 
62
58
                 the.storage.data = {planets = {}}
63
59
 
64
60
                 -- build planets from random
65
 
                 for _ = 1, math.random(5, 7) do
 
61
                 for _ = 1, math.random(3, 6) do
66
62
                    local planet = Planet:new{
67
63
                       x = math.random(the.app.width / 2,
68
64
                                       the.bg.width - the.app.width / 2),
75
71
                                    x = planet.x,
76
72
                                    y = planet.y,
77
73
                                    rotation = planet.rotation,
78
 
                                    goods = planet.goods,
79
 
                                    name = planet.name
 
74
                                    goods = planet.goods
80
75
                                 })
81
76
                 end
82
77
 
83
 
                 Good:stockPlanets()
84
 
 
85
78
                 -- build fresh player
86
79
                 local player = SpacePlayer:new{x=the.bg.width / 2, y=the.bg.height / 2}
87
80
                 the.player = player
107
100
              end
108
101
 
109
102
              self:add(the.planets)
110
 
              self:add(the.planetLabels)
111
103
 
112
104
              self:add(the.player)
113
105
              self:add(the.player.thrust)
131
123
              the.cursor = Cursor:new()
132
124
              self:add(the.cursor)
133
125
 
 
126
              the.over = Text:new{
 
127
                 y = the.app.height / 2,
 
128
                 width = the.app.width,
 
129
                 align = 'center',
 
130
                 font = 25,
 
131
                 text = "Game Over",
 
132
                 visible = false
 
133
              }
 
134
              the.interface:add(the.over)
 
135
 
 
136
 
 
137
              the.instructions = Text:new{
 
138
                 y = the.app.height / 2 + 32,
 
139
                 width = the.app.width,
 
140
                 align = 'center',
 
141
                 font = 12,
 
142
                 text = "Press Enter to start a new game\nPress Q to quit",
 
143
                 visible = false
 
144
              }
 
145
              the.interface:add(the.instructions)
 
146
 
134
147
              love.mouse.setGrab(true)
135
148
              love.mouse.setVisible(false)
136
149
              love.mouse.setPosition(the.app.width / 2, the.app.height / 2)
189
202
                 self.console:watch('num rocks', '#the.rocks.sprites')
190
203
                 self.console:watch('num planets', '#the.planets.sprites')
191
204
                 self.console:watch('num enemies', 'the.enemies:count()')
192
 
                 self.console:watch('onPlanet', 'the.player.onPlanet')
193
 
                 self.console:watch('kills', 'the.player.kills')
194
205
                 --self.console:watch('drawTook', 'the.drawTook')
195
206
 
196
207
                 -- back off that dark overlay a bit