11
11
low = 5000, med = 6000, high = 8000,
23
15
onNew = function (self)
24
16
self.indicator = Tile:new{ image = 'data/planet1ind.png' }
25
17
the.indicators:add(self.indicator)
27
while not self.name do
28
local name = self.potentialNames[math.random(#self.potentialNames)]
30
for _, planet in ipairs(the.planets.sprites) do
31
if name == planet.name then inUse = true end
39
19
while #self.goods == 0 do
40
20
for _, good in ipairs(self.potentialGoods) do
41
21
if math.random() < good.chance then
59
39
the.player.y - (self.y + hw))
61
41
if pvec:len2() < hw ^ 2 then
62
the.player.velocity = {x=0, y=0}
63
the.player.acceleration = {x=0, y=0}
66
the.storage.data.player = {x = the.player.x,
68
money = the.player.money,
69
goods = the.player.goods,
70
cargoSpace = the.player.cargoSpace
74
42
tradeView = TradeView:new{ planet = self }
75
43
tradeView:activate()
79
onEndFrame = function (self)
81
local pvec = vector.new(
82
self.x - the.player.x + self.width / 2,
83
self.y - the.player.y + self.height / 2 )
85
-- TODO: is there a better way to specify the
87
if self:intersects(the.player.x - the.app.width / 2,
88
the.player.y - the.app.height / 2,
91
-- planet is on the screen
92
self.indicator.visible = false
94
self.indicator.visible = true
96
if math.abs(pvec.x) / math.abs(pvec.y) > the.app.width / the.app.height then
97
indx = (the.app.width / 2 - 10) * util.signOf(pvec.x) + 8
98
indy = (the.app.width / 2 - 10) * pvec.y / math.abs(pvec.x)
100
indy = (the.app.height / 2 - 10) * util.signOf(pvec.y) + 8
101
indx = (the.app.height / 2 - 10) * pvec.x / math.abs(pvec.y)
104
self.indicator.x = the.player.x + indx
105
self.indicator.y = the.player.y + indy
109
onCollide = function (self, other)
110
if other:instanceOf(Bullet) then
111
the.bullets:remove(other)
b'\\ No newline at end of file'