allow player to have a different width/height that is not a perfect square, (now we have Constants.playerWidth and Constants.playerHeight, having deleted the previous size in Constants.playerSize)

This commit is contained in:
2025-02-18 12:31:22 +00:00
parent e62493ce56
commit d3200745d0
7 changed files with 270 additions and 88 deletions

View File

@@ -6,10 +6,13 @@ struct
val worldHeightReal: Real32.real = 1080.0 val worldHeightReal: Real32.real = 1080.0
(* constants for player *) (* constants for player *)
val playerSize = 32 val playerWidth = 32
val playerSizeReal: Real32.real = 32.0 val playerHeight = 40
val halfPlayerSize = 16 val playerWidthReal: Real32.real = 32.0
val halfPlayerSizeReal: Real32.real = 16.0 val playerHeightReal: Real32.real = 40.0
val halfPlayerWidthReal: Real32.real = 16.0
val halfPlayerHeightReal: Real32.real = 20.0
val movePlayerBy = 5 val movePlayerBy = 5
(* player timing values *) (* player timing values *)

View File

@@ -3,35 +3,6 @@ struct
open EnemyType open EnemyType
open EntityType open EntityType
(* if player is attacking, does enemy collide with attack? *)
fun isCollidingWithPlayerAttack (player: PlayerType.player, enemy: enemy) =
let
val {x = px, y = py, facing, mainAttack, ...} = player
val pSize = Constants.playerSize
val {x = ex, y = ey, ...} = enemy
val eSize = Constants.enemySize
in
case mainAttack of
PlayerType.MAIN_ATTACKING {length, ...} =>
(case facing of
FACING_RIGHT =>
let
val px = px + pSize
in
Collision.isCollidingPlus
(px, py, length, pSize, ex, ey, eSize, eSize)
end
| FACING_LEFT =>
let
val px = px - length
in
Collision.isCollidingPlus
(px, py, length, pSize, ex, ey, eSize, eSize)
end)
| _ => false
end
fun canWalkAhead (x, y, wallTree, platformTree) = fun canWalkAhead (x, y, wallTree, platformTree) =
let let
val y = y + Constants.enemySize - 5 val y = y + Constants.enemySize - 5
@@ -351,8 +322,8 @@ struct
fun isInFollowRange (player, enemy) = fun isInFollowRange (player, enemy) =
let let
val {x = px, y = py, ...} = player val {x = px, y = py, ...} = player
val pfx = px + Constants.playerSize val pfx = px + Constants.playerWidth
val pfy = py + Constants.playerSize val pfy = py + Constants.playerHeight
val range = 199 val range = 199

View File

