From f8ed79c81f3854f9b14cd15fef3900908e4cebec Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sat, 22 Feb 2025 06:02:28 +0000 Subject: [PATCH] small improvement to player's sprite (and create subdirectory for player's sprites too, as I expect there will be quite a few) --- fcore/level/player/player.sml | 16 +- .../player/sprites/player-standing-left.sml | 313 ++++++++++++++++++ .../player-standing-right.sml} | 2 +- oms.mlb | 4 +- 4 files changed, 328 insertions(+), 7 deletions(-) create mode 100644 fcore/level/player/sprites/player-standing-left.sml rename fcore/level/player/{player-sprite.sml => sprites/player-standing-right.sml} (99%) diff --git a/fcore/level/player/player.sml b/fcore/level/player/player.sml index d2cc357..43ea016 100644 --- a/fcore/level/player/player.sml +++ b/fcore/level/player/player.sml @@ -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 diff --git a/fcore/level/player/sprites/player-standing-left.sml b/fcore/level/player/sprites/player-standing-left.sml new file mode 100644 index 0000000..7fbced0 --- /dev/null +++ b/fcore/level/player/sprites/player-standing-left.sml @@ -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 diff --git a/fcore/level/player/player-sprite.sml b/fcore/level/player/sprites/player-standing-right.sml similarity index 99% rename from fcore/level/player/player-sprite.sml rename to fcore/level/player/sprites/player-standing-right.sml index c64ab9b..2c899fe 100644 --- a/fcore/level/player/player-sprite.sml +++ b/fcore/level/player/sprites/player-standing-right.sml @@ -1,4 +1,4 @@ -structure PlayerSprite = +structure PlayerStandingRight = struct fun lerp (startX, startY, drawWidth, drawHeight, windowWidth, windowHeight, r, g, b) : Real32.real vector = diff --git a/oms.mlb b/oms.mlb index 33a7f1d..0ebc8b3 100644 --- a/oms.mlb +++ b/oms.mlb @@ -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