-
Notifications
You must be signed in to change notification settings - Fork 0
/
galaxy.lua
57 lines (33 loc) · 1.01 KB
/
galaxy.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
local Planets = require "planets"
M = {}
M.__index = M
function M.new(galaxyType, layerNum)
local self = setmetatable({
galaxyType = galaxyType or "random",
numPlanets = love.math.random(2, 5),
planets = {},
visited = false,
layerNum = layerNum
}, M)
for i=1, self.numPlanets do
self.planets[i] = Planets.new(self.galaxyType)
end
self.name = randomName(love.math.random(1, 26))
self.src = randomImg(love.math.random(1, 16))
self.desc = randomDesc(love.math.random(1, 25), layerNum)
return self
end
function randomName(seed)
return galaxyNames[seed]
end
function randomImg(seed)
local posY = math.floor(seed / 4)
if seed == 4 then posY = 0 elseif seed == 16 then posY = 3 end
local posX = seed % 4
g = gr.newQuad(192*posX, 192*posY, 192, 192, galaxySheet:getDimensions())
return g
end
function randomDesc(seed, l)
if l <= 15 then return warpNarrative[l] else return "BONUS LEVELS" end
end
return M