diff --git a/src/autosave_warning.lua b/src/autosave_warning.lua index d0601d373..31b065f0d 100644 --- a/src/autosave_warning.lua +++ b/src/autosave_warning.lua @@ -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() @@ -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) diff --git a/src/blackjackgame.lua b/src/blackjackgame.lua index 94b2827bb..fa03815f4 100644 --- a/src/blackjackgame.lua +++ b/src/blackjackgame.lua @@ -78,6 +78,12 @@ end function state:enter(previous, player, screenshot) sound.playMusic( "tavern" ) --lazy because i want to reset all position data + + local width, height, flags = love.window.getMode() + self.width = width*window.scale + self.height = height*window.scale + self.x = camera.x + (self.width - window.width)/2 + self.y = camera.y + (self.height - window.height)/2 self.previous = previous self.screenshot = screenshot @@ -91,22 +97,22 @@ function state:enter(previous, player, screenshot) self.cardback = love.graphics.newQuad( self.cardback_idx * self.card_width, self.card_height * 4, self.card_width, self.card_height, self.cardSprite:getDimensions() ) - self.chip_x = 168 + camera.x - self.chip_y = 237 + camera.y + self.chip_x = 168 + self.x + self.chip_y = 237 + self.y - self.center_x = ( window.width / 2 ) + camera.x - self.center_y = ( window.height / 2 ) + camera.y - self.dealer_stack_x = 386 + camera.x - self.dealer_stack_y = 66 + camera.y + self.center_x = ( window.width / 2 ) + self.x + self.center_y = ( window.height / 2 ) + self.y + self.dealer_stack_x = 386 + self.x + self.dealer_stack_y = 66 + self.y - self.dealer_result_pos_x = 346 + camera.x - self.dealer_result_pos_y = 89 + camera.y + self.dealer_result_pos_x = 346 + self.x + self.dealer_result_pos_y = 89 + self.y - self.outcome_pos_x = 225 + camera.x - self.outcome_pos_y = 141 + camera.y + self.outcome_pos_x = 225 + self.x + self.outcome_pos_y = 141 + self.y - self.options_x = 395 + camera.x - self.options_y = 145 + camera.y + self.options_x = 395 + self.x + self.options_y = 145 + self.y self.selection = 4 -- Don't allow the player to bet more money than they have @@ -356,7 +362,7 @@ end function state:dealCard(to) -- Deal out an individual card, will update score as well, no bust logic --Initiate location of card - x = 293 + camera.x + x = 293 + self.x -- cards dealt face up except for second dealer card local face_up = true @@ -367,14 +373,14 @@ function state:dealCard(to) -- Deal out an individual card, will update score as if to == 'dealer' then hand = self.dealerHand[1] - y = 66 + camera.y + y = 66 + self.y -- second card is not shown if #self.dealerHand[1].cards == 1 then face_up = false end elseif to == 'player' then hand = self.playerHand[self.activeHand] - y = 169 + ( self.activeHand - 1 ) * 9 + camera.y + y = 169 + ( self.activeHand - 1 ) * 9 + self.y end self.card_moving = true @@ -476,7 +482,7 @@ function state:split() --move 2nd card to new hand and move to new row self.playerHand[newHandNum].cards[1] = table.remove(self.playerHand[self.activeHand].cards) --move second card to new hand - self.playerHand[newHandNum].cards[1].y = 169 + camera.y + ( newHandNum - 1 ) * 9 -- place hand in new row + self.playerHand[newHandNum].cards[1].y = 169 + self.y + ( newHandNum - 1 ) * 9 -- place hand in new row self.playerHand[newHandNum].cards[1].x = self.playerHand[self.activeHand].cards[1].x if self.playerHand[self.activeHand].cards[1].card == 1 then @@ -612,14 +618,20 @@ function state:updateScore(hand) -- Accepts dealerHand[1] or playerHand[activeHa end function state:draw() + if self.screenshot then - love.graphics.draw(self.screenshot, camera.x, camera.y, 0, - window.width / love.graphics:getWidth(), window.height / love.graphics:getHeight() ) + love.graphics.draw( self.screenshot, self.x + camera.x, self.y + camera.y, 0, self.width / love.graphics:getWidth(), self.height / love.graphics:getHeight() ) + -- hiding the HUD + love.graphics.setColor( 0, 0, 0, 255) + love.graphics.rectangle("fill", camera.x, camera.y, (self.width - window.width)/2, self.height) + love.graphics.rectangle("fill", camera.x, camera.y, self.width, (self.height - window.height)/2) + love.graphics.setColor( 255, 255, 255, 255) else - love.graphics.setColor(0, 0, 0, 255) - love.graphics.rectangle('fill', 0, 0, love.graphics:getDimensions() ) - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor( 0, 0, 0, 255 ) + love.graphics.rectangle( 'fill', 0, 0, self.width, self.height ) + love.graphics.setColor( 255, 255, 255, 255 ) end + love.graphics.draw( self.table, self.center_x - ( self.table:getWidth() / 2 ), self.center_y - ( self.table:getHeight() / 2 )) --dealer stack @@ -726,9 +738,9 @@ function state:draw() love.graphics.print(self.outcome, self.outcome_pos_x, self.outcome_pos_y, 0, 0.5) end -- print current money - love.graphics.print( 'On Hand\n $ ' .. self.player.money, 110+camera.x, 244+camera.y, 0, 0.5) + love.graphics.print( 'On Hand\n $ ' .. self.player.money, 110+self.x, 244+self.y, 0, 0.5) -- print current bet - love.graphics.print('Bet $ ' .. self.currentBet, 361+camera.x, 141+camera.y, 0, 0.5) + love.graphics.print('Bet $ ' .. self.currentBet, 361+self.x, 141+self.y, 0, 0.5) love.graphics.setColor( 255, 255, 255, 255 ) diff --git a/src/brewing.lua b/src/brewing.lua index 56f251160..20862e231 100644 --- a/src/brewing.lua +++ b/src/brewing.lua @@ -26,6 +26,10 @@ end --enter may take additional arguments from previous as necessary --@param previous the actual gamestate that the player came from (not just its name) function state:enter(previous, player, screenshot, supplierName) + local width, height, flags = love.window.getMode() + self.width = width*window.scale + self.height = height*window.scale + fonts.set( 'arial' ) sound.playMusic( "potionlab" ) self.previous = previous @@ -191,17 +195,17 @@ end function state:draw() if self.screenshot then - love.graphics.draw( self.screenshot, camera.x, camera.y, 0, window.width / love.graphics:getWidth(), window.height / love.graphics:getHeight() ) + love.graphics.draw( self.screenshot, camera.x, camera.y, 0, self.width / love.graphics:getWidth(), self.height / love.graphics:getHeight() ) else love.graphics.setColor( 0, 0, 0, 255 ) - love.graphics.rectangle( 'fill', 0, 0, love.graphics:getWidth(), love.graphics:getHeight() ) + love.graphics.rectangle( 'fill', 0, 0, love.graphics:getDimensions() ) love.graphics.setColor( 255, 255, 255, 255 ) end self.hud:draw( self.player ) - local width = window.width - local height = window.height + local width = self.width + local height = self.height local menu_right = camera.x + width/2 - self.background:getWidth()/2 local menu_top = camera.y + height/2 - self.background:getHeight()/2 love.graphics.draw( self.background, menu_right,menu_top, 0 ) @@ -213,9 +217,8 @@ function state:draw() love.graphics.newQuad(0,0,selectionSprite:getWidth(),selectionSprite:getHeight(),selectionSprite:getWidth(),selectionSprite:getHeight()), firstcell_right, firstcell_top + ((self.selected-1) * 22)) - love.graphics.setColor( 255, 255, 255, 255 ) - love.graphics.printf(self.player.controls:getKey('JUMP') .. " BREW", 0, 200, width, 'center') - love.graphics.printf(self.player.controls:getKey('START') .. " CANCEL", 0, 213, width, 'center') + love.graphics.printf(self.player.controls:getKey('JUMP') .. " BREW", menu_right, 200, self.background:getWidth(), 'center') + love.graphics.printf(self.player.controls:getKey('START') .. " CANCEL", menu_right, 213, self.background:getWidth(), 'center') for i = 1,4 do if self.values[i+self.offset] ~= nil then diff --git a/src/cheatscreen.lua b/src/cheatscreen.lua index 0077a38fb..336dad1e3 100644 --- a/src/cheatscreen.lua +++ b/src/cheatscreen.lua @@ -103,6 +103,10 @@ function cheatscreen:enter( previous, real_previous ) camera:setPosition(0, 0) self.previous = real_previous + + local width, height, flags = love.window.getMode() + self.width = width*window.scale + self.height = height*window.scale self.current_key = 'g' end @@ -186,9 +190,9 @@ function cheatscreen:keypressed( button ) end function cheatscreen:draw() - local y = self.cmd.offset_y + local y = self.cmd.offset_y + (self.height - window.height)/2 love.graphics.setColor( 0, 0, 0, 255 ) - love.graphics.rectangle( 'fill', 0, 0, window.width, window.height ) + love.graphics.rectangle( 'fill', camera.x, camera.y, self.width, self.height ) love.graphics.setColor( 88, 246, 0, 255 ) for i,n in pairs(self.cmd.queue) do love.graphics.print( n, self.cmd.offset_x, y, 0, 0.5, 0.5 ) diff --git a/src/credits.lua b/src/credits.lua index 902277c7e..0584b9b53 100644 --- a/src/credits.lua +++ b/src/credits.lua @@ -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() @@ -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 diff --git a/src/frying.lua b/src/frying.lua index f7063668c..85cec1d6b 100644 --- a/src/frying.lua +++ b/src/frying.lua @@ -26,6 +26,9 @@ end --enter may take additional arguments from previous as necessary --@param previous the actual gamestate that the player came from (not just its name) function state:enter(previous, player, screenshot, supplierName) + local width, height, flags = love.window.getMode() + self.width = width*window.scale + self.height = height*window.scale fonts.set( 'arial' ) sound.playMusic( "potionlab" ) self.previous = previous @@ -191,17 +194,17 @@ end function state:draw() if self.screenshot then - love.graphics.draw( self.screenshot, camera.x, camera.y, 0, window.width / love.graphics:getWidth(), window.height / love.graphics:getHeight() ) + love.graphics.draw( self.screenshot, camera.x, camera.y, 0, self.width / love.graphics:getWidth(), self.height / love.graphics:getHeight() ) else love.graphics.setColor( 0, 0, 0, 255 ) - love.graphics.rectangle( 'fill', 0, 0, love.graphics:getWidth(), love.graphics:getHeight() ) + love.graphics.rectangle( 'fill', 0, 0, love.graphics:getDimensions() ) love.graphics.setColor( 255, 255, 255, 255 ) end self.hud:draw( self.player ) - local width = window.width - local height = window.height + local width = self.width + local height = self.height local menu_right = camera.x + width/2 - self.background:getWidth()/2 local menu_top = camera.y + height/2 - self.background:getHeight()/2 love.graphics.draw( self.background, menu_right,menu_top, 0 ) @@ -214,8 +217,8 @@ function state:draw() firstcell_right, firstcell_top + ((self.selected-1) * 22)) love.graphics.setColor( 255, 255, 255, 255 ) - love.graphics.printf(self.player.controls:getKey('JUMP') .. " fry", 0, 200, width, 'center') - love.graphics.printf(self.player.controls:getKey('START') .. " CANCEL", 0, 213, width, 'center') + love.graphics.printf(self.player.controls:getKey('JUMP') .. " fry", menu_right, 200, self.background:getWidth(), 'center') + love.graphics.printf(self.player.controls:getKey('START') .. " CANCEL", menu_right, 213, self.background:getWidth(), 'center') for i = 1,4 do if self.values[i+self.offset] ~= nil then diff --git a/src/instructions.lua b/src/instructions.lua index e89a22fb3..b0ee7bbfe 100644 --- a/src/instructions.lua +++ b/src/instructions.lua @@ -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") @@ -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() @@ -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) diff --git a/src/level.lua b/src/level.lua index 843f6fe2f..359f13b2b 100644 --- a/src/level.lua +++ b/src/level.lua @@ -94,23 +94,25 @@ 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)) +local function setBackgroundColor() + love.graphics.setBackgroundColor(0, 0, 0) 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) @@ -149,7 +151,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' @@ -375,9 +376,16 @@ function Level:enter(previous, door, position) self:restartLevel(true) end - camera.max.x = self.map.width * self.map.tilewidth - window.width + 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) - setBackgroundColor(self.map) + setBackgroundColor() sound.playMusic( self.music ) @@ -544,7 +552,27 @@ function Level:exit(levelName, doorName) end end +function Level:setBoundaryColor() + local prop = self.map.properties + if not prop.red then return end + + love.graphics.setColor(tonumber(prop.red), tonumber(prop.green), tonumber(prop.blue), 255) + + local width, height, flags = love.window.getMode() + + local widthDif = (self.map.width * self.map.tilewidth) - width*window.scale + local heightDif = (self.map.height * self.map.tileheight) - height*window.scale + + -- Draw the background only as big as the size of the level boundary + love.graphics.rectangle("fill", camera.x + ((widthDif) * window.scale * -1), + camera.y + ((heightDif) * window.scale * -1), + self.boundary.width, + self.boundary.height) + love.graphics.setColor( 255, 255, 255, 255 ) +end + function Level:draw() + self:setBoundaryColor() self.tileset:draw(0, 0, 'background') if self.player.footprint then @@ -821,9 +849,9 @@ function Level:getOutgoingDoors() -- process all nodes; self.doors doesn't contain all doors, it contains only named doors (i.e. incoming) for _,door in pairs(self.nodes) do - if door.isDoor and door.level ~= nil then - table.insert(doors, door) - end + if door.isDoor and door.level ~= nil then + table.insert(doors, door) + end end return doors diff --git a/src/options.lua b/src/options.lua index ce63a3b8a..ad3ca4515 100644 --- a/src/options.lua +++ b/src/options.lua @@ -227,12 +227,10 @@ end function state:updateFullscreen() if self.option_map['FULLSCREEN'].bool then utils.setMode(0, 0, true) - local width = love.graphics:getWidth() - local height = love.graphics:getHeight() - camera:setScale( window.width / width , window.height / height ) + camera:setScale(window.scale, window.scale) love.mouse.setVisible(false) else - camera:setScale(window.scale,window.scale) + camera:setScale(window.scale, window.scale) utils.setMode(window.screen_width, window.screen_height, false) love.mouse.setVisible(true) end diff --git a/src/overworld.lua b/src/overworld.lua index e16128b5d..0067925d5 100644 --- a/src/overworld.lua +++ b/src/overworld.lua @@ -58,6 +58,11 @@ function state:insertrandomcloud(map, nofade) end function state:enter(previous) + + local width, height, flags = love.window.getMode() + self.width = width*window.scale + self.height = height*window.scale + self.overworld = { love.graphics.newImage('images/overworld/world_01.png'), love.graphics.newImage('images/overworld/world_02.png'), @@ -143,7 +148,7 @@ function state:enter(previous) g = anim8.newGrid(36, 36, self.charactersprites:getWidth(), self.charactersprites:getHeight()) camera:scale(scale, scale) - camera.max.x = map.width * map.tileWidth - (window.width * 2) + camera.max.x = map.width * map.tileWidth - (self.width * 2) fonts.set('big') @@ -289,7 +294,7 @@ function state:update(dt) end end - camera:setPosition(self.tx - window.width * scale / 2, self.ty - window.height * scale / 2) + camera:setPosition(self.tx - self.width * scale / 2, self.ty - self.height * scale / 2) end function state:move( button ) @@ -438,12 +443,12 @@ function state:draw() end end - love.graphics.draw(self.board, camera.x + window.width - self.board:getWidth() / 2, - camera.y + window.height + self.board:getHeight() * 2) + love.graphics.draw(self.board, camera.x + self.width - self.board:getWidth() / 2, + camera.y + self.height + self.board:getHeight() * 2) love.graphics.printf(self:title(), - camera.x + window.width - self.board:getWidth() / 2, - camera.y + window.height + self.board:getHeight() * 2.5 - 10, + camera.x + self.width - self.board:getWidth() / 2, + camera.y + self.height + self.board:getHeight() * 2.5 - 10, self.board:getWidth(), 'center') end diff --git a/src/pause.lua b/src/pause.lua index b436fe3ed..6123c2998 100644 --- a/src/pause.lua +++ b/src/pause.lua @@ -20,6 +20,10 @@ function state:enter(previous, player) fonts.set( 'big' ) + local width, height, flags = love.window.getMode() + self.width = width*window.scale + self.height = height*window.scale + camera:setPosition(0, 0) self.option = 0 @@ -91,19 +95,22 @@ 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 x = (self.width - window.width)/2 + local y = (self.height - window.height)/2 local controls = self.player.controls love.graphics.setColor( 0, 0, 0, 255 ) - love.graphics.print('Controls', 198, 101) - love.graphics.print('Options', 198, 131) - love.graphics.print('Quit to Map', 198, 161) - love.graphics.print('Quit to Menu', 198, 191) - love.graphics.print('Quit to Desktop', 198, 221) + love.graphics.print('Controls', x + 198, y + 101) + love.graphics.print('Options', x + 198, y + 131) + love.graphics.print('Quit to Map', x + 198, y + 161) + love.graphics.print('Quit to Menu', x + 198, y + 191) + love.graphics.print('Quit to Desktop', x + 198, y + 221) love.graphics.setColor( 255, 255, 255, 255 ) - love.graphics.draw(self.arrow, 156, 96 + 30 * self.option) + love.graphics.draw(self.arrow, x + 156, y + 96 + 30 * self.option) local back = controls:getKey("START") .. ": BACK TO GAME" local howto = controls:getKey("ATTACK") .. " OR " .. controls:getKey("JUMP") .. ": SELECT ITEM" love.graphics.print(back, 25, 25) diff --git a/src/pokergame.lua b/src/pokergame.lua index 2ad50672d..d8461e603 100644 --- a/src/pokergame.lua +++ b/src/pokergame.lua @@ -98,9 +98,15 @@ end function state:enter(previous, player, screenshot) sound.playMusic( "tavern" ) + + local width, height, flags = love.window.getMode() + self.width = width*window.scale + self.height = height*window.scale + self.x = camera.x + (self.width - window.width)/2 + self.y = camera.y + (self.height - window.height)/2 self.previous = previous - self.screenshot = screenshot + self.screenshot = screenshot self.prompt = nil @@ -117,17 +123,16 @@ function state:enter(previous, player, screenshot) self.cardback = love.graphics.newQuad( self.cardback_idx * self.card_width, self.card_height * 4, self.card_width, self.card_height, self.cardSprite:getDimensions() ) + self.chip_x = 138+36 + self.x + self.chip_y = 208+33 + self.y - self.chip_x = 138+36 + camera.x - self.chip_y = 208+33 + camera.y - - self.center_x = ( window.width / 2 ) + camera.x - self.center_y = ( window.height / 2 ) + camera.y - self.dealer_stack_x = 356+36 + camera.x - self.dealer_stack_y = 37+33 + camera.y + self.center_x = ( window.width / 2 ) + self.x + self.center_y = ( window.height / 2 ) + self.y + self.dealer_stack_x = 356+36 + self.x + self.dealer_stack_y = 37+33 + self.y - self.options_x = 360+36 + camera.x - self.options_y = 135+33 + camera.y + self.options_x = 360+36 + self.x + self.options_y = 135+33 + self.y self.selection = 2 -- Don't allow the player to bet more money than they have @@ -374,15 +379,15 @@ end function state:deal_card( to ) deal_card = table.remove( self.deck, 1 ) - x = 266+33 + camera.x + x = 266+33 + self.x face_up = true tbl = self.player_cards - y = 140+33 + camera.y + y = 140+33 + self.y if to == 'dealer' then -- second card is not shown face_up = false tbl = self.dealer_cards - y = 37+33 + camera.y + y = 37+33 + self.y end index = get_first_nil(tbl) tbl[index] = { @@ -431,11 +436,17 @@ function state:game_over() end function state:draw() + if self.screenshot then - love.graphics.draw( self.screenshot, camera.x, camera.y, 0, window.width / love.graphics:getWidth(), window.height / love.graphics:getHeight() ) + love.graphics.draw( self.screenshot, self.x + camera.x, self.y + camera.y, 0, self.width / love.graphics:getWidth(), self.height / love.graphics:getHeight() ) + -- hiding the HUD + love.graphics.setColor( 0, 0, 0, 255) + love.graphics.rectangle("fill", camera.x, camera.y, (self.width - window.width)/2, self.height) + love.graphics.rectangle("fill", camera.x, camera.y, self.width, (self.height - window.height)/2) + love.graphics.setColor( 255, 255, 255, 255) else love.graphics.setColor( 0, 0, 0, 255 ) - love.graphics.rectangle( 'fill', 0, 0, love.graphics:getDimensions() ) + love.graphics.rectangle( 'fill', 0, 0, self.width, self.height ) love.graphics.setColor( 255, 255, 255, 255 ) end @@ -518,21 +529,21 @@ function state:draw() end if self.outcome then - love.graphics.print( self.outcome, 200+36+camera.x, 112+33+camera.y, 0, 0.5 ) + love.graphics.print( self.outcome, 200+36+self.x, 112+33+self.y, 0, 0.5 ) end if(self.player_hand and self.dealer_hand) then - x = 80+36 + camera.x - love.graphics.print( self.dealer_hand.hand.friendly_name, x, 97+33+camera.y, 0, 0.5) - love.graphics.print( self.player_hand.hand.friendly_name, x, 128+33+camera.y, 0, 0.5 ) + x = 80+36 + self.x + love.graphics.print( self.dealer_hand.hand.friendly_name, x, 97+33+self.y, 0, 0.5) + love.graphics.print( self.player_hand.hand.friendly_name, x, 128+33+self.y, 0, 0.5 ) end - love.graphics.print( 'On Hand\n $ ' .. self.player.money, 80+36 + camera.x, 213+33+camera.y, 0, 0.5 ) + love.graphics.print( 'On Hand\n $ ' .. self.player.money, 80+36 + self.x, 213+33+self.y, 0, 0.5 ) if self.nakedBet then - love.graphics.print('Bet Clothes', 315+36+camera.x, 112+33+camera.y, 0, 0.5 ) + love.graphics.print('Bet Clothes', 315+36+self.x, 112+33+self.y, 0, 0.5 ) else - love.graphics.print( 'Bet $ ' .. self.bet , 315+36+camera.x, 112+33+camera.y, 0, 0.5 ) + love.graphics.print( 'Bet $ ' .. self.bet , 315+36+self.x, 112+33+self.y, 0, 0.5 ) end love.graphics.setColor( 255, 255, 255, 255 ) @@ -753,7 +764,6 @@ function compare_hands(a,b) if(ret ~= 0) then return ret end - i = i + 1 end end return 0 diff --git a/src/scanning.lua b/src/scanning.lua index 7df829d22..5fe2318d4 100644 --- a/src/scanning.lua +++ b/src/scanning.lua @@ -16,6 +16,9 @@ function state:enter(previous) self:refresh() self.previous = previous self.music = sound.playMusic("opening") + local width, height, flags = love.window.getMode() + self.width = width*window.scale + self.height = height*window.scale end function state:keypressed( button ) @@ -57,8 +60,8 @@ function state:draw() love.graphics.setColor( 255, 255, 255, 255 ) -- coloured backgrounds - local width = window.width - local height = window.height + local width = self.width + local height = self.height local xcorner = width/2 - 200 local ycorner = height/2 - 125 diff --git a/src/shopping.lua b/src/shopping.lua index 99201e88a..dd7eadaaf 100644 --- a/src/shopping.lua +++ b/src/shopping.lua @@ -40,7 +40,7 @@ function state:init() self.arrow = love.graphics.newImage("images/menu/small_arrow.png") - local backgroundtGrid = anim8.newGrid(87, 130, self.backgroundt:getWidth(), self.backgroundt:getHeight()) + local backgroundtGrid = anim8.newGrid(87, 130, self.backgroundt:getDimensions()) self.categories = {} self.categories[1] = "weapons" @@ -98,6 +98,12 @@ end function state:enter(previous, player, screenshot, supplierName) fonts.set( 'small' ) + + local width, height, flags = love.window.getMode() + self.width = width*window.scale + self.height = height*window.scale + self.x = camera.x + (self.width - window.width)/2 + self.y = camera.y + (self.height - window.height)/2 self.previous = previous self.player = player @@ -415,18 +421,18 @@ function state:draw() --background if self.screenshot then - love.graphics.draw( self.screenshot, camera.x, camera.y, 0, window.width / love.graphics:getWidth(), window.height / love.graphics:getHeight() ) + love.graphics.draw( self.screenshot, camera.x, camera.y, 0, window.scale, window.scale) else love.graphics.setColor( 0, 0, 0, 255 ) - love.graphics.rectangle( 'fill', 0, 0, love.graphics:getWidth(), love.graphics:getHeight() ) + love.graphics.rectangle( 'fill', 0, 0, self.width, self.height ) love.graphics.setColor( 255, 255, 255, 255 ) end -- HUD self.hud:draw( self.player ) - local width = window.width - local height = window.height + local width = self.width + local height = self.height local xcorner = camera.x + width/2 - self.background:getWidth()/2 local ycorner = camera.y + height*2/5 - self.background:getHeight()/2 diff --git a/src/start.lua b/src/start.lua index 19d5ed3b2..a921abaa1 100644 --- a/src/start.lua +++ b/src/start.lua @@ -41,6 +41,9 @@ function state:enter( previous ) camera:setPosition( 0, 0 ) self.previous = previous self.window = 'main' + local width, height, flags = love.window.getMode() + self.width = width*window.scale + self.height = height*window.scale end function state:leave() @@ -161,8 +164,11 @@ function state:draw() love.graphics.setColor(255, 255, 255) 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 x = (self.width - window.width)/2 + local y = 90 + (self.height - window.height)/2 if self.window == 'main' then love.graphics.setColor(255, 255, 255) @@ -172,20 +178,18 @@ function state:draw() love.graphics.print(delete, 25, 55) local yFactor = 20 - local y = 90 - love.graphics.setColor( 0, 0, 0, 255 ) for n, opt in pairs(self.options) do if tonumber( n ) ~= nil then if opt.name and opt.slot then - love.graphics.print( opt.name , 175, y, 0 ) + love.graphics.print( opt.name , x + 175, y, 0 ) y = y + yFactor - love.graphics.print( self.get_slot_level( opt.slot ), 190, y, 0 ) + love.graphics.print( self.get_slot_level( opt.slot ), x + 190, y, 0 ) y = y + yFactor elseif opt.name then y = y + yFactor - love.graphics.print( opt.name, 175, y, 0 ) + love.graphics.print( opt.name, x + 175, y, 0 ) end end end @@ -195,7 +199,7 @@ function state:draw() if self.selection > 2 then arrowYFactor = 2.5 end - love.graphics.draw( self.arrow, 135, 127 + ( (yFactor * arrowYFactor) * ( self.selection - 1 ) ) ) + love.graphics.draw( self.arrow, x + 135, y - 80 + ( (yFactor * arrowYFactor) * ( self.selection - 1 ) ) ) elseif self.window == 'deleteSlot' then love.graphics.setColor(255, 255, 255) local howto = controls:getKey("UP") .. " OR " .. controls:getKey("DOWN") .. ": CHANGE OPTION" @@ -203,11 +207,11 @@ function state:draw() love.graphics.print(howto, 25, 25) love.graphics.print(delete, 25, 55) love.graphics.setColor( 0, 0, 0, 255 ) - love.graphics.printf('Are you sure you want to delete this slot?', 155, 110, self.background:getWidth() - 30, 'left') - love.graphics.print('Yes', 175, 175, 0) - love.graphics.print('No', 175, 205, 0) + love.graphics.printf('Are you sure you want to delete this slot?', x + 155, y + 20, self.background:getWidth() - 30, 'left') + love.graphics.print('Yes', x + 175, y + 85, 0) + love.graphics.print('No', x + 175, y + 115, 0) love.graphics.setColor( 255, 255, 255, 255 ) - love.graphics.draw( self.arrow, 140, 170 + 30 * self.selectionDelete ) + love.graphics.draw( self.arrow, x + 140, y + 80 + 30 * self.selectionDelete ) end end diff --git a/src/update.lua b/src/update.lua index b389c519a..db732a2ce 100644 --- a/src/update.lua +++ b/src/update.lua @@ -21,6 +21,9 @@ function screen:enter() self.logo = love.graphics.newImage('images/menu/splash.png') self.bg = sound.playMusic("ending") self.updater:start() + local width, height, flags = love.window.getMode() + self.width = width*window.scale + self.height = height*window.scale end function screen:update(dt) @@ -54,16 +57,16 @@ end function screen:draw() love.graphics.setColor(255, 255, 255, math.min(255, self.time * 100)) - love.graphics.draw(self.logo, window.width / 2 - self.logo:getWidth() / 2, - window.height / 2 - self.logo:getHeight() / 2) + love.graphics.draw(self.logo, (self.width - self.logo:getWidth()) / 2, + (self.height - self.logo:getHeight()) / 2) if self.progress > 0 then love.graphics.setColor(255, 255, 255) - love.graphics.rectangle("line", 40, window.height - 75, window.width - 80, 10) - love.graphics.rectangle("fill", 40, window.height - 75, - (window.width - 80) * self.progress / 100, 10) - love.graphics.printf(self.message, 40, window.height - 55, - window.width - 80, 'center') + love.graphics.rectangle("line", 40, self.width - 75, self.height - 80, 10) + love.graphics.rectangle("fill", 40, self.height - 75, + (self.width - 80) * self.progress / 100, 10) + love.graphics.printf(self.message, 40, self.height - 55, + self.width - 80, 'center') end end diff --git a/src/verticalparticles.lua b/src/verticalparticles.lua index 21f4f0447..de5a38134 100644 --- a/src/verticalparticles.lua +++ b/src/verticalparticles.lua @@ -7,12 +7,14 @@ function Particle:new() new = {} setmetatable(new, Particle) - local winWidth = window.width + local width, height, flags = love.window.getMode() + self.width = width*window.scale + self.height = height*window.scale new.size = math.random(3) - new.pos = { x = math.random(winWidth), y = math.random(window.height) } + new.pos = { x = math.random(self.width), y = math.random(self.height) } - local ratio = 1.0 - math.cos(math.abs(new.pos.x - winWidth/2) * 2 / winWidth) * 0.6 + local ratio = 1.0 - math.cos(math.abs(new.pos.x - self.width/2) * 2 / self.width) * 0.6 new.speed = 300 * (ratio + math.random()/4) @@ -23,7 +25,7 @@ end function Particle:update(dt) self.pos.y = self.pos.y - (dt * self.speed) - if self.pos.y < 0 then self.pos.y = window.height end + if self.pos.y < 0 then self.pos.y = self.height end end function Particle:draw() diff --git a/src/welcome.lua b/src/welcome.lua index 4f453623b..93c35ef3b 100644 --- a/src/welcome.lua +++ b/src/welcome.lua @@ -22,7 +22,6 @@ function state:init() Gamestate.switch(option) end end) - end function state:enter(previous) @@ -30,6 +29,10 @@ function state:enter(previous) self.arrow = love.graphics.newImage("images/menu/small_arrow.png") self.text = string.format(app.i18n('s_or_s_select_item'), controls:getKey('JUMP'), controls:getKey('ATTACK') ) self.bg = sound.playMusic("ending") + + local width, height, flags = love.window.getMode() + self.width = width*window.scale + self.height = height*window.scale self.line = " terminal:// \n\n operations://loadprogram:(true) \n\n".. " program:-journey-to-the-center-of-hawkthorne \n\n loading simulation ..." @@ -87,23 +90,21 @@ end function state:draw() - --background colour - love.graphics.setColor( 0, 0, 0, 255 ) - love.graphics.rectangle( 'fill', 0, 0, love.graphics:getWidth(), love.graphics:getHeight() ) - love.graphics.setColor( 255, 255, 255, 255 ) + local a = (self.width - window.width)/2 + local b = (self.height - window.height)/2 -- green terminal fonts.set('courier') love.graphics.setColor( 48, 254, 31, 225 ) if self.code_loaded == false then - love.graphics.print(self.line_short, 50, 50, 0, 0.5, 0.5 ) + love.graphics.print(self.line_short, a + 50, b + 50, 0, 0.5, 0.5 ) for i = 1, 7 do - love.graphics.print(self.code_short[i], 60*i - 10, 130, 0, 0.4, 0.4) + love.graphics.print(self.code_short[i], a + 60*i - 10, b + 130, 0, 0.4, 0.4) end else - love.graphics.print(self.line, 50, 50, 0, 0.5, 0.5 ) + love.graphics.print(self.line, a + 50, b + 50, 0, 0.5, 0.5 ) for i = 1, 7 do - love.graphics.print(self.code, 60*i - 10, 130, 0, 0.4, 0.4) + love.graphics.print(self.code, a + 60*i - 10, b + 130, 0, 0.4, 0.4) end end @@ -111,8 +112,8 @@ function state:draw() fonts.set( 'big' ) -- menu - local x = window.width / 2 - self.splash:getWidth()/2 - local y = 2*window.height / 2.5 - self.splash:getHeight()/2 + local x = (self.width - self.splash:getWidth())/2 + local y = 0.8* self.height - self.splash:getHeight()/2 if self.code_loaded then love.graphics.draw(self.splash, x, y) love.graphics.draw(self.arrow, x + 12, y + 23 + 12 * (self.menu:selected() - 1)) @@ -121,7 +122,7 @@ function state:draw() end self.menu_shown = true -- control instructions - love.graphics.print(self.text, window.width/2-65, window.height - 24, 0, 0.5, 0.5) + love.graphics.print(self.text, self.width/2-65, self.height - 24, 0, 0.5, 0.5) end end