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 full screen distortion #2327

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions src/autosave_warning.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ function state:enter()
Timer.add(8, function()
Gamestate.switch('scanning')
end)
local width, height, flags = love.window.getMode()
self.width = width*window.scale
self.height = height*window.scale
end

function state:leave()
Expand All @@ -40,8 +43,8 @@ function state:draw()
local width = self.background:getWidth()
local height = self.background:getHeight()

local x = (window.width - width)/2
local y = (window.height - height)/2
local x = (self.width - width)/2
local y = (self.height - height)/2

love.graphics.draw(self.background, x, y)
self.savingAnimation:draw(self.savingImage, x + 10, y + 10)
Expand Down
5 changes: 4 additions & 1 deletion src/credits.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ function state:enter(previous)
self.ty = 0
camera:setPosition(0, self.ty)
self.previous = previous
local width, height, flags = love.window.getMode()
self.width = width*window.scale
self.height = height*window.scale
end

function state:leave()
Expand Down Expand Up @@ -378,7 +381,7 @@ function state:draw()
for i = shift - 14, shift + 1 do
local name = self.credits[i]
if name then
love.graphics.printf(name, 0, window.height + 25 * i, window.width, 'center')
love.graphics.printf(name, 0, self.height + 25 * i, self.width, 'center')
end
end
end
Expand Down
Binary file modified src/images/tilesets/baseball.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/images/tilesets/deans-closet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 15 additions & 10 deletions src/instructions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ menu:onSelect(function()
state.statusText = "PRESS NEW KEY" end)

function state:init()
VerticalParticles.init()

self.arrow = love.graphics.newImage("images/menu/arrow.png")
self.background = love.graphics.newImage("images/menu/pause.png")
Expand All @@ -56,12 +55,16 @@ end
function state:enter(previous)
fonts.set( 'big' )
sound.playMusic( "daybreak" )

VerticalParticles.init()

camera:setPosition(0, 0)
self.instructions = controls:getActionmap()
self.previous = previous
self.option = 0
self.statusText = ''
local width, height, flags = love.window.getMode()
self.width = width*window.scale
self.height = height*window.scale
end

function state:leave()
Expand All @@ -82,29 +85,31 @@ function state:draw()
VerticalParticles.draw()

love.graphics.draw(self.background,
camera:getWidth() / 2 - self.background:getWidth() / 2,
camera:getHeight() / 2 - self.background:getHeight() / 2)
(self.width - self.background:getWidth()) / 2,
(self.height - self.background:getHeight()) / 2)

local n = 1

local x = (self.width - window.width)/2
local y = (self.height - window.height)/2

love.graphics.setColor(255, 255, 255)
local back = controls:getKey("START") .. ": BACK TO MENU"
local howto = controls:getKey("ATTACK") .. " OR " .. controls:getKey("JUMP") .. ": REASSIGN CONTROL"

love.graphics.print(back, 25, 25)
love.graphics.print(howto, 25, 55)
love.graphics.print(self.statusText, self.left_column, 280)
love.graphics.print(self.statusText, x + self.left_column, y + 280)
love.graphics.setColor( 0, 0, 0, 255 )

for i, button in ipairs(menu.options) do
local y = self.top + self.spacing * (i - 1)
local z = y + self.top + self.spacing * (i - 1)
local key = controls:getKey(button)
love.graphics.print(descriptions[button], self.left_column, y, 0, 0.5)
love.graphics.print(key, self.right_column, y, 0, 0.5)
love.graphics.print(descriptions[button], x + self.left_column, z, 0, 0.5)
love.graphics.print(key, x + self.right_column, z, 0, 0.5)
end

love.graphics.setColor( 255, 255, 255, 255 )
love.graphics.draw(self.arrow, 135, 87 + self.spacing * menu:selected())
love.graphics.draw(self.arrow, x + 135, y + 87 + self.spacing * menu:selected())
end

function state:remapKey(key)
Expand Down
39 changes: 21 additions & 18 deletions src/level.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,22 @@ local function collision_stop(dt, shape_a, shape_b)
end
end

local function setBackgroundColor(map)
local prop = map.properties
if not prop.red then
love.graphics.setBackgroundColor(0, 0, 0)
return
end
love.graphics.setBackgroundColor(tonumber(prop.red),
tonumber(prop.green),
tonumber(prop.blue))
end

local function getCameraOffset(map)
local prop = map.properties
if not prop.offset then
return 0

