require attack button to be pressed twice in order to trigger throwing of defeated enemies
This commit is contained in:
@@ -19,7 +19,11 @@ sig
|
|||||||
|
|
||||||
datatype facing = FACING_LEFT | FACING_RIGHT
|
datatype facing = FACING_LEFT | FACING_RIGHT
|
||||||
|
|
||||||
datatype main_attack = MAIN_NOT_ATTACKING | MAIN_ATTACKING | MAIN_CHARGING
|
datatype main_attack =
|
||||||
|
MAIN_NOT_ATTACKING
|
||||||
|
| MAIN_ATTACKING
|
||||||
|
| MAIN_CHARGING
|
||||||
|
| MAIN_THROWING
|
||||||
|
|
||||||
type defeated_enemies = {angle: int}
|
type defeated_enemies = {angle: int}
|
||||||
|
|
||||||
@@ -94,7 +98,11 @@ struct
|
|||||||
|
|
||||||
datatype facing = FACING_LEFT | FACING_RIGHT
|
datatype facing = FACING_LEFT | FACING_RIGHT
|
||||||
|
|
||||||
datatype main_attack = MAIN_NOT_ATTACKING | MAIN_ATTACKING | MAIN_CHARGING
|
datatype main_attack =
|
||||||
|
MAIN_NOT_ATTACKING
|
||||||
|
| MAIN_ATTACKING
|
||||||
|
| MAIN_CHARGING
|
||||||
|
| MAIN_THROWING
|
||||||
|
|
||||||
type defeated_enemies = {angle: int}
|
type defeated_enemies = {angle: int}
|
||||||
|
|
||||||
|
|||||||
@@ -546,6 +546,21 @@ struct
|
|||||||
defeatedEnemiesToProjectiles (pos + 1, defeteadEnemies, player, acc)
|
defeatedEnemiesToProjectiles (pos + 1, defeteadEnemies, player, acc)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun getThrowPatches (defeteadEnemies, projectiles, player, acc) =
|
||||||
|
let
|
||||||
|
val newProjectiles =
|
||||||
|
defeatedEnemiesToProjectiles (0, defeteadEnemies, player, [])
|
||||||
|
|
||||||
|
(* concatenate new projectiles with previous projectiles *)
|
||||||
|
val allProjectiles = Vector.concat [newProjectiles, projectiles]
|
||||||
|
|
||||||
|
(* remove defeated enemies from player record *)
|
||||||
|
val enemies = Vector.fromList []
|
||||||
|
in
|
||||||
|
W_MAIN_ATTACK MAIN_THROWING :: W_PROJECTILES allProjectiles
|
||||||
|
:: W_ENEMIES enemies :: acc
|
||||||
|
end
|
||||||
|
|
||||||
fun getMainAttackPatches
|
fun getMainAttackPatches
|
||||||
( prevAttack
|
( prevAttack
|
||||||
, defeteadEnemies
|
, defeteadEnemies
|
||||||
@@ -556,38 +571,46 @@ struct
|
|||||||
, player
|
, player
|
||||||
, acc
|
, acc
|
||||||
) =
|
) =
|
||||||
if attackHeld then
|
case prevAttack of
|
||||||
if
|
MAIN_NOT_ATTACKING =>
|
||||||
prevWasNotAttacking prevAttack andalso Vector.length defeteadEnemies > 0
|
if attackHeld andalso Vector.length defeteadEnemies > 0 then
|
||||||
then
|
(* shoot projectiles if player was not attacking previously,
|
||||||
(* shoot projectiles if player was not attacking previously,
|
* and there is more than one enemy *)
|
||||||
* and there is more than one enemy *)
|
getThrowPatches (defeteadEnemies, projectiles, player, acc)
|
||||||
let
|
else
|
||||||
val newProjectiles =
|
let
|
||||||
defeatedEnemiesToProjectiles (0, defeteadEnemies, player, [])
|
val mainAttack =
|
||||||
|
helpGetMainAttackPatches (attackHeld, chargeHeld, charge)
|
||||||
(* concatenate new projectiles with previous projectiles *)
|
in
|
||||||
val allProjectiles = Vector.concat [newProjectiles, projectiles]
|
mainAttack :: acc
|
||||||
|
end
|
||||||
(* remove defeated enemies from player record *)
|
| MAIN_CHARGING =>
|
||||||
val enemies = Vector.fromList []
|
if attackHeld andalso Vector.length defeteadEnemies > 0 then
|
||||||
in
|
getThrowPatches (defeteadEnemies, projectiles, player, acc)
|
||||||
W_PROJECTILES allProjectiles :: W_ENEMIES enemies :: acc
|
else
|
||||||
end
|
let
|
||||||
else
|
val mainAttack =
|
||||||
|
helpGetMainAttackPatches (attackHeld, chargeHeld, charge)
|
||||||
|
in
|
||||||
|
mainAttack :: acc
|
||||||
|
end
|
||||||
|
| MAIN_ATTACKING =>
|
||||||
let
|
let
|
||||||
val mainAttack =
|
val mainAttack =
|
||||||
helpGetMainAttackPatches (attackHeld, chargeHeld, charge)
|
helpGetMainAttackPatches (attackHeld, chargeHeld, charge)
|
||||||
in
|
in
|
||||||
mainAttack :: acc
|
mainAttack :: acc
|
||||||
end
|
end
|
||||||
else
|
| MAIN_THROWING =>
|
||||||
let
|
if attackHeld then
|
||||||
val mainAttack =
|
acc
|
||||||
helpGetMainAttackPatches (attackHeld, chargeHeld, charge)
|
else
|
||||||
in
|
let
|
||||||
mainAttack :: acc
|
val mainAttack =
|
||||||
end
|
helpGetMainAttackPatches (attackHeld, chargeHeld, charge)
|
||||||
|
in
|
||||||
|
mainAttack :: acc
|
||||||
|
end
|
||||||
|
|
||||||
fun getInputPatches (player: player, input) =
|
fun getInputPatches (player: player, input) =
|
||||||
let
|
let
|
||||||
@@ -615,7 +638,7 @@ struct
|
|||||||
case mainAttack of
|
case mainAttack of
|
||||||
MAIN_CHARGING => Int.min (charge + 1, maxCharge)
|
MAIN_CHARGING => Int.min (charge + 1, maxCharge)
|
||||||
| MAIN_ATTACKING => Int.max (charge - 1, 0)
|
| MAIN_ATTACKING => Int.max (charge - 1, 0)
|
||||||
| MAIN_NOT_ATTACKING => 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]
|
||||||
|
|
||||||
@@ -738,6 +761,15 @@ 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_THROWING =>
|
||||||
|
(case attacked of
|
||||||
|
NOT_ATTACKED =>
|
||||||
|
Block.lerp (x, y, size, size, width, height, 0.5, 0.5, 0.5)
|
||||||
|
| ATTACKED amt =>
|
||||||
|
if amt mod 5 = 0 then
|
||||||
|
Block.lerp (x, y, size, size, width, height, 0.9, 0.9, 0.9)
|
||||||
|
else
|
||||||
|
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 =>
|
||||||
|
|||||||
Reference in New Issue
Block a user