From 67c80456895ed13f79999e6cb7162680d3e8909d Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Tue, 1 Mar 2022 20:43:10 +0530 Subject: * Adds Fullscreen+Toggle Support * Window Resolution changed to 1280x720 --- core/constants.lua | 2 +- core/map.lua | 42 ++++++++++++++++++++++++++++++------------ core/notifications.lua | 6 +++++- 3 files changed, 36 insertions(+), 14 deletions(-) (limited to 'core') diff --git a/core/constants.lua b/core/constants.lua index 7077f1f..b6cdf6a 100644 --- a/core/constants.lua +++ b/core/constants.lua @@ -2,7 +2,7 @@ constants = {} constants.resetBgColor = {0.15, 0.15, 0.15} constants.resetFgColor = {1, 1, 1} -constants.defaultFontSize = 12 +constants.defaultFontSize = 13 constants.defaultFont = love.graphics.newFont('assets/fonts/C800.ttf', constants.defaultFontSize) function constants:resetColors() diff --git a/core/map.lua b/core/map.lua index 280057a..2bd0110 100644 --- a/core/map.lua +++ b/core/map.lua @@ -1,19 +1,20 @@ Class = require("libs.hump.class") Gamestate = require("libs.hump.gamestate") STI = require("libs.sti") -Moonshine = require("libs.moonshine") +local Moonshine = require("libs.moonshine") Camera = require("libs.hump.camera") Windfield = require("libs.windfield") require("libs.tserial") require("core.notifications") -local zoomFactor = 2 +local zoomFactor = 3 local player = { x=0, y=0, sprite=love.graphics.newImage("assets/images/player_demo.png"), speed=100 } +local fullscreen = true local windowWidth, windowHeight = love.graphics.getDimensions() local _w = windowWidth/zoomFactor @@ -29,10 +30,11 @@ Map = Class { .chain(Moonshine.effects.vignette) .chain(Moonshine.effects.scanlines) .chain(Moonshine.effects.chromasep) + effect.scanlines.thickness = .2 effect.scanlines.opacity = .5 effect.chromasep.angle = 1 - effect.chromasep.radius = 2 + effect.chromasep.radius = 3 notifications = Notifications(zoomFactor) camera = Camera() @@ -74,23 +76,22 @@ Map = Class { } function Map:update(dt) - local vx = 0 local vy = 0 - if love.keyboard.isDown("up") then + if love.keyboard.isDown("w") then vy = player.speed * -1 end - - if love.keyboard.isDown("down") then - vy = player.speed - end - - if love.keyboard.isDown("left") then + + if love.keyboard.isDown("a") then vx = player.speed * -1 end + + if love.keyboard.isDown("s") then + vy = player.speed + end - if love.keyboard.isDown("right") then + if love.keyboard.isDown("d") then vx = player.speed end @@ -149,9 +150,16 @@ function Map:draw() camera:detach() notifications:draw() end) + end function Map:keypressed(key, scancode) + if(scancode=="f4") then + fullscreen = not fullscreen + love.window.setFullscreen(fullscreen) + print("Fullscreen Toggle") + resize() + end end function drawMapLayer(layerName) @@ -160,4 +168,14 @@ function drawMapLayer(layerName) end end +function resize() + _width, _height = love.graphics.getDimensions() + if not(fullscreen) then + _width = 1280 + _height = 720 + end + effect.resize(_width,_height) + notifications.calculateWindowDimensions() +end + return Map \ No newline at end of file diff --git a/core/notifications.lua b/core/notifications.lua index ec0a1e1..26096ca 100644 --- a/core/notifications.lua +++ b/core/notifications.lua @@ -3,11 +3,15 @@ Timer = require("libs.hump.timer") require("core.constants") Notifications = Class { init = function(self, zoomFactor) - windowWidth, windowHeight = love.graphics.getDimensions() + self.calculateWindowDimensions() end, messages={} } +function Notifications:calculateWindowDimensions() + windowWidth, windowHeight = love.graphics.getDimensions() +end + function Notifications:update(dt) for i,obj in pairs(self.messages) do if obj.timer then -- cgit v1.2.3