/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-07-04 18:15:15 UTC
  • Revision ID: josh@9ix.org-20130704181515-pmp44y2vv3vw170x
reset kill counter on reward

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'
23
26
 
24
27
util = {
25
28
   signOf = function(value)
43
46
              the.bullets = Group:new()
44
47
              the.interface = Group:new()
45
48
              the.planets = Group:new()
 
49
              the.planetLabels = Group:new()
46
50
              the.indicators = Group:new()
47
51
              the.enemies = Group:new()
48
52
 
58
62
                 the.storage.data = {planets = {}}
59
63
 
60
64
                 -- build planets from random
61
 
                 for _ = 1, math.random(3, 6) do
 
65
                 for _ = 1, math.random(5, 7) do
62
66
                    local planet = Planet:new{
63
67
                       x = math.random(the.app.width / 2,
64
68
                                       the.bg.width - the.app.width / 2),
71
75
                                    x = planet.x,
72
76
                                    y = planet.y,
73
77
                                    rotation = planet.rotation,
74
 
                                    goods = planet.goods
 
78
                                    goods = planet.goods,
 
79
                                    name = planet.name
75
80
                                 })
76
81
                 end
77
82
 
 
83
                 Good:stockPlanets()
 
84
 
78
85
                 -- build fresh player
79
86
                 local player = SpacePlayer:new{x=the.bg.width / 2, y=the.bg.height / 2}
80
87
                 the.player = player
94
101
 
95
102
                 -- load player with cargo, money, position
96
103
                 the.player = SpacePlayer:new(the.storage.data.player)
 
104
 
 
105
                 -- reload storage as we've turned it all into objects
 
106
                 the.storage:load()
97
107
              end
98
108
 
99
109
              self:add(the.planets)
 
110
              self:add(the.planetLabels)
100
111
 
101
112
              self:add(the.player)
102
113
              self:add(the.player.thrust)
120
131
              the.cursor = Cursor:new()
121
132
              self:add(the.cursor)
122
133
 
123
 
              the.over = Text:new{
124
 
                 y = the.app.height / 2,
125
 
                 width = the.app.width,
126
 
                 align = 'center',
127
 
                 font = 25,
128
 
                 text = "Game Over",
129
 
                 visible = false
130
 
              }
131
 
              the.interface:add(the.over)
132
 
 
133
 
 
134
 
              the.instructions = Text:new{
135
 
                 y = the.app.height / 2 + 32,
136
 
                 width = the.app.width,
137
 
                 align = 'center',
138
 
                 font = 12,
139
 
                 text = "Press Enter to start a new game\nPress Q to quit",
140
 
                 visible = false
141
 
              }
142
 
              the.interface:add(the.instructions)
143
 
 
144
134
              love.mouse.setGrab(true)
145
135
              love.mouse.setVisible(false)
146
136
              love.mouse.setPosition(the.app.width / 2, the.app.height / 2)
181
171
}
182
172
 
183
173
the.app = App:new {
 
174
   name = 'Traderous',
184
175
   onRun = function (self)
185
176
              print('Version: ' .. VERSION)
186
177
 
199
190
                 self.console:watch('num rocks', '#the.rocks.sprites')
200
191
                 self.console:watch('num planets', '#the.planets.sprites')
201
192
                 self.console:watch('num enemies', 'the.enemies:count()')
 
193
                 self.console:watch('onPlanet', 'the.player.onPlanet')
 
194
                 self.console:watch('kills', 'the.player.kills')
202
195
                 --self.console:watch('drawTook', 'the.drawTook')
203
196
 
204
197
                 -- back off that dark overlay a bit