Browse Source

lowcpu mode added

tags/earlygalaxy
Madiwka3 3 years ago
parent
commit
bc592919b4
5 changed files with 118 additions and 119 deletions
  1. +10
    -2
      main.lua
  2. +86
    -92
      mainMenu.lua
  3. +1
    -0
      readme.md
  4. +0
    -0
      save.lua
  5. +21
    -25
      src/baseGame.lua

+ 10
- 2
main.lua View File

@@ -26,7 +26,7 @@ showTouchControls = false

--0.9 VARIABLES
isButtonAnimated = false
lowcpu = false
wallsLoadError = false
background = love.graphics.newImage('img/background.jpg')
backgroundScroll = 0
@@ -1020,10 +1020,19 @@ function speedControl()
end
end
checking = 0
local countinglowcpu = 0
function love.update(dt)
--checking = checking + 1
--print(checking)
--print("IMPORTANT!!!!!" .. globalState .. gameState)
if not lowcpu then
if (love.timer.getFPS() < 50 and gameState ~= "animation") then
countinglowcpu = countinglowcpu + 1
if countinglowcpu > 10 then
lowcpu = true
end
end
end
for i, explosion in ipairs(explosions) do
explosion:update(dt)
end
@@ -1039,7 +1048,6 @@ function love.update(dt)
end
if globalState == "base" and not paused then
basegame(dt)
end
if globalState == "menu" then
debugCheck(dt)


+ 86
- 92
mainMenu.lua View File