local width, height, flags = love.window.getMode( )
if not flags.fullscreen then
if not prop.offset then
return 0
end
return tonumber(prop.offset) * map.tilewidth
else
if not prop.offset or tonumber(prop.offset) < 2 then
return (map.height*map.tileheight - height*window.scale)/2
end
return math.min(tonumber(prop.offset)*map.tileheight + (window.height - height*window.scale)/2,
map.height*map.tileheight - height*window.scale)
end
return tonumber(prop.offset) * map.tilewidth
end

local function getTitle(map)
Expand Down Expand Up @@ -149,7 +148,6 @@ function Level.new(name)
level.map.moving_platforms = {} -- Need to give map access to moving platforms
level.tileset = tmx.load(level.map)
level.collider = HC(100, on_collision, collision_stop)
level.offset = getCameraOffset(level.map)
level.music = getSoundtrack(level.map)
level.spawn = (level.map.properties and level.map.properties.respawn) or 'studyroom'
level.overworldName = (level.map.properties and level.map.properties.overworldName) or 'greendale'
Expand Down Expand Up @@ -371,9 +369,14 @@ function Level:enter(previous, door, position)
self:restartLevel(true)
end

camera.max.x = self.map.width * self.map.tilewidth - window.width

setBackgroundColor(self.map)
local width, height, flags = love.window.getMode( )
if not flags.fullscreen then
camera.max.x = self.map.width * self.map.tilewidth - window.width
else
local widthDif = self.map.width * self.map.tilewidth - width*window.scale
camera.max.x = widthDif > 0 and widthDif or widthDif/2
end
self.offset = getCameraOffset(self.map)

sound.playMusic( self.music )

