remove dead code

This commit is contained in:
2025-08-29 10:42:46 +01:00
parent 1d1fed35cf
commit a016832233
7 changed files with 1 additions and 516 deletions

View File

@@ -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