begin function for drawing title screen

This commit is contained in:
2025-02-19 04:07:27 +00:00
parent 6ca2d379f7
commit dab81e3904
4 changed files with 39 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
structure Constants =
struct
val fontSpace = 13
val fontSize: Real32.real = 30.0
val fontSpace = 26
val fontSize: Real32.real = 60.0
val worldWidth = 1920
val worldHeight = 1080

23
fcore/title/title-vec.sml Normal file
View File

@@ -0,0 +1,23 @@
structure TitleVec =
struct
val fontSpace = Constants.fontSpace
val fontSize = Constants.fontSize
fun getTextVec (x, y, windowWidth, windowHeight, pos, str, acc) =
if pos = String.size str then
Vector.concat acc
else
let
val chr = String.sub (str, pos)
val chrFun = Vector.sub (CozetteAscii.asciiTable, Char.ord chr)
val hd = chrFun
(x, y, fontSize, fontSize, windowWidth, windowHeight, 0.0, 0.0, 0.0)
val acc = hd :: acc
in
getTextVec
(x + fontSpace, y, windowWidth, windowHeight, pos + 1, str, acc)
end
fun getDrawVec (title: TitleType.title_type, width, height) =
getTextVec (555, 55, width, height, 0, "hello world", [])
end

View File

@@ -1,8 +1,6 @@
$(SML_LIB)/basis/basis.mlb
(* fcore *)
vendored/cozette-sml/fonts/cozette-ascii.mlb
fcore/constants.sml
fcore/level/collision.sml
@@ -18,6 +16,7 @@ fcore/bin-vec.sml
ann
"allowVectorExps true"
in
vendored/cozette-sml/fonts/cozette-ascii.mlb
fcore/block.sml
fcore/level/player/player-sprite.sml
fcore/field.sml
@@ -56,6 +55,7 @@ fcore/level/level-update.sml
fcore/title/title-type.sml
fcore/title/title-update.sml
fcore/title/title-vec.sml
fcore/game-type.sml
fcore/game-update.sml

View File

@@ -250,13 +250,24 @@ struct
shellState
end
fun drawTitle (shellState: t, title) =
let
val width = InputState.getWidth ()
val height = InputState.getHeight ()
val vec = TitleVec.getDrawVec (title, width, height)
val shellState = uploadPlayer (shellState, vec)
val () = helpDrawLevel shellState
in
shellState
end
fun drawMode (shellState: t, game: GameType.game_type) =
let
open GameType
in
case #mode game of
LEVEL level => drawLevel (shellState, level)
| TITLE title => shellState
| TITLE title => drawTitle (shellState, title)
end
fun helpLoop (shellState as {window, ...}: t, game) =