@@ -1,6 +1,6 @@
mainMenu = Class{}
function mainMenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds, location)
if (gameState == 'editor')
if (gameState == 'editor')
then
ev_button_width = VIRTUAL_WIDTH * (1/72)
ev_BUTTON_HEIGHT = VIRTUAL_WIDTH * (1/72)
@@ -79,40 +79,37 @@ function mainMenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds
ev_bx = locationx - (ev_button_width * 0.5)
end
if (location == 'control') then
if string.sub(button.text, 1, 1) == '2' then
if string.sub(button.text, 1, 1) == '2' then
ev_bx = (VIRTUAL_WIDTH*0.2) - (ev_button_width * 0.5)
ev_by = locationy - (total_height * 0.5) + cursor_y
elseif string.sub(button.text, 1, 1) == '1' then
ev_bx = (VIRTUAL_WIDTH*0.8) - (ev_button_width * 0.5)
ev_by = locationy - (total_height * 0.5) + cursor_y
else
ev_bx = (VIRTUAL_WIDTH*0.5) - (ev_button_width * 0.5)
ev_by = locationy - (total_height * 0.5) + cursor_y
end
elseif button.text == 'NUCLEAR MODE' and easternum < 11 then
ev_bx = -400
ev_by = -400
elseif button.x > locationx - (ev_button_width * 0.5) then
--print("moving from" .. button.x)
button.x = button.x - 15
--print("moving!" .. button.x)
ev_by = locationy - (total_height * 0.5) + cursor_y
elseif string.sub(button.text, 1, 1) == '1' then
ev_bx = (VIRTUAL_WIDTH*0.8) - (ev_button_width * 0.5)
ev_by = locationy - (total_height * 0.5) + cursor_y
else
ev_bx = (VIRTUAL_WIDTH*0.5) - (ev_button_width * 0.5)
ev_by = locationy - (total_height * 0.5) + cursor_y
end
if (button.text == 'Play') and location == 'playercount' then color = {0/255, 255/255, 0/255, 255} else
color = {10, 10, 0, 255}
elseif button.text == 'NUCLEAR MODE' and easternum < 11 then
ev_bx = -400
ev_by = -400
elseif button.x > locationx - (ev_button_width * 0.5) then
--print("moving from" .. button.x)
if lowcpu then
button.x = locationx - (ev_button_width * 0.5)
else
button.x = button.x - 15
end
--print("moving!" .. button.x)
ev_by = locationy - (total_height * 0.5) + cursor_y
else
ev_by = locationy - (total_height * 0.5) + cursor_y
end
local color = {255, 255, 255, 255}
if (button.text == 'NUCLEAR MODE' and easternum > 10) then
color = {255, 255, 255, 255}
if (button.text == 'Play') and location == 'playercount' then color = {0/255, 255/255, 0/255, 255}
elseif (button.text == 'NUCLEAR MODE' and easternum > 10) then
color = {0,0,0,1}
else
color = {1,1,1,1}
end
local mx, my = love.mouse.getPosition()
mx = mx
my = my
local mx = mx * DIFFERENCE_X
local my = my * DIFFERENCE_Y
local hot = (mx > ev_bx and mx < ev_bx + ev_button_width and my > ev_by and my < ev_by + ev_BUTTON_HEIGHT) and i
@@ -121,26 +118,26 @@ function mainMenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds
end
--print(love.keyboard.mouseisReleased)
button.now = love.keyboard.mouseisReleased
if location == "android" then
button.now = love.mouse.isDown(1)
end
button.now = love.keyboard.mouseisReleased
if location == "android" then
button.now = love.mouse.isDown(1)
end
if button.now and hot == i then
love.keyboard.mouseisReleased = false
love.graphics.setColor(0,0,0,1)
love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
sounds['wallhit']:play()
if button.skipAnim then
print("skipped anim")
else
for j, buttons in ipairs(buttons) do
buttons.x = 1300
print("making" .. j)
end
end
button.fn()
break
end
sounds['wallhit']:play()
if button.skipAnim then
print("skipped anim")
else
for j, buttons in ipairs(buttons) do
buttons.x = 1300
print("making" .. j)
end
end
button.fn()
break
end
love.graphics.setColor(unpack(color))
love.graphics.rectangle("fill", ev_bx,ev_by, ev_button_width, ev_BUTTON_HEIGHT)
print(ev_bx .. " " .. i)
@@ -159,71 +156,68 @@ function mainMenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds
love.graphics.print("P2 UP: " .. string.upper(p2control.up), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5)
elseif button.text == '1down' then
love.graphics.print("P1 DOWN: " .. string.upper(p1control.down), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5)
elseif button.text == '2down' then
elseif button.text == '2down' then
love.graphics.print("P2 DOWN: " .. string.upper(p2control.down), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5)
elseif button.text == '1special' then
elseif button.text == '1special' then
love.graphics.print("P1 SPECIAL: " .. string.upper(p1control.super), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5)
elseif button.text == '2special' then
elseif button.text == '2special' then
love.graphics.print("P2 SPECIAL: " .. string.upper(p2control.super), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5)
elseif button.text == '1ct' then
elseif button.text == '1ct' then
love.graphics.print("P1 COUNTER: " .. string.upper(p1control.counter), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5)
elseif button.text == '2ct' then
love.graphics.print("P2 COUNTER: " .. string.upper(p2control.counter), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5)
else
love.graphics.print(button.text, smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5)
love.graphics.print(button.text, smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5)
end
cursor_y = cursor_y + (ev_BUTTON_HEIGHT + margin)
else
if (button.text == '1v1') then
love.graphics.print(playertext, smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, by+textH*0.5)
elseif button.text == 'snc' then
if (nuckemodactive == 1) then
textW = smallfont:getWidth(synctext)
love.graphics.setColor(1,0,0,1)
love.graphics.print(synctext, smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5)
love.graphics.setColor(1,1,1,1)
love.graphics.print(synctext, smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5)
love.graphics.setColor(0,0,0,1)
else
textW = smallfont:getWidth(synctext)
love.graphics.print(synctext, smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5)
end
elseif (button.text == 'ballCount') then
local tempstr = "Ball Count: " .. maxBalls
textW = smallfont:getWidth(tempstr)
love.graphics.print("Ball Count: " .. maxBalls, smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5)
elseif (button.text == "Ball Speed: ") then
if (nuckemodactive == 1) then
love.graphics.setColor(1,0,0,1)
love.graphics.print("shaitan machina", smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5)
love.graphics.setColor(1,1,1,1)
love.graphics.print("shaitan machina", smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5)
love.graphics.setColor(0,0,0,1)
else
textW = smallfont:getWidth(button.text .. ballSet)
love.graphics.print(button.text .. ballSet, smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5)
end
elseif button.text == 'ptw' then
local tempstr = "Points to Win: " .. ptw
textW = smallfont:getWidth(tempstr)
love.graphics.print("Points to Win: " .. ptw, smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5)
elseif (button.text == 'Silverblade') then
local tempstr = "Difficulty: " .. prtext
textW = smallfont:getWidth(tempstr)
love.graphics.print("Difficulty: " .. prtext, smallfont,ev_bx + ev_button_width*0.5 - textW*0.5 , ev_by+textH*0.5)
if (button.text == '1v1') then
love.graphics.print(playertext, smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, by+textH*0.5)
elseif button.text == 'snc' then
if (nuckemodactive == 1) then
textW = smallfont:getWidth(synctext)
love.graphics.setColor(1,0,0,1)
love.graphics.print(synctext, smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5)
love.graphics.setColor(1,1,1,1)
love.graphics.print(synctext, smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5)
love.graphics.setColor(0,0,0,1)
else
love.graphics.print(button.text, smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5)
textW = smallfont:getWidth(synctext)
love.graphics.print(synctext, smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5)
end
love.graphics.setColor(255, 255, 255, 255)
cursor_y = cursor_y + (ev_BUTTON_HEIGHT + margin)
elseif (button.text == 'ballCount') then
local tempstr = "Ball Count: " .. maxBalls
textW = smallfont:getWidth(tempstr)
love.graphics.print("Ball Count: " .. maxBalls, smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5)
elseif (button.text == "Ball Speed: ") then
if (nuckemodactive == 1) then
love.graphics.setColor(1,0,0,1)
love.graphics.print("shaitan machina", smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5)
love.graphics.setColor(1,1,1,1)
love.graphics.print("shaitan machina", smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5)
love.graphics.setColor(0,0,0,1)
else
textW = smallfont:getWidth(button.text .. ballSet)
love.graphics.print(button.text .. ballSet, smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5)
end
end
elseif button.text == 'ptw' then
local tempstr = "Points to Win: " .. ptw
textW = smallfont:getWidth(tempstr)
love.graphics.print("Points to Win: " .. ptw, smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5)
elseif (button.text == 'Silverblade') then
local tempstr = "Difficulty: " .. prtext
textW = smallfont:getWidth(tempstr)
love.graphics.print("Difficulty: " .. prtext, smallfont,ev_bx + ev_button_width*0.5 - textW*0.5 , ev_by+textH*0.5)
else
love.graphics.print(button.text, smallfont, ev_bx + ev_button_width*0.5 - textW*0.5, ev_by+textH*0.5)
end
love.graphics.setColor(255, 255, 255, 255)
cursor_y = cursor_y + (ev_BUTTON_HEIGHT + margin)
end
end
end
end
end
function mainMenu:addButton(text, fn)
if isButtonAnimated == true then
print("Button shall be animated!")