@@ -3,7 +3,8 @@ sig
type t type t
type patch type patch
val entitySize: int val entityWidth: int
val entityHeight: int
(* constants for physics *) (* constants for physics *)
val moveBy: int val moveBy: int
@@ -76,9 +77,9 @@ struct
fun standingOnArea (x, y, tree) = fun standingOnArea (x, y, tree) =
let let
val y = y + Fn.entitySize - 1 val y = y + Fn.entityHeight - 1
val width = Fn.entitySize val width = Fn.entityWidth
val height = Platform.platHeight val height = Platform.platHeight
val ww = Constants.worldWidth val ww = Constants.worldWidth
@@ -89,9 +90,9 @@ struct
fun standingOnAreaID (x, y, tree) = fun standingOnAreaID (x, y, tree) =
let let
val y = y + Fn.entitySize - 1 val y = y + Fn.entityHeight - 1
val width = Fn.entitySize val width = Fn.entityWidth
val height = Platform.platHeight + 2 val height = Platform.platHeight + 2
in in
@@ -100,7 +101,9 @@ struct
fun getWallPatches (x, y, walls, wallTree, acc) = fun getWallPatches (x, y, walls, wallTree, acc) =
let let
val size = Fn.entitySize val entityWidth = Fn.entityWidth
val entityHeight = Fn.entityHeight
val moveBy = Fn.moveBy val moveBy = Fn.moveBy
val ww = Constants.worldWidth val ww = Constants.worldWidth
val wh = Constants.worldHeight val wh = Constants.worldHeight
@@ -126,13 +129,14 @@ struct
(* check collision with wall to the right *) (* check collision with wall to the right *)
val acc = val acc =
let let
val rightWallID = QuadTree.getItemID (x + size - 1, y, 1, 1, wallTree) val rightWallID = QuadTree.getItemID
(x + entityWidth - 1, y, 1, 1, wallTree)
in in
if rightWallID <> ~1 then if rightWallID <> ~1 then
let let
val {x = wallX, ...} = Vector.sub (walls, rightWallID - 1) val {x = wallX, ...} = Vector.sub (walls, rightWallID - 1)
val newX = wallX - size val newX = wallX - entityWidth
in in
Fn.W_X newX :: acc Fn.W_X newX :: acc
end end
@@ -142,13 +146,13 @@ struct
(* check collision with wall below *) (* check collision with wall below *)
val downWallID = QuadTree.getItemID val downWallID = QuadTree.getItemID
(x + moveBy + 1, y + size, 1, 1, wallTree) (x + moveBy + 1, y + entityHeight, 1, 1, wallTree)
in in
if downWallID <> ~1 then if downWallID <> ~1 then
let let
val {y = wallY, ...} = Vector.sub (walls, downWallID - 1) val {y = wallY, ...} = Vector.sub (walls, downWallID - 1)
val newY = wallY - size val newY = wallY - entityHeight
in in
Fn.W_Y_AXIS ON_GROUND :: Fn.W_Y newY :: acc Fn.W_Y_AXIS ON_GROUND :: Fn.W_Y newY :: acc
end end
@@ -164,7 +168,9 @@ struct
val y = Fn.getY input val y = Fn.getY input
val yAxis = Fn.getYAxis input val yAxis = Fn.getYAxis input
val size = Fn.entitySize val ew = Fn.entityWidth
val eh = Fn.entityHeight
val ww = Constants.worldWidth val ww = Constants.worldWidth
val wh = Constants.worldHeight val wh = Constants.worldHeight
@@ -187,7 +193,7 @@ struct
val {y = platY, ...}: Platform.t = val {y = platY, ...}: Platform.t =
Vector.sub (platforms, standPlatID - 1) Vector.sub (platforms, standPlatID - 1)
val newY = platY - Fn.entitySize val newY = platY - eh
val acc = Fn.W_Y_AXIS ON_GROUND :: Fn.W_Y newY :: acc val acc = Fn.W_Y_AXIS ON_GROUND :: Fn.W_Y newY :: acc
in in
acc acc
@@ -204,10 +210,8 @@ struct
* then set new yAxis to FALLING * then set new yAxis to FALLING
* so we do not drop below any platforms again * so we do not drop below any platforms again
* *) * *)
if QuadTree.hasCollisionAt (x, y, size, size, ~1, platformTree) then if QuadTree.hasCollisionAt (x, y, ew, eh, ~1, platformTree) then acc
acc else Fn.W_Y_AXIS FALLING :: acc
else
Fn.W_Y_AXIS FALLING :: acc
| _ => acc | _ => acc
val acc = getWallPatches (x, y, walls, wallTree, acc) val acc = getWallPatches (x, y, walls, wallTree, acc)
@@ -222,7 +226,8 @@ structure PlayerPhysics =
type t = PlayerType.player type t = PlayerType.player
type patch = PlayerPatch.player_patch type patch = PlayerPatch.player_patch
val entitySize = Constants.playerSize val entityWidth = Constants.playerWidth
val entityHeight = Constants.playerHeight
(* constants for physics *) (* constants for physics *)
val moveBy = Constants.movePlayerBy val moveBy = Constants.movePlayerBy
@@ -248,7 +253,8 @@ structure EnemyPhysics =
type t = EnemyType.enemy type t = EnemyType.enemy
type patch = EnemyPatch.enemy_patch type patch = EnemyPatch.enemy_patch
val entitySize = Constants.enemySize val entityWidth = Constants.enemySize
val entityHeight = Constants.enemySize
(* constants for physics *) (* constants for physics *)
val moveBy = Constants.moveEnemyBy val moveBy = Constants.moveEnemyBy

