Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pong-final rendering white screen #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion pong-final/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ require 'Paddle'
-- but which will mechanically function very differently
require 'Ball'

-- Stores true or false, depending on whether the current Love 2D version is prior to 11.0
local love11 = love.getVersion() == 11

-- In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1.
-- Set Clear Color to #282d34 (40, 45, 52) with an alpha of 100%
--
-- https://love2d.org/wiki/love.graphics.clear
r0to255 = 40
g0to255 = 45
b0to255 = 52
a0to255 = 255
local rBackground = love11 and r0to255/255 or r0to255
local gBackground = love11 and g0to255/255 or g0to255
local bBackground = love11 and b0to255/255 or b0to255
local aBackground = love11 and a0to255/255 or a0to255

-- size of our actual window
WINDOW_WIDTH = 1280
WINDOW_HEIGHT = 720
Expand Down Expand Up @@ -303,7 +319,7 @@ function love.draw()
-- begin drawing with push, in our virtual resolution
push:start()

love.graphics.clear(40, 45, 52, 255)
love.graphics.clear(rBackground, gBackground, bBackground, aBackground)

-- render different things depending on which part of the game we're in
if gameState == 'start' then
Expand Down