Expand Down
42 changes: 22 additions & 20 deletions src/maps/admin-hallway.tmx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="48" height="14" tilewidth="24" tileheight="24">
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="48" height="14" tilewidth="24" tileheight="24" nextobjectid="16">
<properties>
<property name="autosave" value="false"/>
<property name="blue" value="159"/>
<property name="green" value="123"/>
<property name="red" value="104"/>
<property name="soundtrack" value="greendale-alt"/>
<property name="title" value="Admin Hallway"/>
</properties>
Expand All @@ -14,6 +11,11 @@
<tileset firstgid="481" name="collisions" tilewidth="24" tileheight="24">
<image source="../images/tilesets/collisions.png" width="632" height="512"/>
</tileset>
<layer name="Tile Layer 0" width="48" height="14">
<data encoding="base64" compression="zlib">
eJztwzENAAAMBKGb3r/kuugECaumqqpPD97OD8E=
</data>
</layer>
<layer name="Tile Layer 1" width="48" height="14">
<data encoding="base64" compression="zlib">
eJxjZGBwYBzCmImBgWGI4wNDGTOMQJA+SM0aBaSDjcBCZBPjwNjdC7S3j0K7TwL1nyLDDGYohgFJIJbCwsYHlgLtXTZAYYfL/dIMhN0vQ4T5QDUNxKhDB7JEqoO5nx2KDYHYCIiNkdjsOLAJHjkkNQ3EqEPHpljE7mIRYx7FgwIzDnEMAH5IPoY=
Expand All @@ -34,66 +36,66 @@
eJxjYBja4CHj0MajYBSMglEwCoYu+M0IwQMFhJgYGASZsMsJMKGqE4BiXOoJmYcOvjEObTwKBhYAAAPfW1Q=
</data>
</layer>
<objectgroup name="nodes" width="48" height="14">
<object name="main" type="door" x="96" y="216" width="24" height="60">
<objectgroup name="nodes">
<object id="1" name="main" type="door" x="96" y="216" width="24" height="60">
<properties>
<property name="level" value="greendale-exterior"/>
<property name="to" value="admin1"/>
</properties>
</object>
<object name="humanbeing" type="npc" x="576" y="216" width="48" height="50"/>
<object type="firealarm" x="480" y="216" width="24" height="48"/>
<object type="firealarm" x="840" y="216" width="24" height="48"/>
<object type="firealarm" x="24" y="216" width="24" height="48"/>
<object type="info" x="360" y="216" width="48" height="48">
<object id="2" name="humanbeing" type="npc" x="576" y="216" width="48" height="50"/>
<object id="3" type="firealarm" x="480" y="216" width="24" height="48"/>
<object id="4" type="firealarm" x="840" y="216" width="24" height="48"/>
<object id="5" type="firealarm" x="24" y="216" width="24" height="48"/>
<object id="6" type="info" x="360" y="216" width="48" height="48">
<properties>
<property name="info" value="The only trophy reads: | Most Valued Customer ... | Henderson Trophy Cases"/>
</properties>
</object>
<object type="info" x="1104" y="216" width="48" height="48">
<object id="7" type="info" x="1104" y="216" width="48" height="48">
<properties>
<property name="info" value="Stairway closed due to black mold"/>
</properties>
</object>
<object type="info" x="216" y="216" width="24" height="48">
<object id="8" type="info" x="216" y="216" width="24" height="48">
<properties>
<property name="info" value="$0.25 per sip. 2 drink minimum."/>
</properties>
</object>
<object type="info" x="169" y="216" width="16" height="48">
<object id="9" type="info" x="169" y="216" width="16" height="48">
<properties>
<property name="info" value="The extinguisher reads ... | WARNING CONTENTS HIGHLY FLAMMABLE"/>
</properties>
</object>
<object type="info" x="1011" y="218" width="41" height="44">
<object id="10" type="info" x="1011" y="218" width="41" height="44">
<properties>
<property name="info" value="Wait a minute... This is just hot soda."/>
</properties>
</object>
<object type="info" x="984" y="216" width="23" height="44">
<object id="11" type="info" x="984" y="216" width="23" height="44">
<properties>
<property name="info" value="This ATM only dispenses ... | Greendale Dollars."/>
</properties>
</object>
<object name="raveSwitch" type="door" x="768" y="216" width="24" height="60">
<object id="12" name="raveSwitch" type="door" x="768" y="216" width="24" height="60">
<properties>
<property name="button" value="INTERACT"/>
<property name="level" value="rave-hallway"/>
<property name="sound" value="alarmswitch"/>
<property name="to" value="raveSwitch"/>
</properties>
</object>
<object type="info" x="313" y="218" width="22" height="44">
<object id="13" type="info" x="313" y="218" width="22" height="44">
<properties>
<property name="info" value="This door is locked."/>
</properties>
</object>
<object type="info" x="529" y="215" width="44" height="47">
<object id="14" type="info" x="529" y="215" width="44" height="47">
<properties>
<property name="info" value="These doors are locked."/>
</properties>
</object>
<object type="info" x="866" y="217" width="22" height="47">
<object id="15" type="info" x="866" y="217" width="22" height="47">
<properties>
<property name="info" value="This door is locked."/>
</properties>
Expand Down
19 changes: 10 additions & 9 deletions src/maps/baseball.tmx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="22" height="14" tilewidth="24" tileheight="24">
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="22" height="14" tilewidth="24" tileheight="24" nextobjectid="4">
<properties>
<property name="autosave" value="false"/>
<property name="blue" value="249"/>
<property name="green" value="154"/>
<property name="offset" value="0"/>
<property name="red" value="125"/>
<property name="soundtrack" value="audio/music/britta-bot.ogg"/>
<property name="title" value="Baseball with Cornelius"/>
</properties>
Expand All @@ -15,6 +11,11 @@
<tileset firstgid="121" name="collisions" tilewidth="24" tileheight="24">
<image source="../images/tilesets/collisions.png" width="632" height="512"/>
</tileset>
<layer name="backbackground" width="22" height="14">
<data encoding="base64" compression="zlib">
eJxjY2BgYBvFo3gUj+JhgAFy/wc5
</data>
</layer>
<layer name="background" width="22" height="14">
<data encoding="base64" compression="zlib">
eJztzEVOg2EUhtEyYAslwbVYgherkNDirgUKxd2d5XNI/sG3gTLqm5zBTW6eWKyyyv5vcWqCu5Y66mmgkSaaaaGVNtrpIEEnXaQi3fTQG3T76GeAQYYYZoQko4wxzgSTUStNkQ0yZJkKutPkyDPDLHPMs8AiSyyzwiprrAfdP5tssc0OuxTYY5+D6P+QI0occ8IpZ5xzEXQvueKaG265454HHnnimRdeeeOdDz754pufqFtVJtVl8gs3bR3E
Expand All @@ -35,14 +36,14 @@
eJxjYBgFo2AUjALsoJJGmFYAAHZ/Cmc=
</data>
</layer>
<objectgroup name="nodes" width="22" height="14">
<object type="cornelius_head" x="384" y="48" width="90" height="139"/>
<object name="baseball" type="projectile" x="360" y="120" width="9" height="9">
<objectgroup name="nodes">
<object id="1" type="cornelius_head" x="384" y="48" width="90" height="139"/>
<object id="2" name="baseball" type="projectile" x="360" y="120" width="9" height="9">
<properties>
<property name="foreground" value="true"/>
</properties>
</object>
<object name="main" type="door" x="24" y="240" width="24" height="48">
<object id="3" name="main" type="door" x="24" y="240" width="24" height="48">
<properties>
<property name="level" value="greendale-exterior"/>
<property name="sound" value="false"/>
Expand Down
Loading