mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
V1 update (#1)
This commit is contained in:
committed by
Squishy (C6H12O6+NaCl+H2O)
parent
3343d8711b
commit
1d6643448e
@@ -3,33 +3,37 @@ NameEntryScene.title = "Game Start"
|
||||
|
||||
local buttonList = {
|
||||
BUTTON.new{
|
||||
text = "←\nCHAR", font = FONT_big,
|
||||
text = "↑\nCHAR", font = FONT_big,
|
||||
x = 25, y = 120, w = 80, h = 80,
|
||||
codeWhenPressed = function() SCENE:onInputPress {input = "left"} end,
|
||||
codeWhenReleased = function() SCENE:onInputRelease{input = "left"} end,
|
||||
},
|
||||
BUTTON.new{
|
||||
text = "→\nCHAR", font = FONT_big,
|
||||
text = "↓\nCHAR", font = FONT_big,
|
||||
x = 115, y = 120, w = 80, h = 80,
|
||||
codeWhenPressed = function() SCENE:onInputPress {input = "right"} end,
|
||||
codeWhenReleased = function() SCENE:onInputRelease{input = "right"} end,
|
||||
},
|
||||
BUTTON.new{
|
||||
text = "↑\nESC", font = FONT_big,
|
||||
text = "←\nESC", font = FONT_big,
|
||||
x = 25, y = 210, w = 80, h = 80,
|
||||
codeWhenPressed = function() SCENE:onInputPress {input = "menu_back"} end,
|
||||
codeWhenReleased = function() SCENE:onInputRelease{input = "menu_back"} end,
|
||||
},
|
||||
BUTTON.new{
|
||||
text = "↓\nENTER", font = FONT_big,
|
||||
text = "→\nENTER", font = FONT_big,
|
||||
x = 115, y = 210, w = 80, h = 80,
|
||||
codeWhenPressed = function() SCENE:onInputPress {input = "menu_decide"} end,
|
||||
codeWhenReleased = function() SCENE:onInputRelease{input = "menu_decide"} end,
|
||||
},
|
||||
BUTTON.new{
|
||||
text = CHAR.key.keyboard.." Open OSK", font = FONT_big,
|
||||
x = 25, y = 300, w = 170, h = 40,
|
||||
codeWhenReleased = function() love.keyboard.setTextInput(true, 215, 175, 160, 160) end
|
||||
}
|
||||
}
|
||||
|
||||
local Grid = require 'game.grid'
|
||||
local bitser = require 'libs.bitser'
|
||||
|
||||
function NameEntryScene:new()
|
||||
VCTRL.toggle(false)
|
||||
@@ -61,7 +65,6 @@ function NameEntryScene:new()
|
||||
self.hi_scores = {"TRO",0,"MIT",0,"ROM",0,"ITR",0,"OMI",0}
|
||||
end
|
||||
end
|
||||
|
||||
function NameEntryScene:drawGradeList(left, top)
|
||||
love.graphics.setColor(0,0,0,0.5)
|
||||
love.graphics.rectangle("fill", left+3, top+3, 200, 240, 10, 10)
|
||||
@@ -97,10 +100,8 @@ function NameEntryScene:render()
|
||||
love.graphics.setColor(0.05,0.05,0.05,1)
|
||||
love.graphics.rectangle("fill", 397, 292, 130, 130, 10, 10)
|
||||
drawText("Best scores:", 410, 297, 1000, "left")
|
||||
i = 2
|
||||
while i <= 10 do
|
||||
for i = 2, 10, 2 do
|
||||
drawText(self.hi_scores[i-1]..' - '..self.hi_scores[i], 410, 297+(i*10), 1000, "left")
|
||||
i = i + 2
|
||||
end
|
||||
if self.entry_pos == 4 then
|
||||
drawText('Press confirm\nto play', 255, 290, 1000)
|
||||
@@ -138,28 +139,43 @@ function NameEntryScene:onInputMove(e)
|
||||
end
|
||||
end
|
||||
|
||||
function NameEntryScene:getPlayInfo(player_name)
|
||||
if love.filesystem.getInfo((SAVE_DIR..player_name.."_grade_history.sav")) then
|
||||
grade_history = FILE.read(SAVE_DIR..player_name.."_grade_history.sav")
|
||||
self.grade = grade_history[1]
|
||||
self.wins = grade_history[2]
|
||||
self.plays = grade_history[4]
|
||||
else
|
||||
self.grade, self.win, self.plays = 0, 0, 0
|
||||
end
|
||||
return self.grade, self.win, self.plays
|
||||
end
|
||||
function NameEntryScene:onInputPress(e)
|
||||
local name = string.lower(self.name_entry[1]..self.name_entry[2]..self.name_entry[3])
|
||||
if e.type == "mouse" or e.type == "touch" then
|
||||
BUTTON.press(buttonList, e.x, e.y, e.id)
|
||||
elseif e.key and #e.key == 1 then
|
||||
local pos = string.find("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.", string.upper(e.key), 1, true)
|
||||
if pos then
|
||||
if self.entry_pos <= 3 then
|
||||
self.char_pos = pos
|
||||
self.name_entry[self.entry_pos] = string.upper(e.key)
|
||||
self.name_entry[self.entry_pos + 1] = string.upper(e.key)
|
||||
end
|
||||
if self.entry_pos == 3 then self:getPlayInfo(name) end
|
||||
self.entry_pos = math.min(self.entry_pos + 1, 4)
|
||||
end
|
||||
elseif e.input == "menu_decide" or e.input == "rotate_left" or e.scancode == "return" then
|
||||
if self.entry_pos == 4 then
|
||||
BUTTON.release(buttonList, e.x, e.y, e.id)
|
||||
SETTINGS['last_entry'] = name:upper()
|
||||
SCENE = GameScene(name:lower())
|
||||
else
|
||||
if self.entry_pos == 3 then
|
||||
name = string.lower(self.name_entry[1]..self.name_entry[2]..self.name_entry[3])
|
||||
if love.filesystem.getInfo((SAVE_DIR..name.."_grade_history.sav")) then
|
||||
grade_history = FILE.read(SAVE_DIR..name.."_grade_history.sav")
|
||||
self.grade = grade_history[1]
|
||||
self.wins = grade_history[2]
|
||||
self.plays = grade_history[4]
|
||||
end
|
||||
end
|
||||
if self.entry_pos < 3 then
|
||||
self.name_entry[self.entry_pos] = self.chars:sub(self.char_pos, self.char_pos)
|
||||
self.name_entry[self.entry_pos+1] = self.chars:sub(self.char_pos, self.char_pos)
|
||||
end
|
||||
if self.entry_pos == 3 then self:getPlayInfo(name)
|
||||
else
|
||||
self.name_entry[self.entry_pos ] = self.chars:sub(self.char_pos, self.char_pos)
|
||||
self.name_entry[self.entry_pos+1] = self.chars:sub(self.char_pos, self.char_pos)
|
||||
end
|
||||
self.entry_pos = self.entry_pos + 1
|
||||
end
|
||||
elseif e.input == "left" or e.scancode == "left" then
|
||||
|
||||
Reference in New Issue
Block a user