small improvement to player's sprite (and create subdirectory for player's sprites too, as I expect there will be quite a few)

This commit is contained in:
2025-02-22 06:02:28 +00:00
parent aa2936499d
commit f8ed79c81f
4 changed files with 328 additions and 7 deletions

View File

@@ -496,7 +496,7 @@ struct
(* block is placeholder asset *)
fun helpGetDrawVec
(x, y, realWidth, realHeight, width, height, attacked, mainAttack) =
(x, y, realWidth, realHeight, width, height, attacked, facing) =
let
val (r, g, b) =
case attacked of
@@ -504,12 +504,18 @@ struct
| ATTACKED amt =>
if amt mod 5 = 0 then (1.0, 1.0, 1.0) else (1.0, 0.75, 0.75)
in
PlayerSprite.lerp (x, y, realWidth, realHeight, width, height, r, g, b)
case facing of
FACING_RIGHT =>
PlayerStandingRight.lerp
(x, y, realWidth, realHeight, width, height, r, g, b)
| FACING_LEFT =>
PlayerStandingLeft.lerp
(x, y, realWidth, realHeight, width, height, r, g, b)
end
fun getDrawVec (player: player, width, height) =
let
val {x, y, attacked, mainAttack, ...} = player
val {x, y, attacked, facing, ...} = player
val wratio = width / Constants.worldWidthReal
val hratio = height / Constants.worldHeightReal
in
@@ -528,7 +534,7 @@ struct
val realHeight = Constants.playerHeightReal * wratio
in
helpGetDrawVec
(x, y, realWidth, realHeight, width, height, attacked, mainAttack)
(x, y, realWidth, realHeight, width, height, attacked, facing)
end
else
let
@@ -545,7 +551,7 @@ struct
val realHeight = Constants.playerHeightReal * hratio
in
helpGetDrawVec
(x, y, realWidth, realHeight, width, height, attacked, mainAttack)
(x, y, realWidth, realHeight, width, height, attacked, facing)
end
end

View File

@@ -0,0 +1,313 @@
structure PlayerStandingLeft =
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.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.25)) + (endX * 0.25)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.25)) + (endX * 0.25)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.25)) + (endX * 0.25)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.625)) + (endX * 0.625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.625)) + (endX * 0.625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.625)) + (endX * 0.625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.375)) + (endX * 0.375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.5)) + (endX * 0.5)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.5)) + (endX * 0.5)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.375)) + (endX * 0.375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.375)) + (endX * 0.375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.5)) + (endX * 0.5)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.25)) + (endY * 0.25)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.25)) + (endY * 0.25)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.25)) + (endY * 0.25)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.950000047684)) + (endY * 0.950000047684)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.950000047684)) + (endY * 0.950000047684)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.950000047684)) + (endY * 0.950000047684)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.625)) + (endX * 0.625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.5)) + (endX * 0.5)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.5)) + (endX * 0.5)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.5)) + (endX * 0.5)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.625)) + (endX * 0.625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.625)) + (endX * 0.625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.375)) + (endX * 0.375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.375)) + (endX * 0.375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.25)) + (endX * 0.25)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.25)) + (endX * 0.25)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.700000047684)) + (endY * 0.700000047684)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.25)) + (endX * 0.25)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.375)) + (endX * 0.375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.799999952316)) + (endY * 0.799999952316)) / 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.3125)) + (endX * 0.3125)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.25)) + (endX * 0.25)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.25)) + (endX * 0.25)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / 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.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.75)) + (endX * 0.75)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.75)) + (endX * 0.75)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / 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 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.950000047684)) + (endY * 0.950000047684)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.950000047684)) + (endY * 0.950000047684)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.950000047684)) + (endY * 0.950000047684)) / 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.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.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 - 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.25)) + (endY * 0.25)) / 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.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.25)) + (endY * 0.25)) / 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.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0,
0.0,
0.0,
0.0,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / 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
]
end
end

View File

@@ -1,4 +1,4 @@
structure PlayerSprite =
structure PlayerStandingRight =
struct
fun lerp (startX, startY, drawWidth, drawHeight, windowWidth, windowHeight, r,
g, b) : Real32.real vector =

View File

@@ -18,9 +18,11 @@ ann
in
vendored/cozette-sml/fonts/cozette-ascii.mlb
fcore/block.sml
fcore/level/player/player-sprite.sml
fcore/field.sml
fcore/level/chain-edge.sml
fcore/level/player/sprites/player-standing-right.sml
fcore/level/player/sprites/player-standing-left.sml
end
fcore/make-text-vec.sml