From f632735f6ea2b1be4dbfb381d28a64e88ac91e37 Mon Sep 17 00:00:00 2001 From: Madiwka3 Date: Thu, 29 Apr 2021 19:55:25 +0600 Subject: [PATCH] Fixed Button things --- buttonClutter.lua | 10 +++++++++- levels/levelgeneral.lua | 1 + levels/menu.lua | 1 + levels/practice.lua | 1 + levels/selectlv.lua | 1 + main.lua | 5 +++-- src/GUI.lua | 5 +++++ src/fullScreener.lua | 8 ++++---- stateMachine.lua | 3 +++ 9 files changed, 28 insertions(+), 7 deletions(-) diff --git a/buttonClutter.lua b/buttonClutter.lua index 106cad8..deb7feb 100644 --- a/buttonClutter.lua +++ b/buttonClutter.lua @@ -8,8 +8,16 @@ function buttonClutter() table.insert(buttons, menu:addButton("Levels", function() gameState = "selectlv" + end)) + --[[table.insert(buttons, menu:addButton("Toggle Fullscreen", + function() + myscreen:toggle(WINDOW_HEIGHT, WINDOW_WIDTH) + DIFFERENCE_X = myscreen.c + DIFFERENCE_Y = myscreen.d + OFFSET_X = myscreen.e + OFFSET_Y = myscreen.f end -)) +))]]-- end local t=0 function explode(x, y) diff --git a/levels/levelgeneral.lua b/levels/levelgeneral.lua index 4e35233..b6f0f19 100644 --- a/levels/levelgeneral.lua +++ b/levels/levelgeneral.lua @@ -107,6 +107,7 @@ function levelgeneral.draw() love.graphics.rectangle("fill",0, WINDOW_HEIGHT-50, firstShip.fuel/2, n) love.graphics.setColor(1,1,1,1) guimenu:butt(playbutts, WINDOW_WIDTH, WINDOW_HEIGHT, 1100, WINDOW_HEIGHT-50, 40, WINDOW_WIDTH/3) + love.keyboard.mouseisReleased = false end end diff --git a/levels/menu.lua b/levels/menu.lua index d007a42..e15a011 100644 --- a/levels/menu.lua +++ b/levels/menu.lua @@ -36,6 +36,7 @@ function menu.draw(dt) love.graphics.setFont(titlefont) love.graphics.printf("NuclearGravity", 0, 20, WINDOW_WIDTH, "center") menu:butt(buttons, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH/2, WINDOW_HEIGHT/2, 40, WINDOW_WIDTH/3) + love.keyboard.mouseisReleased = false end end diff --git a/levels/practice.lua b/levels/practice.lua index 9c43d13..3824df8 100644 --- a/levels/practice.lua +++ b/levels/practice.lua @@ -83,6 +83,7 @@ function practice.draw() GUIDraw("anywhere") elseif gameStatus == "play" then guimenu:butt(playbutts, WINDOW_WIDTH, WINDOW_HEIGHT, 1100, WINDOW_HEIGHT-50, 40, WINDOW_WIDTH/3) + love.keyboard.mouseisReleased = false end diff --git a/levels/selectlv.lua b/levels/selectlv.lua index fbb11be..119c7c0 100644 --- a/levels/selectlv.lua +++ b/levels/selectlv.lua @@ -63,6 +63,7 @@ function selectlv.draw(dt) planets[i]:draw(dt) end menu:butt(levels, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH/2, WINDOW_HEIGHT/2, 40, WINDOW_WIDTH/3, "beatenGreen") + love.keyboard.mouseisReleased = false end return selectlv \ No newline at end of file diff --git a/main.lua b/main.lua index ecf85ab..30e85c9 100644 --- a/main.lua +++ b/main.lua @@ -39,6 +39,7 @@ function love.load() VCAM = VCAM(WINDOW_WIDTH/2, WINDOW_HEIGHT/2) smallfont = love.graphics.newFont("font.ttf", 25) titlefont = love.graphics.newFont("font.ttf", 50) + myscreen = fullScreener(RESOLUTION_SET, isFullscreen, DIFFERENCE_X, DIFFERENCE_Y, OFFSET_X, OFFSET_Y) --table.insert(planets, planet(100, WINDOW_HEIGHT/2-100, 1010000000, 1)) buttonClutter() --planet2 = planet(1000, 300, 1000000000, 20) @@ -46,7 +47,7 @@ end function love.update(dt) stateUpdate(dt) - +love.window.setTitle("Nuclear Gravity") end function love.draw() @@ -66,4 +67,4 @@ end function objReset() firstShip:reset() planets = {} -end \ No newline at end of file +end diff --git a/src/GUI.lua b/src/GUI.lua index 20f7968..af9903f 100644 --- a/src/GUI.lua +++ b/src/GUI.lua @@ -30,6 +30,8 @@ function GUIDraw(mode) --PLACING local mx, my = love.mouse.getPosition() local vmx, vmy = camera:getMousePosition() + local vmx = vmx * DIFFERENCE_X + local vmy = vmy * DIFFERENCE_Y local mx = mx * DIFFERENCE_X local my = my * DIFFERENCE_Y if mode == "anywhere" then @@ -197,6 +199,7 @@ function GUIDraw(mode) --START BUTTON guimenu:butt(guibutts, WINDOW_WIDTH, WINDOW_HEIGHT, menuX + 200, WINDOW_HEIGHT-100, 40, WINDOW_WIDTH/3.7) + love.keyboard.mouseisReleased = false --START BUTTON love.window.setTitle(selectedItem) end @@ -209,6 +212,8 @@ function GUIButton(num, shipImage, x, y, fn, sx, sy, color, r) local mx, my = love.mouse.getPosition() local vmx, vmy = camera:getMousePosition() + local vmx = vmx * DIFFERENCE_X + local vmy = vmy * DIFFERENCE_Y local mx = mx * DIFFERENCE_X local my = my * DIFFERENCE_Y local hot = (mx > x-shipW/2*sx and mx < x-shipW/2*sx + shipW*sx and my > y-shipH/2*sy and my < y -shipH/2*sy + shipH*sy) diff --git a/src/fullScreener.lua b/src/fullScreener.lua index bcd2d4d..8e40ec2 100644 --- a/src/fullScreener.lua +++ b/src/fullScreener.lua @@ -28,10 +28,10 @@ function fullScreener:toggle(vh, vw) simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, {fullscreen = true}) local newWidth = love.graphics.getWidth() local newHeight = love.graphics.getHeight() - self.c = VIRTUAL_WIDTH / newWidth - self.d = VIRTUAL_HEIGHT / newHeight - self.e = math.fmod(newWidth * self.d, VIRTUAL_WIDTH) / 2 - self.f = math.fmod(newHeight * self.d, VIRTUAL_HEIGHT) / 2 + self.c = WINDOW_WIDTH / newWidth + self.d = WINDOW_HEIGHT / newHeight + self.e = math.fmod(newWidth * self.d, WINDOW_WIDTH) / 2 + self.f = math.fmod(newHeight * self.d, WINDOW_HEIGHT) / 2 self.b = 1 end diff --git a/stateMachine.lua b/stateMachine.lua index 1063be4..2db34e7 100644 --- a/stateMachine.lua +++ b/stateMachine.lua @@ -3,6 +3,9 @@ print("levels/"..gameState) function stateUpdate(dt) state = require("levels/"..gameState) state.update(dt) + if love.keyboard.isDown('escape') then + love.event.quit() + end end