This commit is contained in:
SweetSea-ButImNotSweet
2024-05-13 17:27:51 +07:00
parent 940e17eff7
commit f5584b5df7
6 changed files with 66 additions and 38 deletions

View File

@@ -991,20 +991,26 @@ function GameMode:drawLinesStats(left, top)
local lines = self.total_lines
if lines == 0 then lines = 1 end
drawText("Lines Bonus: ", left+15, top+10, 1000, "left")
--drawText(string.format("+ %4d %3d%%", self.lineClearPoints[self.lines_cleared], (self.score_totals['lines']/(self.lineClearPoints[4]*math.ceil(lines/4)))*100), left+15, top+25, 1000, "left")
-- drawText(string.format("+ %4d %3d%%", self.lineClearPoints[self.lines_cleared], (self.score_totals['lines']/(self.lineClearPoints[4]*math.ceil(lines/4)))*100), left+15, top+25, 1000, "left")
drawText(string.format("2 x Lines = %d\n3 x Lines = %d\n4 x Lines = %d", self.lineClearPoints[2], self.lineClearPoints[3], self.lineClearPoints[4]), left+15, top+25, 1000, "left")
end
function GameMode:drawScoringInfo()
-- Name & Grade
love.graphics.setColor(0,0,0,0.5)
love.graphics.rectangle("fill", 98, 83, 110, 180, 10, 10) --name, grade
love.graphics.setColor(0,0,0,0.5)
love.graphics.rectangle("fill", 241, 407, 116, 40, 5, 5) --lines
love.graphics.rectangle("fill", 98, 83, 110, 180, 10, 10)
love.graphics.setColor(0.05,0.05,0.05,1)
love.graphics.rectangle("fill", 239, 405, 116, 40, 5, 5) --lines
love.graphics.rectangle("fill", 95, 80, 110, 180, 10, 10) --name, grade
drawText(string.format("Level: %2d\nLines: %3d/300", self:getBackground(), self.total_lines), 249, 408, 1000, "left")
love.graphics.rectangle("fill", 95, 80, 110, 180, 10, 10)
if not PENTO_MODE then drawText("Grade:", 100, 128, 1000, "left") end
-- Line & Level
if self.training or SETTINGS["lines"] then
love.graphics.setColor(0,0,0,0.5)
love.graphics.rectangle("fill", 241, 407, 116, 40, 5, 5) --lines
love.graphics.setColor(0.05,0.05,0.05,1)
love.graphics.rectangle("fill", 239, 405, 116, 40, 5, 5) --lines
drawText(string.format("Level: %2d\nLines: %3d/300", self:getBackground(), self.total_lines), 249, 408, 1000, "left")
end
-- REPLAY
if self.input_playback then
love.graphics.setColor(0,0,0,0.5)
love.graphics.rectangle("fill", 68, 270, 140, 190, 10, 10)
@@ -1013,8 +1019,7 @@ function GameMode:drawScoringInfo()
drawText(string.format("Replay in progress\nRotate Left:\n Pause/Frame Step\nRotate Right:\n Unpause\nLeft:\n Rewind 5 sec\nRight:\n FF 10 secs\n%s", formatTime(self.frames)), 70, 275, 1000, "left")
drawBigText(string.format("%s", self.grade), 100, 143, 1000, "left")
self:drawInputDisplay(103,185)
elseif self.training or PENTO_MODE then
else
elseif not PENTO_MODE then
if math.mod(self.grade_change_flash, 5) ~= 0 then
drawBigText(string.format("%s", self.gradeNames[self.grade]), 100, 143, 1000, "left", self.grade_change_color)
else

View File

@@ -117,13 +117,7 @@ end
local touches={}
local global_toggle=false
VCTRL={}
-- VCTRL.focus=nil -- Focusing buttons
---@param toggle boolean|false
---Enabling virtual control or not
function VCTRL.toggle(toggle)
global_toggle=toggle
end
VCTRL.focus=nil -- Focusing buttons
---@param ... table
---@class data
@@ -144,6 +138,19 @@ function VCTRL.new(...)
end
end
---@param toggle boolean|false
---Enabling virtual control or not
function VCTRL.toggle(toggle)
if not toggle then
-- Release all buttons to prevent ghost keys
for id, b in pairs(touches) do
b:release(id)
touches[id]=nil
end
end
global_toggle=toggle
end
function VCTRL.press(x,y,id)
if not global_toggle then return end
local obj,closestDist=false,1e99

View File