View File

@@ -60,10 +60,10 @@ struct
MAIN_ATTACKING {length, ...} => MAIN_ATTACKING {length, ...} =>
let let
open EntityType open EntityType
val height = Constants.playerSize val height = Constants.playerHeight
val x = val x =
(case facing of (case facing of
FACING_RIGHT => x + Constants.playerSize FACING_RIGHT => x + Constants.playerWidth
| FACING_LEFT => x - length) | FACING_LEFT => x - length)
val (defeatedList, enemyMap) = PlayerAttackEnemy.foldRegion val (defeatedList, enemyMap) = PlayerAttackEnemy.foldRegion

View File

@@ -0,0 +1,193 @@
structure PlayerSprite =
struct
fun lerp (startX, startY, drawWidth, drawHeight, windowWidth, windowHeight) : 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.3125)) + (endX * 0.3125)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.3125)) + (endX * 0.3125)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.25)) + (endX * 0.25)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.25)) + (endX * 0.25)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.25)) + (endX * 0.25)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.3125)) + (endX * 0.3125)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.6875)) + (endX * 0.6875)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.6875)) + (endX * 0.6875)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.75)) + (endX * 0.75)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.75)) + (endX * 0.75)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.75)) + (endX * 0.75)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.6875)) + (endX * 0.6875)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.25)) + (endY * 0.25)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.25)) + (endY * 0.25)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.25)) + (endY * 0.25)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.9375)) + (endY * 0.9375)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.9375)) + (endY * 0.9375)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.9375)) + (endY * 0.9375)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.9375)) + (endY * 0.9375)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.9375)) + (endY * 0.9375)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.9375)) + (endY * 0.9375)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0,
0.0,
0.0,
0.0
]
end
end

View File

