/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:55:40 UTC
  • Revision ID: josh@9ix.org-20130625195540-f4nwz7ffj9f6658a
patch zoetrope storage so it can save lists (arrays indexed by number)

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
101
94
 
102
95
                 -- load player with cargo, money, position
103
96
                 the.player = SpacePlayer:new(the.storage.data.player)
104
 
 
105
 
                 -- reload storage as we've turned it all into objects
106
 
                 the.storage:load()
107
97
              end
108
98
 
109
99
              self:add(the.planets)
110
 
              self:add(the.planetLabels)
111
100
 
112
101
              self:add(the.player)
113
102
              self:add(the.player.thrust)
131
120
              the.cursor = Cursor:new()
132
121
              self:add(the.cursor)
133
122
 
 
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
 
134
144
              love.mouse.setGrab(true)
135
145
              love.mouse.setVisible(false)
136
146
              love.mouse.setPosition(the.app.width / 2, the.app.height / 2)
189
199
                 self.console:watch('num rocks', '#the.rocks.sprites')
190
200
                 self.console:watch('num planets', '#the.planets.sprites')
191
201
                 self.console:watch('num enemies', 'the.enemies:count()')
192
 
                 self.console:watch('onPlanet', 'the.player.onPlanet')
193
202
                 --self.console:watch('drawTook', 'the.drawTook')
194
203
 
195
204
                 -- back off that dark overlay a bit