mirror of
https://github.com/nacabaro/vbhelper.git
synced 2026-06-05 13:52:54 +00:00
Fixed dodge animation. Sprites now move up then back to original location.
This commit is contained in:
parent
f0f1d9830e
commit
7843be7004
@ -66,6 +66,19 @@ class ArenaBattleSystem {
|
||||
private var _isOpponentDodging by mutableStateOf(false)
|
||||
val isOpponentDodging: Boolean get() = _isOpponentDodging
|
||||
|
||||
// Separate dodge progress and direction for player and opponent
|
||||
private var _playerDodgeProgress by mutableStateOf(0f)
|
||||
val playerDodgeProgress: Float get() = _playerDodgeProgress
|
||||
|
||||
private var _playerDodgeDirection by mutableStateOf(1f)
|
||||
val playerDodgeDirection: Float get() = _playerDodgeDirection
|
||||
|
||||
private var _opponentDodgeProgress by mutableStateOf(0f)
|
||||
val opponentDodgeProgress: Float get() = _opponentDodgeProgress
|
||||
|
||||
private var _opponentDodgeDirection by mutableStateOf(1f)
|
||||
val opponentDodgeDirection: Float get() = _opponentDodgeDirection
|
||||
|
||||
private var _isPlayerHit by mutableStateOf(false)
|
||||
val isPlayerHit: Boolean get() = _isPlayerHit
|
||||
|
||||
@ -168,6 +181,10 @@ class ArenaBattleSystem {
|
||||
_hitProgress = 0f
|
||||
_isPlayerDodging = false
|
||||
_isOpponentDodging = false
|
||||
_playerDodgeProgress = 0f
|
||||
_playerDodgeDirection = 1f
|
||||
_opponentDodgeProgress = 0f
|
||||
_opponentDodgeDirection = 1f
|
||||
_isPlayerHit = false
|
||||
_isOpponentHit = false
|
||||
_shouldCounterAttack = false
|
||||
@ -232,31 +249,47 @@ class ArenaBattleSystem {
|
||||
// Player-specific dodge methods
|
||||
fun startPlayerDodge() {
|
||||
_isPlayerDodging = true
|
||||
_dodgeProgress = 0f
|
||||
_dodgeDirection = 1f
|
||||
_playerDodgeProgress = 0f
|
||||
_playerDodgeDirection = 1f
|
||||
Log.d(TAG, "Started player dodge animation")
|
||||
}
|
||||
|
||||
fun endPlayerDodge() {
|
||||
_isPlayerDodging = false
|
||||
_dodgeProgress = 0f
|
||||
_playerDodgeProgress = 0f
|
||||
Log.d(TAG, "Ended player dodge animation")
|
||||
}
|
||||
|
||||
fun setPlayerDodgeProgress(progress: Float) {
|
||||
_playerDodgeProgress = progress
|
||||
}
|
||||
|
||||
fun setPlayerDodgeDirection(direction: Float) {
|
||||
_playerDodgeDirection = direction
|
||||
}
|
||||
|
||||
// Opponent-specific dodge methods
|
||||
fun startOpponentDodge() {
|
||||
_isOpponentDodging = true
|
||||
_dodgeProgress = 0f
|
||||
_dodgeDirection = 1f
|
||||
_opponentDodgeProgress = 0f
|
||||
_opponentDodgeDirection = 1f
|
||||
Log.d(TAG, "Started opponent dodge animation")
|
||||
}
|
||||
|
||||
fun endOpponentDodge() {
|
||||
_isOpponentDodging = false
|
||||
_dodgeProgress = 0f
|
||||
_opponentDodgeProgress = 0f
|
||||
Log.d(TAG, "Ended opponent dodge animation")
|
||||
}
|
||||
|
||||
fun setOpponentDodgeProgress(progress: Float) {
|
||||
_opponentDodgeProgress = progress
|
||||
}
|
||||
|
||||
fun setOpponentDodgeDirection(direction: Float) {
|
||||
_opponentDodgeDirection = direction
|
||||
}
|
||||
|
||||
// Player-specific hit methods
|
||||
fun startPlayerHit() {
|
||||
_isPlayerHit = true
|
||||
|
||||
@ -212,8 +212,8 @@ fun BattleScreen(
|
||||
// Move up
|
||||
while (dodgeProgress < 1f) {
|
||||
dodgeProgress += 0.05f // Faster dodge movement
|
||||
battleSystem.setDodgeProgress(dodgeProgress)
|
||||
battleSystem.setDodgeDirection(dodgeDirection)
|
||||
battleSystem.setPlayerDodgeProgress(dodgeProgress)
|
||||
battleSystem.setPlayerDodgeDirection(dodgeDirection)
|
||||
delay(16) // 60 FPS
|
||||
}
|
||||
|
||||
@ -225,8 +225,8 @@ fun BattleScreen(
|
||||
dodgeProgress = 0f
|
||||
while (dodgeProgress < 1f) {
|
||||
dodgeProgress += 0.05f
|
||||
battleSystem.setDodgeProgress(dodgeProgress)
|
||||
battleSystem.setDodgeDirection(dodgeDirection)
|
||||
battleSystem.setPlayerDodgeProgress(dodgeProgress)
|
||||
battleSystem.setPlayerDodgeDirection(dodgeDirection)
|
||||
delay(16)
|
||||
}
|
||||
|
||||
@ -245,8 +245,8 @@ fun BattleScreen(
|
||||
// Move up
|
||||
while (dodgeProgress < 1f) {
|
||||
dodgeProgress += 0.05f // Faster dodge movement
|
||||
battleSystem.setDodgeProgress(dodgeProgress)
|
||||
battleSystem.setDodgeDirection(dodgeDirection)
|
||||
battleSystem.setOpponentDodgeProgress(dodgeProgress)
|
||||
battleSystem.setOpponentDodgeDirection(dodgeDirection)
|
||||
delay(16) // 60 FPS
|
||||
}
|
||||
|
||||
@ -258,8 +258,8 @@ fun BattleScreen(
|
||||
dodgeProgress = 0f
|
||||
while (dodgeProgress < 1f) {
|
||||
dodgeProgress += 0.05f
|
||||
battleSystem.setDodgeProgress(dodgeProgress)
|
||||
battleSystem.setDodgeDirection(dodgeDirection)
|
||||
battleSystem.setOpponentDodgeProgress(dodgeProgress)
|
||||
battleSystem.setOpponentDodgeDirection(dodgeDirection)
|
||||
delay(16)
|
||||
}
|
||||
|
||||
@ -447,15 +447,15 @@ fun PlayerBattleView(
|
||||
// Calculate vertical offset for dodge animation
|
||||
val verticalOffset = if (battleSystem.isPlayerDodging) {
|
||||
val dodgeHeight = 30.dp
|
||||
val progress = battleSystem.dodgeProgress
|
||||
val direction = battleSystem.dodgeDirection
|
||||
val progress = battleSystem.playerDodgeProgress
|
||||
val direction = battleSystem.playerDodgeDirection
|
||||
|
||||
if (direction > 0) {
|
||||
// Moving up
|
||||
(progress * dodgeHeight.value).dp
|
||||
// Moving up (negative offset to move UP visually)
|
||||
-(progress * dodgeHeight.value).dp
|
||||
} else {
|
||||
// Moving back down
|
||||
((1f - progress) * dodgeHeight.value).dp
|
||||
// Moving back down (from negative peak to 0)
|
||||
-((1f - progress) * dodgeHeight.value).dp
|
||||
}
|
||||
} else {
|
||||
0.dp
|
||||
@ -743,15 +743,15 @@ fun OpponentBattleView(
|
||||
// Calculate vertical offset for dodge animation
|
||||
val verticalOffset = if (battleSystem.isOpponentDodging) {
|
||||
val dodgeHeight = 30.dp
|
||||
val progress = battleSystem.dodgeProgress
|
||||
val direction = battleSystem.dodgeDirection
|
||||
val progress = battleSystem.opponentDodgeProgress
|
||||
val direction = battleSystem.opponentDodgeDirection
|
||||
|
||||
if (direction > 0) {
|
||||
// Moving up
|
||||
(progress * dodgeHeight.value).dp
|
||||
// Moving up (negative offset to move UP visually)
|
||||
-(progress * dodgeHeight.value).dp
|
||||
} else {
|
||||
// Moving back down
|
||||
((1f - progress) * dodgeHeight.value).dp
|
||||
// Moving back down (from negative peak to 0)
|
||||
-((1f - progress) * dodgeHeight.value).dp
|
||||
}
|
||||
} else {
|
||||
0.dp
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user