adjustment to player sprite, allowing the inside of the sprite to be a chosen colour

This commit is contained in:
2025-02-18 12:48:55 +00:00
parent d3200745d0
commit b426ddbdd1
2 changed files with 126 additions and 112 deletions

View File

@@ -1,6 +1,6 @@
structure PlayerSprite = structure PlayerSprite =
struct struct
fun lerp (startX, startY, drawWidth, drawHeight, windowWidth, windowHeight) : Real32.real vector = fun lerp (startX, startY, drawWidth, drawHeight, windowWidth, windowHeight, r, g, b) : Real32.real vector =
let let
val endY = windowHeight - startY val endY = windowHeight - startY
val startY = windowHeight - (startY + drawHeight) val startY = windowHeight - (startY + drawHeight)
@@ -8,23 +8,53 @@ struct
val windowHeight = windowHeight / 2.0 val windowHeight = windowHeight / 2.0
val windowWidth = windowWidth / 2.0 val windowWidth = windowWidth / 2.0
in in
#[ (((startX * (1.0 - 0.3125)) + (endX * 0.3125)) / windowWidth) - 1.0, #[ (((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.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.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.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.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.950000047684)) + (endY * 0.950000047684)) / windowHeight) - 1.0,
r,
g,
b,
(((startX * (1.0 - 0.3125)) + (endX * 0.3125)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0, (((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0,
0.0, 0.0,
0.0, 0.0,
0.0, 0.0,
(((startX * (1.0 - 0.3125)) + (endX * 0.3125)) / windowWidth) - 1.0, (((startX * (1.0 - 0.3125)) + (endX * 0.3125)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0, (((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0,
0.0, 0.0,
0.0, 0.0,
0.0, 0.0,
(((startX * (1.0 - 0.25)) + (endX * 0.25)) / windowWidth) - 1.0, (((startX * (1.0 - 0.25)) + (endX * 0.25)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0, (((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0,
0.0, 0.0,
0.0, 0.0,
0.0, 0.0,
(((startX * (1.0 - 0.25)) + (endX * 0.25)) / windowWidth) - 1.0, (((startX * (1.0 - 0.25)) + (endX * 0.25)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0, (((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0,
0.0, 0.0,
0.0, 0.0,
0.0, 0.0,
@@ -44,17 +74,17 @@ struct
0.0, 0.0,
0.0, 0.0,
(((startX * (1.0 - 0.6875)) + (endX * 0.6875)) / windowWidth) - 1.0, (((startX * (1.0 - 0.6875)) + (endX * 0.6875)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0, (((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0,
0.0, 0.0,
0.0, 0.0,
0.0, 0.0,
(((startX * (1.0 - 0.75)) + (endX * 0.75)) / windowWidth) - 1.0, (((startX * (1.0 - 0.75)) + (endX * 0.75)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0, (((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0,
0.0, 0.0,
0.0, 0.0,
0.0, 0.0,
(((startX * (1.0 - 0.75)) + (endX * 0.75)) / windowWidth) - 1.0, (((startX * (1.0 - 0.75)) + (endX * 0.75)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0, (((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0,
0.0, 0.0,
0.0, 0.0,
0.0, 0.0,
@@ -67,81 +97,31 @@ struct
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0, (((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0,
0.0, 0.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, 0.0,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0, (((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0, (((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0,
0.0, 0.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, 0.0,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0, (((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0, (((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0,
@@ -154,12 +134,57 @@ struct
0.0, 0.0,
0.0, 0.0,
(((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0, (((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.9375)) + (endY * 0.9375)) / windowHeight) - 1.0, (((startY * (1.0 - 0.25)) + (endY * 0.25)) / windowHeight) - 1.0,
0.0, 0.0,
0.0, 0.0,
0.0, 0.0,
(((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0, (((startX * (1.0 - 0.9375)) + (endX * 0.9375)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 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, 0.0,
0.0, 0.0,
@@ -172,18 +197,23 @@ struct
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0, (((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0,
0.0, 0.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, 0.0,
(((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0, (((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0, (((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0,
0.0, 0.0,
0.0, 0.0,
0.0, 0.0,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0, (((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.1875)) + (endY * 0.1875)) / windowHeight) - 1.0, (((startY * (1.0 - 0.200000017881)) + (endY * 0.200000017881)) / windowHeight) - 1.0,
0.0, 0.0,
0.0, 0.0,
0.0, 0.0,
(((startX * (1.0 - 0.0625)) + (endX * 0.0625)) / windowWidth) - 1.0, (((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0, (((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0,
0.0, 0.0,
0.0, 0.0,

View File

@@ -496,34 +496,18 @@ struct
(* block is placeholder asset *) (* block is placeholder asset *)
fun helpGetDrawVec fun helpGetDrawVec
(x, y, realWidth, realHeight, width, height, attacked, mainAttack) = (x, y, realWidth, realHeight, width, height, attacked, mainAttack) =
case mainAttack of let
MAIN_NOT_ATTACKING => val (r, g, b) =
(case attacked of case attacked of
NOT_ATTACKED => NOT_ATTACKED => (1.0, 1.0, 1.0)
PlayerSprite.lerp (x, y, realWidth, realHeight, width, height)
| ATTACKED amt => | ATTACKED amt =>
if amt mod 5 = 0 then if amt mod 5 = 0 then
PlayerSprite.lerp (x, y, realWidth, realHeight, width, height) (1.0, 1.0, 1.0)
else else
PlayerSprite.lerp (x, y, realWidth, realHeight, width, height)) (1.0, 0.75, 0.75)
| MAIN_THROWING => in
(case attacked of PlayerSprite.lerp (x, y, realWidth, realHeight, width, height, r, g, b)
NOT_ATTACKED => end
PlayerSprite.lerp (x, y, realWidth, realHeight, width, height)
| ATTACKED amt =>
if amt mod 5 = 0 then
PlayerSprite.lerp (x, y, realWidth, realHeight, width, height)
else
PlayerSprite.lerp (x, y, realWidth, realHeight, width, height))
| MAIN_ATTACKING _ =>
(case attacked of
NOT_ATTACKED =>
PlayerSprite.lerp (x, y, realWidth, realHeight, width, height)
| ATTACKED amt =>
if amt mod 5 = 0 then
PlayerSprite.lerp (x, y, realWidth, realHeight, width, height)
else
PlayerSprite.lerp (x, y, realWidth, realHeight, width, height))
fun getDrawVec (player: player, width, height) = fun getDrawVec (player: player, width, height) =
let let