+ 1
- 0
readme.md View File

@@ -25,6 +25,7 @@ To play on Windows, download a Windows executable from the releases tab!
<li>Fixed button animations</li>
<li>Fixed demo and editor not working together</li>
<li>Removed a lot of clutter</li>
<li>Added LowPOWER mode to improve FPS on low-end devices</li>
</ul>
ToDo:
<ul>


+ 0
- 0
save.lua View File


+ 21
- 25
src/baseGame.lua View File

@@ -641,7 +641,11 @@ function normalDraw()
love.graphics.clear(1, 1, 1, 1)
else
love.graphics.clear(40 / 255, 40 / 255, 40 / 255, 1)
love.graphics.draw(background, 0, -backgroundScroll)
if (lowcpu) then
--love.graphics.draw(background, 0,0)
else
love.graphics.draw(background, 0,-backgroundScroll)
end
end
if gameState == "assign" then
love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255)
@@ -715,8 +719,7 @@ function menuDraw()
love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, 0, 10, VIRTUAL_HEIGHT * 0.3)
love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, VIRTUAL_HEIGHT * 0.7, 10, VIRTUAL_HEIGHT * 0.3)
love.graphics.setColor(1, 1, 1, 1)
end
if MAP_TYPE == 2 then
elseif MAP_TYPE == 2 then
for i, wall in ipairs(walls) do
love.graphics.setColor(1, 1, 1, 1)
love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
@@ -734,28 +737,22 @@ function menuDraw()
love.graphics.setFont(smallfont)
love.graphics.printf("The green zones are for moving up and down, double tap the red zone for special attack or to start the serve.", 10, 150, VIRTUAL_WIDTH, "center")
love.graphics.printf("Swipe from red to green for stopping time", 10, 450, VIRTUAL_WIDTH, "center")
end
if gameState == "windowsettings" then
elseif gameState == "windowsettings" then
mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, settings, sounds, "right")
love.keyboard.mouseisReleased = false
end
if gameState == "editor" then
elseif gameState == "editor" then
mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, editorpicks, sounds, "right")
love.keyboard.mouseisReleased = false
end
if gameState == "speedSettings" then
elseif gameState == "speedSettings" then
mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, speedParameters, sounds, "middle")
love.keyboard.mouseisReleased = false
end
if gameState == "controlSettings" then
elseif gameState == "controlSettings" then
mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, controlSettings, sounds, "control")
love.keyboard.mouseisReleased = false
end
if gameState == "gameMode" then
elseif gameState == "gameMode" then
mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, modeSelectorButtons, sounds, "middle")
love.keyboard.mouseisReleased = false
end
if gameState == "chooseIP" then
elseif gameState == "chooseIP" then
IPselect = {}
if isAndroid then
table.insert(
@@ -839,24 +836,19 @@ function menuDraw()
love.graphics.printf(IPnew, 0, VIRTUAL_HEIGHT / 4, VIRTUAL_WIDTH, "center")
end
love.keyboard.mouseisReleased = false
end
if gameState == "menu" then
elseif gameState == "menu" then
mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds, "middle")
love.keyboard.mouseisReleased = false
end
if gameState == "difficulty" then
elseif gameState == "difficulty" then
mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, difbuttons, sounds, "middle")
love.keyboard.mouseisReleased = false
end
if gameState == "multiMode" then
elseif gameState == "multiMode" then
mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, playerCountButtons, sounds, "middle")
love.keyboard.mouseisReleased = false
end
if gameState == "prdiff" then
elseif gameState == "prdiff" then
mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, pracdiff, sounds, "playercount")
love.keyboard.mouseisReleased = false
end
if gameState == 'start' then
elseif gameState == 'start' then
love.graphics.push()
love.graphics.translate(VIRTUAL_WIDTH * 0.4, VIRTUAL_HEIGHT * 0.5)
love.graphics.rotate(rotation)
@@ -873,7 +865,11 @@ function menuDraw()
end
function baseDraw()
love.graphics.setColor(255, 255, 255, 1)
if (lowcpu) then
-- love.graphics.draw(background, 0,0)
else
love.graphics.draw(background, 0,-backgroundScroll)
end

if shakeDuration > t then


Loading…
Cancel
Save