@@ -65,7 +65,7 @@ function love.load()
require "game.vctrl" -- VCTRL
SCENE = SETTINGS.firstTime and InputConfigScene(true) or TitleScene()
VCTRL.toggle(love.system.getOS()=='Android' or true)
-- VCTRL.toggle(love.system.getOS()=='Android' or true)
VCTRL.new{ -- up down left right --- right left down up
-- {type='button',x= 100,y=320,key= 'up',r=35,iconSize=60,alpha=0.75},
-- {type='button',x= 100,y=440,key= 'down',r=35,iconSize=60,alpha=0.75},
@@ -138,14 +138,14 @@ function love.touchpressed(id,x,y)
end
function love.touchdragged(id,x,y,dx,dy)
local x,y=GLOBAL_TRANSFORM:inverseTransformPoint(x,y)
if not VCTRL.press(x,y,id) then
SCENE:onInputMove{type = "touch", x = x, y = y, dx = dx, dy = dy, id = id}
if not VCTRL.drag(x,y,id) then
SCENE:onInputDrag{type = "touch", x = x, y = y, dx = dx, dy = dy, id = id}
end
end
function love.touchreleased(id,x,y)
local x,y=GLOBAL_TRANSFORM:inverseTransformPoint(x,y)
if not VCTRL.release(id) then
SCENE:onInputPress{type = "touch", x = x, y = y, dx = 0, dy = 0, id = id}
SCENE:onInputRelease{type = "touch", x = x, y = y, dx = 0, dy = 0, id = id}
end
end

View File

@@ -6,14 +6,14 @@ function SCENE:new() end
function SCENE:update() end
function SCENE:render() end
-- e in 3 below functions will contain:
-- e in 3 below functions will contain different things based on it's type:
-- key - input, key, scancode
-- joystick - input, button, name
-- virtual - input
-- touch - x, y, dx, dy, id
function SCENE:onInputPress(e) end
function SCENE:onInputMove(e) end
function SCENE:onInputDrag(e) end
function SCENE:onInputRelease(e) end
GameScene = require "scene.game"

View File

@@ -48,8 +48,8 @@ function ReplaySelectScene:render()
drawText('Name - Grade - Score', 40, 20, 1000, "left")
drawText(string.format('Page %s', self.page), 20, 440, 1000, "left")
j = 1
i = 1
local i, j = 1, 1
while i <= #self.replay_text do
if j > self.page_flip then j = 1
elseif j < 1 then j = self.page_flip
@@ -60,6 +60,7 @@ function ReplaySelectScene:render()
j = j + 1
i = i + 1
end
if self.dialog then
love.graphics.setColor(0, 0, 0, 0.5)
love.graphics.rectangle("fill", 23, 43 + 20 * self.replay_select, 65, 40, 5, 5)
@@ -132,6 +133,8 @@ function ReplaySelectScene:onInputPress(e)
player_grade = string.gsub(line_components[2], " ", "")
SCENE = GameScene(player_name, selected_replay, player_grade)
end
elseif e.input == "rotate_right" then
love.system.setClipboardText(love.data.encode("string", "base64", love.filesystem.read('saves/replays/'..selected_replay)))
elseif e.input == "up" or e.scancode == "up" then
if self.replays[1] == nil then scene = TitleScene() end
self.direction = 'up'
@@ -139,7 +142,7 @@ function ReplaySelectScene:onInputPress(e)
if self.replays[1] == nil then scene = TitleScene() end
self.direction = 'down'
elseif e.input == "menu_back" or e.input == "rotate_right" or e.scancode == "backspace" or e.scancode == "delete" then
scene = TitleScene()
SCENE = TitleScene()
end
end

View File

@@ -21,6 +21,7 @@ function TitleScene:new()
self.main_menu_state = 1
PENTO_MODE = false
self.code = {0,0,0,0,0,0,0,0}
VCTRL.toggle(false)
end
function TitleScene:update()
@@ -63,7 +64,7 @@ function TitleScene:render()
drawBigText('Tromi', 30, 180, 120, "left")
drawText('version 2', 110, 193, 120, "left")
self:drawCredits(300, 40)
drawText("mycophobia.org", 20, 405, 1000)
drawText(tostring(self.main_menu_state), 20, 405, 1000)
drawText("Based on Cambridge - t-sp.in/cambridge", 20, 420, 1000)
drawText("Music for Tromi by Jerry Martin, all rights reserved - jerrymartinmusic.com", 20, 435, 1000)
drawText("Game backgrounds by Pixabay users Joe_hackney, yokim, Favorisxp, Any_Ann, VisualSkyFX ", 20, 450, 1000)
@@ -92,18 +93,30 @@ function TitleScene:changeOption(rel)
end
function TitleScene:onInputPress(e)
if e.input == "menu_decide" or e.input == "rotate_left" or e.scancode == "return" then
SCENE = main_menu_screens[self.main_menu_state]()
elseif e.input == "up" or e.scancode == "up" then
self:changeOption(-1)
elseif e.input == "down" or e.scancode == "down" then
self:changeOption(1)
elseif e.input == "left" or e.scancode == "left" then
table.remove(self.code, 8)
table.insert(self.code, 1, -1)
elseif e.input == "right" or e.scancode == "right" then
table.remove(self.code, 8)
table.insert(self.code, 1, 1)
if e.type == "touch" then
local selecting = math.floor((e.y - 198) / 20)
if selecting > 0 and selecting <= #main_menu_screens then
if self.main_menu_state ~= selecting then
self.main_menu_state = selecting
else
VCTRL.toggle(true)
SCENE = main_menu_screens[selecting]()
end
end
else
if e.input == "menu_decide" or e.input == "rotate_left" or e.scancode == "return" then
SCENE = main_menu_screens[self.main_menu_state]()
elseif e.input == "up" or e.scancode == "up" then
self:changeOption(-1)
elseif e.input == "down" or e.scancode == "down" then
self:changeOption(1)
elseif e.input == "left" or e.scancode == "left" then
table.remove(self.code, 8)
table.insert(self.code, 1, -1)
elseif e.input == "right" or e.scancode == "right" then
table.remove(self.code, 8)
table.insert(self.code, 1, 1)
end
end
end