From a0168322339924d87dcb9f191201a55307783bf8 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Fri, 29 Aug 2025 10:42:46 +0100 Subject: [PATCH] remove dead code --- fcore/field.sml | 26 ----- fcore/level/chain-edge.sml | 49 --------- fcore/level/player/player.sml | 174 ------------------------------ fcore/level/player/whip.sml | 197 ---------------------------------- fcore/level/projectile.sml | 58 ---------- oms.mlb | 4 - shell/gl-draw.sml | 9 +- 7 files changed, 1 insertion(+), 516 deletions(-) delete mode 100644 fcore/field.sml delete mode 100644 fcore/level/chain-edge.sml delete mode 100644 fcore/level/player/whip.sml delete mode 100644 fcore/level/projectile.sml diff --git a/fcore/field.sml b/fcore/field.sml deleted file mode 100644 index f68edd3..0000000 --- a/fcore/field.sml +++ /dev/null @@ -1,26 +0,0 @@ -structure Field = -struct - fun lerp (startX, startY, drawWidth, drawHeight, windowWidth, windowHeight - , r, g, b, a) : Real32.real vector = - let - val endY = windowHeight - startY - val startY = windowHeight - (startY + drawHeight) - val endX = startX + drawWidth - val windowHeight = windowHeight / 2.0 - val windowWidth = windowWidth / 2.0 - in - #[ (((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0, - (((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0, r, g, b, a, - (((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0, - (((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0, r, g, b, a, - (((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0, - (((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0, r, g, b, a, - (((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0, - (((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0, r, g, b, a, - (((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0, - (((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0, r, g, b, a, - (((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0, - (((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0, r, g, b, a - ] - end -end diff --git a/fcore/level/chain-edge.sml b/fcore/level/chain-edge.sml deleted file mode 100644 index 0720788..0000000 --- a/fcore/level/chain-edge.sml +++ /dev/null @@ -1,49 +0,0 @@ -structure ChainEdgeRight = -struct - fun lerp (startX, startY, drawWidth, drawHeight, windowWidth, windowHeight, r, g, b) : Real32.real vector = - let - val endY = windowHeight - startY - val startY = windowHeight - (startY + drawHeight) - val endX = startX + drawWidth - val windowHeight = windowHeight / 2.0 - val windowWidth = windowWidth / 2.0 - in - #[ (((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0, - (((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0, - r, g, b, - - (((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0, - (((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0, - r, g, b, - - (((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0, - (((startY * (1.0 - 0.485714316368)) + (endY * 0.485714316368)) / windowHeight) - 1.0, - r, g, b - ] - end -end - -structure ChainEdgeLeft = -struct - fun lerp (startX, startY, drawWidth, drawHeight, windowWidth, windowHeight, r, g, b) : Real32.real vector = - let - val endY = windowHeight - startY - val startY = windowHeight - (startY + drawHeight) - val endX = startX + drawWidth - val windowHeight = windowHeight / 2.0 - val windowWidth = windowWidth / 2.0 - in - #[ (((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0, - (((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0, - r, g, b, - - (((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0, - (((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0, - r, g, b, - - (((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0, - (((startY * (1.0 - 0.485714316368)) + (endY * 0.485714316368)) / windowHeight) - 1.0, - r, g, b - ] - end -end diff --git a/fcore/level/player/player.sml b/fcore/level/player/player.sml index 3e87ad3..3a4249c 100644 --- a/fcore/level/player/player.sml +++ b/fcore/level/player/player.sml @@ -448,178 +448,4 @@ struct in PlayerPatch.withPatches (player, patches) end - - (*** DRAWING FUNCTIONS ***) - fun helpGetWhipVec - (tlx, tly, ratio, xOffset, yOffset, pos, boxes, width, height, acc) = - if pos = Vector.length boxes then - Vector.concat acc - else - let - val {x, y} = Vector.sub (boxes, pos) - val x = tlx + x - val y = tly + y - - val x = Real32.fromInt x * ratio + xOffset - val y = Real32.fromInt y * ratio + yOffset - - val size = Whip.sizeReal - val acc = Box.lerp (x, y, size, size, width, height) :: acc - in - helpGetWhipVec - ( tlx - , tly - , ratio - , xOffset - , yOffset - , pos + 1 - , boxes - , width - , height - , acc - ) - end - - fun getFieldVec (player: player, width, height) = - case #mainAttack player of - MAIN_ATTACKING frame => - let - val {x, y, facing, ...} = player - val wratio = width / Constants.worldWidthReal - val hratio = height / Constants.worldHeightReal - in - if wratio < hratio then - let - val scale = Constants.worldHeightReal * wratio - val yOffset = - if height > scale then (height - scale) / 2.0 - else if height < scale then (scale - height) / 2.0 - else 0.0 - - val boxes = - case facing of - FACING_RIGHT => Vector.sub (Whip.rightFrames, frame) - | FACING_LEFT => Vector.sub (Whip.leftFrames, frame) - in - helpGetWhipVec - (x, y, wratio, 0.0, yOffset, 0, boxes, width, height, []) - end - else - let - val scale = Constants.worldWidthReal * hratio - val xOffset = - if width > scale then (width - scale) / 2.0 - else if width < scale then (scale - width) / 2.0 - else 0.0 - - val boxes = - case facing of - FACING_RIGHT => Vector.sub (Whip.rightFrames, frame) - | FACING_LEFT => Vector.sub (Whip.leftFrames, frame) - in - helpGetWhipVec - (x, y, hratio, xOffset, 0.0, 0, boxes, width, height, []) - end - end - | _ => Vector.fromList [] - - fun helpGetPelletVec - ( playerX - , playerY - , pos - , enemies - , width - , height - , ratio - , xOffset - , yOffset - , acc - ) = - if pos = Vector.length enemies then - Vector.concat acc - else - let - val {angle} = Vector.sub (enemies, pos) - (* convert degrees to radians *) - val angle = degreesToRadians angle - - (* calculate pellet's x and y *) - val pelletX = - ((Real32.Math.cos angle) * Constants.projectileDistance) + playerX - val pelletX = pelletX * ratio + xOffset - - val pelletY = - ((Real32.Math.sin angle) * Constants.projectileDistance) + playerY - val pelletY = pelletY * ratio + yOffset - - val defeatedSize = Constants.projectileSize * ratio - - val vec = Field.lerp - ( pelletX - , pelletY - , defeatedSize - , defeatedSize - , width - , height - , 0.3 - , 0.9 - , 0.3 - , 1.0 - ) - val acc = vec :: acc - in - helpGetPelletVec - ( playerX - , playerY - , pos + 1 - , enemies - , width - , height - , ratio - , xOffset - , yOffset - , acc - ) - end - - fun getPelletVec (player: player, width, height) = - if Vector.length (#enemies player) = 0 then - Vector.fromList [] - else - let - val {x, y, enemies, ...} = player - - (* get centre (x, y) coordinates of player *) - val halfProjectileSize = Constants.projectileSize / 2.0 - val diffX = Constants.halfPlayerWidthReal - halfProjectileSize - val diffY = Constants.halfPlayerHeightReal - halfProjectileSize - val x = Real32.fromInt x + diffX - val y = Real32.fromInt y + diffY - - val wratio = width / Constants.worldWidthReal - val hratio = height / Constants.worldHeightReal - in - if wratio < hratio then - let - val scale = Constants.worldHeightReal * wratio - val yOffset = - if height > scale then (height - scale) / 2.0 - else if height < scale then (scale - height) / 2.0 - else 0.0 - in - helpGetPelletVec - (x, y, 0, enemies, width, height, wratio, 0.0, yOffset, []) - end - else - let - val scale = Constants.worldWidthReal * hratio - val xOffset = - if width > scale then (width - scale) / 2.0 - else if width < scale then (scale - width) / 2.0 - else 0.0 - in - helpGetPelletVec - (x, y, 0, enemies, width, height, hratio, xOffset, 0.0, []) - end - end end diff --git a/fcore/level/player/whip.sml b/fcore/level/player/whip.sml deleted file mode 100644 index 459a47f..0000000 --- a/fcore/level/player/whip.sml +++ /dev/null @@ -1,197 +0,0 @@ -structure Whip = -struct - type box = {x: int, y: int} - val size = 16 - val sizeReal: Real32.real = 16.0 - - (* right frames *) - val rf1 = - #[ ] - - val rf2 = - #[ ] - - val rf3 = - #[ ] - - val rf4 = - #[ ] - - val rf5 = - #[ - ] - - val rf6 = - #[ ] - - val rf7 = - #[ ] - - val rf8 = - #[ ] - - val rf9 = - #[ ] - - val rf10 = - #[ ] - - val rf11 = - #[ ] - - val rf12 = - #[ - ] - - val rf13 = - #[ - ] - - val rf14 = - #[ - ] - - val rf15 = - #[ - ] - - val rf16 = - #[ - ] - - val rf17 = - #[ - ] - - val rf18 = - #[ - ] - - val rf19 = - #[ - ] - - val rf20 = - #[ - ] - - val rf21 = - #[ - ] - - val rf22 = - #[ - ] - - val rf23 = - #[ - ] - - val rf24 = - #[] - - val rightFrames = #[ - rf1, rf2, rf3, rf4, rf5, rf6, rf7, rf8, rf9, rf10, rf11, rf12, rf13, rf14, - rf15, rf16, rf17, rf18, rf19, rf20, rf21, rf22, rf23, rf24, #[], #[] - ] - - (* left frames *) - val lf1 = - #[ ] - - val lf2 = - #[ - ] - - val lf3 = - #[ - ] - - val lf4 = - #[ - ] - - val lf5 = - #[ - ] - - val lf6 = - #[ - ] - - val lf7 = - #[ - ] - - val lf8 = - #[ - ] - - val lf9 = - #[ - ] - - val lf10 = - #[ - ] - - val lf11 = - #[ - ] - - val lf12 = - #[ - ] - - val lf13 = - #[ - ] - - val lf14 = - #[ - ] - - val lf15 = - #[ - ] - - val lf16 = - #[ - ] - - val lf17 = - #[ - ] - - val lf18 = - #[ - ] - - val lf19 = - #[ - ] - - val lf20 = - #[ - ] - - val lf21 = - #[ - ] - - val lf22 = - #[ - ] - - val lf23 = - #[ - ] - - val lf24 = - #[] - - val leftFrames = #[ - lf1, lf2, lf3, lf4, lf5, lf6, lf7, lf8, lf9, lf10, lf11, lf12, lf13, lf14, - lf15, lf16, lf17, lf18, lf19, lf20, lf21, lf22, lf23, lf24, #[], #[] - ] -end diff --git a/fcore/level/projectile.sml b/fcore/level/projectile.sml deleted file mode 100644 index a5176a2..0000000 --- a/fcore/level/projectile.sml +++ /dev/null @@ -1,58 +0,0 @@ -structure Projectile = -struct - fun helpGetProjectileVec - (pos, projectiles, width, height, ratio, xOffset, yOffset, acc) = - if pos = Vector.length projectiles then - Vector.concat acc - else - let - val {x, y, ...} = Vector.sub (projectiles, pos) - - val x = Real32.fromInt x * ratio + xOffset - val y = Real32.fromInt y * ratio + yOffset - - val size = Constants.projectileSize * ratio - - val vec = Field.lerp - (x, y, size, size, width, height, 0.3, 0.9, 0.3, 1.0) - val acc = vec :: acc - in - helpGetProjectileVec - (pos + 1, projectiles, width, height, ratio, xOffset, yOffset, acc) - end - - fun getProjectileVec (player: PlayerType.player, width, height) = - let - val {projectiles, ...} = player - - val wratio = width / 1920.0 - val hratio = height / 1080.0 - in - if wratio < hratio then - let - val scale = 1080.0 * wratio - val yOffset = - if height > scale then (height - scale) / 2.0 - else if height < scale then (scale - height) / 2.0 - else 0.0 - - val xOffset = 0.0 - in - helpGetProjectileVec - (0, projectiles, width, height, wratio, xOffset, yOffset, []) - end - else - let - val scale = 1920.0 * hratio - val xOffset = - if width > scale then (width - scale) / 2.0 - else if width < scale then (scale - width) / 2.0 - else 0.0 - - val yOffset = 0.0 - in - helpGetProjectileVec - (0, projectiles, width, height, hratio, xOffset, yOffset, []) - end - end -end diff --git a/oms.mlb b/oms.mlb index b749cf0..1c8c429 100644 --- a/oms.mlb +++ b/oms.mlb @@ -18,10 +18,7 @@ ann in vendored/cozette-sml/fonts/cozette-ascii.mlb fcore/block.sml - fcore/field.sml fcore/box.sml - fcore/level/chain-edge.sml - fcore/level/player/whip.sml end @@ -155,7 +152,6 @@ end fcore/level/player/player.sml fcore/level/player/player-attack.sml -fcore/level/projectile.sml fcore/level/level-update.sml fcore/title/title-update.sml diff --git a/shell/gl-draw.sml b/shell/gl-draw.sml index a577a0e..6500cb8 100644 --- a/shell/gl-draw.sml +++ b/shell/gl-draw.sml @@ -233,18 +233,11 @@ struct val wallVec = Wall.getDrawVec (#walls level, width, height) val platVec = Platform.getDrawVec (#platforms level, width, height) - val chainVec = Player.getFieldVec (#player level, width, height) val fallingVec = FallingEnemies.getDrawVec (level, width, height) - val wallVec = Vector.concat [wallVec, platVec, chainVec, fallingVec] - - val pelletVec = Player.getPelletVec (#player level, width, height) - val projectileVec = - Projectile.getProjectileVec (#player level, width, height) - val fieldVec = Vector.concat [pelletVec, projectileVec] + val wallVec = Vector.concat [wallVec, platVec, fallingVec] val shellState = uploadWall (shellState, wallVec) val shellState = uploadPlayer (shellState, playerVec) - val shellState = uploadField (shellState, fieldVec) val () = helpDrawLevel shellState in shellState