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 []
|
||||
|
||||
1
oms.mlb
1
oms.mlb
@@ -15,6 +15,7 @@ ann
|
||||
in
|
||||
fcore/block.sml
|
||||
fcore/field.sml
|
||||
fcore/chain-edge.sml
|
||||
end
|
||||
|
||||
fcore/wall.sml
|
||||
|
||||
@@ -241,15 +241,14 @@ struct
|
||||
|
||||
val wallVec = Wall.getDrawVec (#walls game, width, height)
|
||||
val platVec = Platform.getDrawVec (#platforms game, width, height)
|
||||
val wallVec = Vector.concat [wallVec, platVec]
|
||||
|
||||
val fieldVec = Player.getFieldVec (#player game, width, height)
|
||||
val chainVec = Player.getFieldVec (#player game, width, height)
|
||||
val wallVec = Vector.concat [wallVec, platVec, chainVec]
|
||||
|
||||
(* temp *)
|
||||
val pelletVec = Player.getPelletVec (#player game, width, height)
|
||||
val projectileVec =
|
||||
Projectile.getProjectileVec (#player game, width, height)
|
||||
val fieldVec = Vector.concat [pelletVec, projectileVec, fieldVec]
|
||||
val fieldVec = Vector.concat [pelletVec, projectileVec]
|
||||
|
||||
val shellState = uploadWall (shellState, wallVec)
|
||||
val shellState = uploadPlayer (shellState, playerVec)
|
||||
|
||||
Reference in New Issue
Block a user