remove dead code
This commit is contained in:
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -448,178 +448,4 @@ struct
|
|||||||
in
|
in
|
||||||
PlayerPatch.withPatches (player, patches)
|
PlayerPatch.withPatches (player, patches)
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
4
oms.mlb
4
oms.mlb
@@ -18,10 +18,7 @@ ann
|
|||||||
in
|
in
|
||||||
vendored/cozette-sml/fonts/cozette-ascii.mlb
|
vendored/cozette-sml/fonts/cozette-ascii.mlb
|
||||||
fcore/block.sml
|
fcore/block.sml
|
||||||
fcore/field.sml
|
|
||||||
fcore/box.sml
|
fcore/box.sml
|
||||||
fcore/level/chain-edge.sml
|
|
||||||
fcore/level/player/whip.sml
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -155,7 +152,6 @@ end
|
|||||||
fcore/level/player/player.sml
|
fcore/level/player/player.sml
|
||||||
fcore/level/player/player-attack.sml
|
fcore/level/player/player-attack.sml
|
||||||
|
|
||||||
fcore/level/projectile.sml
|
|
||||||
fcore/level/level-update.sml
|
fcore/level/level-update.sml
|
||||||
|
|
||||||
fcore/title/title-update.sml
|
fcore/title/title-update.sml
|
||||||
|
|||||||
@@ -233,18 +233,11 @@ struct
|
|||||||
|
|
||||||
val wallVec = Wall.getDrawVec (#walls level, width, height)
|
val wallVec = Wall.getDrawVec (#walls level, width, height)
|
||||||
val platVec = Platform.getDrawVec (#platforms 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 fallingVec = FallingEnemies.getDrawVec (level, width, height)
|
||||||
val wallVec = Vector.concat [wallVec, platVec, chainVec, fallingVec]
|
val wallVec = Vector.concat [wallVec, platVec, fallingVec]
|
||||||
|
|
||||||
val pelletVec = Player.getPelletVec (#player level, width, height)
|
|
||||||
val projectileVec =
|
|
||||||
Projectile.getProjectileVec (#player level, width, height)
|
|
||||||
val fieldVec = Vector.concat [pelletVec, projectileVec]
|
|
||||||
|
|
||||||
val shellState = uploadWall (shellState, wallVec)
|
val shellState = uploadWall (shellState, wallVec)
|
||||||
val shellState = uploadPlayer (shellState, playerVec)
|
val shellState = uploadPlayer (shellState, playerVec)
|
||||||
val shellState = uploadField (shellState, fieldVec)
|
|
||||||
val () = helpDrawLevel shellState
|
val () = helpDrawLevel shellState
|
||||||
in
|
in
|
||||||
shellState
|
shellState
|
||||||
|
|||||||
Reference in New Issue
Block a user