Start on the Orb (atm behaves like a wall)

This commit is contained in:
Juhani Krekelä 2019-06-29 11:45:13 +03:00
parent e7207f2d46
commit e79fdc5c9b
1 changed files with 33 additions and 3 deletions

View File

@ -1,5 +1,5 @@
local cavern = {}
local tiletypes = {unknown = 0, empty = 1, wall = 2}
local tiletypes = {unknown = 0, empty = 1, wall = 2, orb = 3}
local visibility_map = {}
local remembered_cavern = {}
@ -140,6 +140,18 @@ function spawnPlayer()
end
end
function spawnOrb()
local orb_x = nil
local orb_y = nil
repeat
orb_x = math.random(2, cavern.width - 1)
orb_y = math.random(2, cavern.height - 1)
until cavern[orb_x][orb_y] == tiletypes.empty
cavern[orb_x][orb_y] = tiletypes.orb
end
-- ------------------------------------------------------------------
-- Visibility
-- ------------------------------------------------------------------
@ -518,7 +530,10 @@ end
-- ------------------------------------------------------------------
function newGame()
generateCavern()
spawnPlayer()
spawnOrb()
generateVisibilityMap()
initializeRememberedCavern()
end
@ -603,23 +618,38 @@ function love.draw()
if tile == tiletypes.empty then
love.graphics.setColor(0, 0, 0)
love.graphics.rectangle('fill', x, y, x_scale, y_scale)
elseif tile == tiletypes.wall then
love.graphics.setColor(1, 1, 1)
love.graphics.rectangle('fill', x, y, x_scale, y_scale)
elseif tile == tiletypes.orb then
love.graphics.setColor(0.5, 0.3, 0.3)
love.graphics.rectangle('fill', x, y, x_scale, y_scale)
love.graphics.setColor(0, 1, 0)
love.graphics.ellipse('fill', x + 0.5 * x_scale, y + 0.5 * y_scale, 0.7 * x_scale/2, 0.7 * y_scale/2)
else
love.graphics.setColor(1, 0.5, 0.5)
love.graphics.rectangle('fill', x, y, x_scale, y_scale)
end
else
tile = remembered_cavern[tile_x][tile_y]
if tile == tiletypes.empty then
love.graphics.setColor(0.2, 0.2, 0.2)
love.graphics.rectangle('fill', x, y, x_scale, y_scale)
elseif tile == tiletypes.wall then
love.graphics.setColor(0.9, 0.9, 0.9)
love.graphics.rectangle('fill', x, y, x_scale, y_scale)
elseif tile == tiletypes.orb then
love.graphics.setColor(0.4, 0.4, 0.4)
love.graphics.rectangle('fill', x, y, x_scale, y_scale)
love.graphics.setColor(0.2, 0.7, 0.2)
love.graphics.ellipse('fill', x + 0.5 * x_scale, y + 0.5 * y_scale, 0.7 * x_scale/2, 0.7 * y_scale/2)
else
love.graphics.setColor(0.5, 0.5, 0.5)
love.graphics.rectangle('fill', x, y, x_scale, y_scale)
end
end
love.graphics.rectangle('fill', x, y, x_scale, y_scale)
end
end