Create a vector version of the win image, and get rid of the terrible programmer art

This commit is contained in:
Juhani Krekelä 2019-06-30 21:03:55 +03:00
parent 0e59001d03
commit 361961ab9e
2 changed files with 53 additions and 11 deletions

View File

@ -47,6 +47,7 @@ direction_keys['space'] = directions.inplace
local control_keys = {quit = 'q', restart = 'r', configure = 'c', autoexplore = 'a'}
local win_image = nil
local win_is_raster = false
-- ------------------------------------------------------------------
-- Cavern generation
@ -971,25 +972,64 @@ function drawHP()
local x = (i - 1) * scale + x_offset
local y = y_offset
love.graphics.setColor(1, 1, 1)
love.graphics.draw(heart_sprite, x, y, 0, scale/16, scale/16)
end
end
function drawWin()
local img_width, img_height = win_image:getDimensions()
if win_is_raster then
local img_width, img_height = win_image:getDimensions()
local screen_width = love.graphics.getWidth()
local screen_height = love.graphics.getHeight()
local screen_width = love.graphics.getWidth()
local screen_height = love.graphics.getHeight()
local width_scale = screen_width / img_width
local height_scale = screen_height / img_height
local scale = math.min(width_scale, height_scale)
local width_scale = screen_width / img_width
local height_scale = screen_height / img_height
local scale = math.min(width_scale, height_scale)
local x_offset = (screen_width - img_width * scale) / 2
local y_offset = (screen_height - img_height * scale) / 2
local x_offset = (screen_width - img_width * scale) / 2
local y_offset = (screen_height - img_height * scale) / 2
love.graphics.setColor(1, 1, 1)
love.graphics.draw(win_image, x_offset, y_offset, 0, scale, scale)
love.graphics.setColor(1, 1, 1)
love.graphics.draw(win_image, x_offset, y_offset, 0, scale, scale)
else
local width = 20
local height = 20
local screen_width = love.graphics.getWidth()
local screen_height = love.graphics.getHeight()
local width_scale = screen_width / width
local height_scale = screen_height / height
local scale = math.min(width_scale, height_scale)
local x_offset = (screen_width - width * scale) / 2
local y_offset = (screen_height - height * scale) / 2
local vertices = {10, 7, 6, 8, 5, 20, 15, 20, 14, 8}
local transformed_vertices = {}
for i = 1, #vertices, 2 do
local x = vertices[i] * scale + x_offset
local y = vertices[i + 1] * scale + y_offset
transformed_vertices[i] = x
transformed_vertices[i + 1] = y
end
love.graphics.setColor(0, 0, 1)
love.graphics.polygon('fill', transformed_vertices)
love.graphics.setColor(0.6, 0.3, 0.2)
love.graphics.circle('fill', 10 * scale + x_offset, 5 * scale + y_offset, 3 * scale)
love.graphics.setColor(0.5, 0.2, 0.1)
love.graphics.rectangle('fill', x_offset, 15 * scale + y_offset, 20 * scale, 10 * scale)
love.graphics.setColor(0, 1, 0)
love.graphics.circle('fill', 10 * scale + x_offset, 16 * scale + y_offset, 2 * scale)
end
end
function drawLoss()
@ -1077,7 +1117,9 @@ function love.load()
newGame()
win_image = love.graphics.newImage("win_image.png")
if win_is_raster then
win_image = love.graphics.newImage("win_image.png")
end
player_sprite = love.graphics.newImage("sprite.png")
player_sprite_crit = love.graphics.newImage("sprite_crit.png")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 0 B