Commit 3916c2e0 by anshve

Upload New File

parent fb6b7dce
Showing with 52 additions and 0 deletions
VictoryState = Class{__includes = BaseState}
function VictoryState:enter(params)
paddle1 = params.paddle1
paddle2 = params.paddle2
self.background = params.background
self.winner = params.winner
end
function VictoryState:update(dt)
if love.keyboard.wasPressed('enter') or love.keyboard.wasPressed('return') then
gStateMachine:change('menu', {})
end
end
function VictoryState:render()
if self.background == 0 then
love.graphics.clear(40 / 255, 45 / 255, 52 / 255, 1)
else
local backgroundName = 'background-' .. self.background
local backgroundWidth = gTextures[backgroundName]:getWidth()
local backgroundHeight = gTextures[backgroundName]:getHeight()
love.graphics.draw(gTextures[backgroundName], 0, 0, 0, VIRTUAL_WIDTH / (backgroundWidth - 1), VIRTUAL_HEIGHT / (backgroundHeight - 1))
end
love.graphics.setFont(gFonts['large'])
self:drawTextWithShadow(paddle1:getScore(), -100, 200)
self:drawTextWithShadow(paddle2:getScore(), 100, 200)
love.graphics.setFont(gFonts['medium'])
self:drawTextWithShadow("Player " .. tostring(self.winner) .. " wins!", 0, 20)
self:drawTextWithShadow("Press Enter to return to the main menu!", 0, 50)
love.graphics.setFont(gFonts['small'])
paddle1:render()
paddle2:render()
end
function VictoryState:drawTextWithShadow(text, x, y)
love.graphics.setColor(34/255, 32/255, 52/255, 255/255)
love.graphics.printf(text, x + 2, y + 1, VIRTUAL_WIDTH, 'center')
love.graphics.printf(text, x + 1, y + 1, VIRTUAL_WIDTH, 'center')
love.graphics.printf(text, x + 0, y + 1, VIRTUAL_WIDTH, 'center')
love.graphics.printf(text, x + 1, y + 2, VIRTUAL_WIDTH, 'center')
love.graphics.setColor(1, 1, 1, 1)
love.graphics.printf(text, x, y, VIRTUAL_WIDTH, 'center')
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment