add asset for ChainEdge (attack)
This commit is contained in:
49
fcore/chain-edge.sml
Normal file
49
fcore/chain-edge.sml
Normal file
@@ -0,0 +1,49 @@
|
||||
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
|
||||
@@ -548,7 +548,7 @@ struct
|
||||
case #mainAttack player of
|
||||
MAIN_ATTACKING {length, ...} =>
|
||||
let
|
||||
val {x, y, ...} = player
|
||||
val {x, y, facing, ...} = player
|
||||
val wratio = width / Constants.worldWidthReal
|
||||
val hratio = height / Constants.worldHeightReal
|
||||
val x =
|
||||
@@ -573,18 +573,13 @@ struct
|
||||
val {charge, ...} = player
|
||||
val alpha = Real32.fromInt charge / 60.0
|
||||
in
|
||||
Field.lerp
|
||||
( x
|
||||
, y
|
||||
, realLength
|
||||
, realSize
|
||||
, width
|
||||
, height
|
||||
, 0.7
|
||||
, 0.7
|
||||
, 1.0
|
||||
, alpha
|
||||
)
|
||||
case facing of
|
||||
FACING_RIGHT =>
|
||||
ChainEdgeRight.lerp
|
||||
(x, y, realLength, realSize, width, height, 0.5, 0.5, 0.5)
|
||||
| FACING_LEFT =>
|
||||
ChainEdgeLeft.lerp
|
||||
(x, y, realLength, realSize, width, height, 0.5, 0.5, 0.5)
|
||||
end
|
||||
else
|
||||
let
|
||||
@@ -603,18 +598,13 @@ struct
|
||||
val {charge, ...} = player
|
||||
val alpha = Real32.fromInt charge / 60.0
|
||||
in
|
||||
Field.lerp
|
||||
( x
|
||||
, y
|
||||
, realLength
|
||||
, realSize
|
||||
, width
|
||||
, height
|
||||
, 0.7
|
||||
, 0.7
|
||||
, 1.0
|
||||
, alpha
|
||||
)
|
||||
case facing of
|
||||
FACING_RIGHT =>
|
||||
ChainEdgeRight.lerp
|
||||
(x, y, realLength, realSize, width, height, 0.5, 0.5, 0.5)
|
||||
| FACING_LEFT =>
|
||||
ChainEdgeLeft.lerp
|
||||
(x, y, realLength, realSize, width, height, 0.5, 0.5, 0.5)
|
||||
end
|
||||
end
|
||||
| _ => Vector.fromList []
|
||||
|
||||
Reference in New Issue
Block a user