Skip to content

Commit

Permalink
Implement name entry
Browse files Browse the repository at this point in the history
  • Loading branch information
irismessage committed Apr 27, 2022
1 parent 86895d4 commit 1da7244
Showing 1 changed file with 51 additions and 8 deletions.
59 changes: 51 additions & 8 deletions cart/bros.p8
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ __lua__
--2 custom font system
--3 top bar rendering

-- game
g = {
score=0,
coins=0,
Expand All @@ -23,29 +24,40 @@ g = {
wep=0,
}

-- player
p = {
x=0,
y=0,
r=1,
jump=0,
}

-- name entry
e = {
ords={97,97,97},
chrs={"a","a","a"},
curs=1,
}

scoresn={}
scoresc={}

function _init()
load_font()
loadfont()
loadscores()
--mainscreen()
scorescreen()
-- mainscreen()
-- scorescreen()
askname()
end

function _update()
--g.timer -= 1
-- g.timer -= 1
updatenameentry()
end

function _draw()
scorebarl()
drawnameentry()
end

function mainscreen()
Expand Down Expand Up @@ -83,7 +95,8 @@ function initscores()
dset(i,0)
end
for i=11,20 do
dset(i,packname(" "))
default = packname(" ")
dset(i,default)
end
end
end
Expand Down Expand Up @@ -140,10 +153,40 @@ function shiftscores(rank)
end

function askname()
--todo implement
cls(1)
scorebars()
print("great score",42,40)
print("enter your name",34,56)
return "abc"
end

function drawnameentry()
rectfill(58,72,70,86,1)
color(15)
for i=1,3 do
print(e.chrs[i],54+4*i,72)
end
print(":",54+4*e.curs,80)
end

function updatenameentry()
c = e.curs
if btnp(➡️) and c < 3 then
e.curs += 1
end
if btnp(⬅️) and 1 < c then
e.curs -= 1
end
if btnp(⬆️) and e.ords[c]<122 then
e.ords[c] += 1
e.chrs[c] = chr(e.ords[c])
end
if btnp(⬇️) and 97<e.ords[c] then
e.ords[c] -= 1
e.chrs[c] = chr(e.ords[c])
end
end

function savescore(num)
rank = rankscore(num)
if (rank == 10) return
Expand Down Expand Up @@ -202,8 +245,8 @@ function fblock(src, dest, len)
end
end

function load_font()
--load custom font from sprite
function loadfont()
-- load custom font from sprite
-- sheet and activate it

--letters
Expand Down

0 comments on commit 1da7244

Please sign in to comment.