From dab81e3904a820a605dc1013e50ae1865b36064f Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Wed, 19 Feb 2025 04:07:27 +0000 Subject: [PATCH] begin function for drawing title screen --- fcore/constants.sml | 4 ++-- fcore/title/title-vec.sml | 23 +++++++++++++++++++++++ oms.mlb | 4 ++-- shell/gl-draw.sml | 13 ++++++++++++- 4 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 fcore/title/title-vec.sml diff --git a/fcore/constants.sml b/fcore/constants.sml index 9202f5c..104b3a5 100644 --- a/fcore/constants.sml +++ b/fcore/constants.sml @@ -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 diff --git a/fcore/title/title-vec.sml b/fcore/title/title-vec.sml new file mode 100644 index 0000000..3ccc30a --- /dev/null +++ b/fcore/title/title-vec.sml @@ -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 diff --git a/oms.mlb b/oms.mlb index a291493..d2d2471 100644 --- a/oms.mlb +++ b/oms.mlb @@ -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 diff --git a/shell/gl-draw.sml b/shell/gl-draw.sml index f432b43..785d393 100644 --- a/shell/gl-draw.sml +++ b/shell/gl-draw.sml @@ -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) =