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