@@ -103,10 +103,11 @@ struct
Vector.fromList acc Vector.fromList acc
else else
let let
val diff = val halfProjectileSize = Constants.projectileSize / 2.0
Constants.halfPlayerSizeReal - (Constants.projectileSize / 2.0) val diffX = Constants.halfPlayerWidthReal - halfProjectileSize
val x = Real32.fromInt x + diff val diffY = Constants.halfPlayerHeightReal - halfProjectileSize
val y = Real32.fromInt y + diff val x = Real32.fromInt x + diffX
val y = Real32.fromInt y + diffY
val {angle} = Vector.sub (defeteadEnemies, pos) val {angle} = Vector.sub (defeteadEnemies, pos)
val angle = degreesToRadians angle val angle = degreesToRadians angle
@@ -343,8 +344,8 @@ struct
* and then chose appropriate direction to recoil in *) * and then chose appropriate direction to recoil in *)
let let
val {x, ...} = player val {x, ...} = player
val pFinishX = x + Constants.playerSize val pFinishX = x + Constants.playerWidth
val pHalfW = Constants.playerSize div 2 val pHalfW = Constants.playerWidth div 2
val pCentreX = x + pHalfW val pCentreX = x + pHalfW
in in
case EnemyMap.get (enemyID, enemies) of case EnemyMap.get (enemyID, enemies) of
@@ -433,11 +434,12 @@ struct
| _ => | _ =>
let let
val {x, y, ...} = player val {x, y, ...} = player
val size = Constants.playerSize val ew = Constants.playerWidth
val eh = Constants.playerHeight
val env = (enemies, player) val env = (enemies, player)
val state = [] val state = []
val patches = FoldEnemies.foldRegion val patches = FoldEnemies.foldRegion
(x, y, size, size, env, state, enemyTree) (x, y, ew, eh, env, state, enemyTree)
in in
PlayerPatch.withPatches (player, patches) PlayerPatch.withPatches (player, patches)
end end
@@ -492,35 +494,36 @@ struct
(*** DRAWING FUNCTIONS ***) (*** DRAWING FUNCTIONS ***)
(* block is placeholder asset *) (* block is placeholder asset *)
fun helpGetDrawVec (x, y, size, width, height, attacked, mainAttack) = fun helpGetDrawVec
(x, y, realWidth, realHeight, width, height, attacked, mainAttack) =
case mainAttack of case mainAttack of
MAIN_NOT_ATTACKING => MAIN_NOT_ATTACKING =>
(case attacked of (case attacked of
NOT_ATTACKED => NOT_ATTACKED =>
Block.lerp (x, y, size, size, width, height, 0.5, 0.5, 0.5) PlayerSprite.lerp (x, y, realWidth, realHeight, width, height)
| ATTACKED amt => | ATTACKED amt =>
if amt mod 5 = 0 then if amt mod 5 = 0 then
Block.lerp (x, y, size, size, width, height, 0.9, 0.9, 0.9) PlayerSprite.lerp (x, y, realWidth, realHeight, width, height)
else else
Block.lerp (x, y, size, size, width, height, 0.5, 0.5, 0.5)) PlayerSprite.lerp (x, y, realWidth, realHeight, width, height))
| MAIN_THROWING => | MAIN_THROWING =>
(case attacked of (case attacked of
NOT_ATTACKED => NOT_ATTACKED =>
Block.lerp (x, y, size, size, width, height, 0.5, 0.5, 0.5) PlayerSprite.lerp (x, y, realWidth, realHeight, width, height)
| ATTACKED amt => | ATTACKED amt =>
if amt mod 5 = 0 then if amt mod 5 = 0 then
Block.lerp (x, y, size, size, width, height, 0.9, 0.9, 0.9) PlayerSprite.lerp (x, y, realWidth, realHeight, width, height)
else else
Block.lerp (x, y, size, size, width, height, 0.5, 0.5, 0.5)) PlayerSprite.lerp (x, y, realWidth, realHeight, width, height))
| MAIN_ATTACKING _ => | MAIN_ATTACKING _ =>
(case attacked of (case attacked of
NOT_ATTACKED => NOT_ATTACKED =>
Block.lerp (x, y, size, size, width, height, 1.0, 0.5, 0.5) PlayerSprite.lerp (x, y, realWidth, realHeight, width, height)
| ATTACKED amt => | ATTACKED amt =>
if amt mod 5 = 0 then if amt mod 5 = 0 then
Block.lerp (x, y, size, size, width, height, 1.0, 0.9, 0.9) PlayerSprite.lerp (x, y, realWidth, realHeight, width, height)
else else
Block.lerp (x, y, size, size, width, height, 1.0, 0.5, 0.5)) PlayerSprite.lerp (x, y, realWidth, realHeight, width, height))
fun getDrawVec (player: player, width, height) = fun getDrawVec (player: player, width, height) =
let let
@@ -539,9 +542,11 @@ struct
val x = Real32.fromInt x * wratio val x = Real32.fromInt x * wratio
val y = Real32.fromInt y * wratio + yOffset val y = Real32.fromInt y * wratio + yOffset
val realSize = Constants.playerSizeReal * wratio val realWidth = Constants.playerWidthReal * wratio
val realHeight = Constants.playerHeightReal * wratio
in in
helpGetDrawVec (x, y, realSize, width, height, attacked, mainAttack) helpGetDrawVec
(x, y, realWidth, realHeight, width, height, attacked, mainAttack)
end end
else else
let let
@@ -554,9 +559,11 @@ struct
val x = Real32.fromInt x * hratio + xOffset val x = Real32.fromInt x * hratio + xOffset
val y = Real32.fromInt y * hratio val y = Real32.fromInt y * hratio
val realSize = Constants.playerSizeReal * hratio val realWidth = Constants.playerWidthReal * hratio
val realHeight = Constants.playerHeightReal * hratio
in in
helpGetDrawVec (x, y, realSize, width, height, attacked, mainAttack) helpGetDrawVec
(x, y, realWidth, realHeight, width, height, attacked, mainAttack)
end end
end end
@@ -569,7 +576,7 @@ struct
val hratio = height / Constants.worldHeightReal val hratio = height / Constants.worldHeightReal
val x = val x =
case #facing player of case #facing player of
FACING_RIGHT => x + Constants.playerSize FACING_RIGHT => x + Constants.playerWidth
| FACING_LEFT => x - length | FACING_LEFT => x - length
in in
if wratio < hratio then if wratio < hratio then
@@ -584,7 +591,7 @@ struct
val y = Real32.fromInt y * wratio + yOffset val y = Real32.fromInt y * wratio + yOffset
val realLength = Real32.fromInt length * wratio val realLength = Real32.fromInt length * wratio
val realSize = Constants.playerSizeReal * wratio val realHeight = Constants.playerHeightReal * wratio
val {charge, ...} = player val {charge, ...} = player
val alpha = Real32.fromInt charge / 60.0 val alpha = Real32.fromInt charge / 60.0
@@ -592,10 +599,10 @@ struct
case facing of case facing of
FACING_RIGHT => FACING_RIGHT =>
ChainEdgeRight.lerp ChainEdgeRight.lerp
(x, y, realLength, realSize, width, height, 0.5, 0.5, 0.5) (x, y, realLength, realHeight, width, height, 0.5, 0.5, 0.5)
| FACING_LEFT => | FACING_LEFT =>
ChainEdgeLeft.lerp ChainEdgeLeft.lerp
(x, y, realLength, realSize, width, height, 0.5, 0.5, 0.5) (x, y, realLength, realHeight, width, height, 0.5, 0.5, 0.5)
end end
else else
let let
@@ -609,7 +616,7 @@ struct
val y = Real32.fromInt y * hratio val y = Real32.fromInt y * hratio
val realLength = Real32.fromInt length * hratio val realLength = Real32.fromInt length * hratio
val realSize = Constants.playerSizeReal * hratio val realHeight = Constants.playerHeightReal * hratio
val {charge, ...} = player val {charge, ...} = player
val alpha = Real32.fromInt charge / 60.0 val alpha = Real32.fromInt charge / 60.0
@@ -617,10 +624,10 @@ struct
case facing of case facing of
FACING_RIGHT => FACING_RIGHT =>
ChainEdgeRight.lerp ChainEdgeRight.lerp
(x, y, realLength, realSize, width, height, 0.5, 0.5, 0.5) (x, y, realLength, realHeight, width, height, 0.5, 0.5, 0.5)
| FACING_LEFT => | FACING_LEFT =>
ChainEdgeLeft.lerp ChainEdgeLeft.lerp
(x, y, realLength, realSize, width, height, 0.5, 0.5, 0.5) (x, y, realLength, realHeight, width, height, 0.5, 0.5, 0.5)
end end
end end
| _ => Vector.fromList [] | _ => Vector.fromList []
@@ -692,10 +699,11 @@ struct
val {x, y, enemies, ...} = player val {x, y, enemies, ...} = player
(* get centre (x, y) coordinates of player *) (* get centre (x, y) coordinates of player *)
val diff = val halfProjectileSize = Constants.projectileSize / 2.0
Constants.halfPlayerSizeReal - (Constants.projectileSize / 2.0) val diffX = Constants.halfPlayerWidthReal - halfProjectileSize
val x = Real32.fromInt x + diff val diffY = Constants.halfPlayerHeightReal - halfProjectileSize
val y = Real32.fromInt y + diff val x = Real32.fromInt x + diffX
val y = Real32.fromInt y + diffY
val wratio = width / Constants.worldWidthReal val wratio = width / Constants.worldWidthReal
val hratio = height / Constants.worldHeightReal val hratio = height / Constants.worldHeightReal

View File

@@ -17,6 +17,7 @@ ann
"allowVectorExps true" "allowVectorExps true"
in in
fcore/block.sml fcore/block.sml
fcore/player/player-sprite.sml
fcore/field.sml fcore/field.sml
fcore/chain-edge.sml fcore/chain-edge.sml
end end