make length of main attack increase and decrease
This commit is contained in:
@@ -18,7 +18,7 @@ struct
|
|||||||
val recoilLimit = 15
|
val recoilLimit = 15
|
||||||
val attackedLimit = 55
|
val attackedLimit = 55
|
||||||
val maxCharge = 60
|
val maxCharge = 60
|
||||||
val attackLengthLimit = 99
|
val attackLengthLimit = 59
|
||||||
|
|
||||||
(* constants for projectiles *)
|
(* constants for projectiles *)
|
||||||
val projectilePi: Real32.real = Real32.Math.pi / 180.0
|
val projectilePi: Real32.real = Real32.Math.pi / 180.0
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ sig
|
|||||||
|
|
||||||
datatype main_attack =
|
datatype main_attack =
|
||||||
MAIN_NOT_ATTACKING
|
MAIN_NOT_ATTACKING
|
||||||
| MAIN_ATTACKING
|
| MAIN_ATTACKING of {length: int, growing: bool}
|
||||||
| MAIN_CHARGING
|
| MAIN_CHARGING
|
||||||
| MAIN_THROWING
|
| MAIN_THROWING
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ struct
|
|||||||
|
|
||||||
datatype main_attack =
|
datatype main_attack =
|
||||||
MAIN_NOT_ATTACKING
|
MAIN_NOT_ATTACKING
|
||||||
| MAIN_ATTACKING
|
| MAIN_ATTACKING of {length: int, growing: bool}
|
||||||
| MAIN_CHARGING
|
| MAIN_CHARGING
|
||||||
| MAIN_THROWING
|
| MAIN_THROWING
|
||||||
|
|
||||||
|
|||||||
@@ -81,13 +81,19 @@ struct
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
fun prevWasNotAttacking prevAttack = prevAttack <> MAIN_ATTACKING
|
|
||||||
|
|
||||||
(* called only when player has no projectiles or was not previously attacking *)
|
(* called only when player has no projectiles or was not previously attacking *)
|
||||||
fun helpGetMainAttackPatches (attackHeld, chargeHeld, charge) =
|
fun helpGetMainAttackPatches (attackHeld, chargeHeld, charge) =
|
||||||
if attackHeld andalso charge > 0 then W_MAIN_ATTACK MAIN_ATTACKING
|
let
|
||||||
else if chargeHeld andalso not attackHeld then W_MAIN_ATTACK MAIN_CHARGING
|
val attack =
|
||||||
else W_MAIN_ATTACK MAIN_NOT_ATTACKING
|
if attackHeld andalso charge > 0 then
|
||||||
|
MAIN_ATTACKING {length = 3, growing = true}
|
||||||
|
else if chargeHeld andalso not attackHeld then
|
||||||
|
MAIN_CHARGING
|
||||||
|
else
|
||||||
|
MAIN_NOT_ATTACKING
|
||||||
|
in
|
||||||
|
W_MAIN_ATTACK attack
|
||||||
|
end
|
||||||
|
|
||||||
fun degreesToRadians degrees = Real32.fromInt degrees * Constants.projectilePi
|
fun degreesToRadians degrees = Real32.fromInt degrees * Constants.projectilePi
|
||||||
|
|
||||||
@@ -164,12 +170,30 @@ struct
|
|||||||
in
|
in
|
||||||
mainAttack :: acc
|
mainAttack :: acc
|
||||||
end
|
end
|
||||||
| MAIN_ATTACKING =>
|
| MAIN_ATTACKING {length, growing} =>
|
||||||
let
|
let
|
||||||
val mainAttack =
|
val mainAttack =
|
||||||
helpGetMainAttackPatches (attackHeld, chargeHeld, charge)
|
if growing then
|
||||||
|
if length < Constants.attackLengthLimit then
|
||||||
|
let val newLength = length + Constants.moveProjectileBy
|
||||||
|
in MAIN_ATTACKING {length = newLength, growing = true}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
let
|
||||||
|
val newLength = length - Constants.moveProjectileBy
|
||||||
|
in
|
||||||
|
if newLength <= 0 then MAIN_NOT_ATTACKING
|
||||||
|
else MAIN_ATTACKING {length = newLength, growing = false}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
let
|
||||||
|
val newLength = length - Constants.moveProjectileBy
|
||||||
|
in
|
||||||
|
if newLength <= 0 then MAIN_NOT_ATTACKING
|
||||||
|
else MAIN_ATTACKING {length = newLength, growing = false}
|
||||||
|
end
|
||||||
in
|
in
|
||||||
mainAttack :: acc
|
W_MAIN_ATTACK mainAttack :: acc
|
||||||
end
|
end
|
||||||
| MAIN_THROWING =>
|
| MAIN_THROWING =>
|
||||||
if attackHeld then
|
if attackHeld then
|
||||||
@@ -207,7 +231,7 @@ struct
|
|||||||
val charge =
|
val charge =
|
||||||
case mainAttack of
|
case mainAttack of
|
||||||
MAIN_CHARGING => Int.min (charge + 1, Constants.maxCharge)
|
MAIN_CHARGING => Int.min (charge + 1, Constants.maxCharge)
|
||||||
| MAIN_ATTACKING => Int.max (charge - 1, 0)
|
| MAIN_ATTACKING _ => (* todo: rework charge *) Int.max (charge - 1, 0)
|
||||||
| _ => charge
|
| _ => charge
|
||||||
|
|
||||||
val acc = [W_X_AXIS xAxis, W_FACING facing, W_CHARGE charge]
|
val acc = [W_X_AXIS xAxis, W_FACING facing, W_CHARGE charge]
|
||||||
@@ -437,18 +461,18 @@ struct
|
|||||||
* and be compared with attackLengthLimit
|
* and be compared with attackLengthLimit
|
||||||
* and the attack should shrink at some point as well *)
|
* and the attack should shrink at some point as well *)
|
||||||
case #mainAttack player of
|
case #mainAttack player of
|
||||||
MAIN_ATTACKING =>
|
MAIN_ATTACKING {length, ...} =>
|
||||||
let
|
let
|
||||||
val size = Constants.playerSize
|
val height = Constants.playerSize
|
||||||
val {x, y, facing, enemies, ...} = player
|
val {x, y, facing, enemies, ...} = player
|
||||||
val x =
|
val x =
|
||||||
(case facing of
|
(case facing of
|
||||||
FACING_RIGHT => x + size
|
FACING_RIGHT => x + length
|
||||||
| FACING_LEFT => x - size)
|
| FACING_LEFT => x - length)
|
||||||
|
|
||||||
val state = []
|
val state = []
|
||||||
val newDefeated = AttackEnemies.foldRegion
|
val newDefeated = AttackEnemies.foldRegion
|
||||||
(x, y, size, size, (), state, enemyTree)
|
(x, y, length, height, (), state, enemyTree)
|
||||||
val allDefeated =
|
val allDefeated =
|
||||||
Vector.concat [Vector.fromList newDefeated, enemies]
|
Vector.concat [Vector.fromList newDefeated, enemies]
|
||||||
in
|
in
|
||||||
@@ -492,7 +516,7 @@ struct
|
|||||||
Block.lerp (x, y, size, size, width, height, 0.9, 0.9, 0.9)
|
Block.lerp (x, y, size, size, width, height, 0.9, 0.9, 0.9)
|
||||||
else
|
else
|
||||||
Block.lerp (x, y, size, size, width, height, 0.5, 0.5, 0.5))
|
Block.lerp (x, y, size, size, width, height, 0.5, 0.5, 0.5))
|
||||||
| MAIN_ATTACKING =>
|
| MAIN_ATTACKING _ =>
|
||||||
(case attacked of
|
(case attacked of
|
||||||
NOT_ATTACKED =>
|
NOT_ATTACKED =>
|
||||||
Block.lerp (x, y, size, size, width, height, 1.0, 0.5, 0.5)
|
Block.lerp (x, y, size, size, width, height, 1.0, 0.5, 0.5)
|
||||||
@@ -551,9 +575,7 @@ struct
|
|||||||
|
|
||||||
fun getFieldVec (player: player, width, height) =
|
fun getFieldVec (player: player, width, height) =
|
||||||
case #mainAttack player of
|
case #mainAttack player of
|
||||||
MAIN_NOT_ATTACKING => Vector.fromList []
|
MAIN_ATTACKING {length, ...} =>
|
||||||
| MAIN_THROWING => Vector.fromList []
|
|
||||||
| _ =>
|
|
||||||
let
|
let
|
||||||
val {x, y, ...} = player
|
val {x, y, ...} = player
|
||||||
val wratio = width / Constants.worldWidthReal
|
val wratio = width / Constants.worldWidthReal
|
||||||
@@ -561,7 +583,7 @@ struct
|
|||||||
val x =
|
val x =
|
||||||
case #facing player of
|
case #facing player of
|
||||||
FACING_RIGHT => x + Constants.playerSize
|
FACING_RIGHT => x + Constants.playerSize
|
||||||
| FACING_LEFT => x - Constants.playerSize
|
| FACING_LEFT => x - Constants.playerSize - length
|
||||||
in
|
in
|
||||||
if wratio < hratio then
|
if wratio < hratio then
|
||||||
let
|
let
|
||||||
@@ -574,13 +596,24 @@ struct
|
|||||||
val x = Real32.fromInt x * wratio
|
val x = Real32.fromInt x * wratio
|
||||||
val y = Real32.fromInt y * wratio + yOffset
|
val y = Real32.fromInt y * wratio + yOffset
|
||||||
|
|
||||||
val realSize = (Constants.playerSizeReal) * wratio
|
val realLength = Real32.fromInt length * wratio
|
||||||
|
val realSize = Constants.playerSizeReal * wratio
|
||||||
|
|
||||||
val {charge, ...} = player
|
val {charge, ...} = player
|
||||||
val alpha = Real32.fromInt charge / 60.0
|
val alpha = Real32.fromInt charge / 60.0
|
||||||
in
|
in
|
||||||
Field.lerp
|
Field.lerp
|
||||||
(x, y, realSize, realSize, width, height, 0.7, 0.7, 1.0, alpha)
|
( x
|
||||||
|
, y
|
||||||
|
, realLength
|
||||||
|
, realSize
|
||||||
|
, width
|
||||||
|
, height
|
||||||
|
, 0.7
|
||||||
|
, 0.7
|
||||||
|
, 1.0
|
||||||
|
, alpha
|
||||||
|
)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
@@ -593,15 +626,27 @@ struct
|
|||||||
val x = Real32.fromInt x * hratio + xOffset
|
val x = Real32.fromInt x * hratio + xOffset
|
||||||
val y = Real32.fromInt y * hratio
|
val y = Real32.fromInt y * hratio
|
||||||
|
|
||||||
val realSize = (Constants.playerSizeReal) * hratio
|
val realLength = Real32.fromInt length * wratio + xOffset
|
||||||
|
val realSize = Constants.playerSizeReal * hratio
|
||||||
|
|
||||||
val {charge, ...} = player
|
val {charge, ...} = player
|
||||||
val alpha = Real32.fromInt charge / 60.0
|
val alpha = Real32.fromInt charge / 60.0
|
||||||
in
|
in
|
||||||
Field.lerp
|
Field.lerp
|
||||||
(x, y, realSize, realSize, width, height, 0.7, 0.7, 1.0, alpha)
|
( x
|
||||||
|
, y
|
||||||
|
, realLength
|
||||||
|
, realSize
|
||||||
|
, width
|
||||||
|
, height
|
||||||
|
, 0.7
|
||||||
|
, 0.7
|
||||||
|
, 1.0
|
||||||
|
, alpha
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
| _ => Vector.fromList []
|
||||||
|
|
||||||
fun helpGetPelletVec
|
fun helpGetPelletVec
|
||||||
( playerX
|
( playerX
|
||||||
|
|||||||
Reference in New Issue
Block a user