diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/battle/BattleSpriteManager.kt b/app/src/main/java/com/github/nacabaro/vbhelper/battle/BattleSpriteManager.kt index b4bd883..0af8f2b 100644 --- a/app/src/main/java/com/github/nacabaro/vbhelper/battle/BattleSpriteManager.kt +++ b/app/src/main/java/com/github/nacabaro/vbhelper/battle/BattleSpriteManager.kt @@ -82,11 +82,18 @@ class BattleSpriteManager(private val context: Context) { val spriteDataJson = spriteDataFile.readText() val spriteData = gson.fromJson(spriteDataJson, SpriteData::class.java) + // Debug: Print sprite coordinates + println("Sprite coordinates: x=${spriteData.texture_rect.x}, y=${spriteData.texture_rect.y}, width=${spriteData.texture_rect.width}, height=${spriteData.texture_rect.height}") + println("Texture dimensions: width=${fullBitmap.width}, height=${fullBitmap.height}") + + // Calculate the correct Y coordinate (inverted coordinate system) + val correctedY = fullBitmap.height - spriteData.texture_rect.y.toInt() - spriteData.texture_rect.height.toInt() + // Extract the sprite from the atlas using texture_rect coordinates val spriteBitmap = Bitmap.createBitmap( fullBitmap, spriteData.texture_rect.x.toInt(), - spriteData.texture_rect.y.toInt(), + correctedY, spriteData.texture_rect.width.toInt(), spriteData.texture_rect.height.toInt() ) diff --git a/app/src/main/java/com/github/nacabaro/vbhelper/screens/BattlesScreen.kt b/app/src/main/java/com/github/nacabaro/vbhelper/screens/BattlesScreen.kt index 50ad664..8bcdf1a 100644 --- a/app/src/main/java/com/github/nacabaro/vbhelper/screens/BattlesScreen.kt +++ b/app/src/main/java/com/github/nacabaro/vbhelper/screens/BattlesScreen.kt @@ -252,10 +252,10 @@ fun BattleScreen( .fillMaxSize() .background(Color.Black) ) { - println("Current battle view: ${battleSystem.currentView}") + //println("Current battle view: ${battleSystem.currentView}") when (battleSystem.currentView) { 0 -> { - println("Showing PlayerBattleView") + //println("Showing PlayerBattleView") PlayerBattleView( battleSystem = battleSystem, stage = stage, @@ -270,8 +270,8 @@ fun BattleScreen( ) } 1 -> { - println("Showing OpponentBattleView") - OpponentBattleView( + //println("Showing OpponentBattleView") + OpponentBattleView( battleSystem = battleSystem, stage = stage, opponentName = opponentName, @@ -353,11 +353,11 @@ fun PlayerBattleView( SpriteImage( spriteName = "00", // The sprite number (00, 01, 02, etc.) atlasName = activeCharacter?.charaId ?: when (stage) { - "rookie" -> "dim000_mon01" + "rookie" -> "dim275_mon01" "champion" -> "dim012_mon04" "ultimate" -> "dim137_mon09" "mega" -> "dim012_mon14" - else -> "dim000_mon01" + else -> "dim275_mon01" }, modifier = Modifier .size(120.dp) @@ -385,17 +385,17 @@ fun PlayerBattleView( // Attack animation overlay if (attackAnimationProgress > 0) { - AttackSpriteImage( - characterId = activeCharacter?.charaId ?: "dim000_mon03", - isLarge = true, - modifier = Modifier - .size(60.dp) - .offset( - x = (attackAnimationProgress * 200 - 100).dp, - y = 0.dp - ), - contentScale = ContentScale.Fit - ) + AttackSpriteImage( + characterId = activeCharacter?.charaId ?: "dim275_mon01", + isLarge = true, + modifier = Modifier + .size(60.dp) + .offset( + x = (attackAnimationProgress * 200 - 100).dp, + y = 0.dp + ), + contentScale = ContentScale.Fit + ) /* Image( painter = painterResource(R.drawable.atk_l_00), @@ -423,7 +423,7 @@ fun PlayerBattleView( ) // Attack button - println("PlayerBattleView: Attack button enabled = ${battleSystem.isAttackButtonEnabled}") + //println("PlayerBattleView: Attack button enabled = ${battleSystem.isAttackButtonEnabled}") Button( onClick = { println("Attack button clicked!") @@ -502,11 +502,11 @@ fun OpponentBattleView( SpriteImage( spriteName = "00", // The sprite number (00, 01, 02, etc.) atlasName = activeCharacter?.charaId ?: when (stage) { - "rookie" -> "dim000_mon01" + "rookie" -> "dim275_mon01" "champion" -> "dim012_mon04" "ultimate" -> "dim137_mon09" "mega" -> "dim012_mon14" - else -> "dim000_mon01" + else -> "dim275_mon01" }, modifier = Modifier .size(120.dp) @@ -535,7 +535,7 @@ fun OpponentBattleView( // Attack animation overlay if (attackAnimationProgress > 0) { AttackSpriteImage( - characterId = activeCharacter?.charaId ?: "dim000_mon03", + characterId = activeCharacter?.charaId ?: "dim275_mon01", isLarge = true, modifier = Modifier .size(60.dp) @@ -759,7 +759,7 @@ fun BattlesScreen() { // Create hardcoded character lists for each stage val rookieCharacters = listOf( APIBattleCharacter("AGUMON", "degimon_name_Dim012_003", "dim012_mon03", 0, 1, 1800, 1800, 2400.0f, 700.0f), - APIBattleCharacter("PULSEMON", "degimon_name_Dim000_003", "dim000_mon03", 0, 1, 1800, 1800, 2400.0f, 700.0f), + APIBattleCharacter("PULSEMON", "degimon_name_Dim275_001", "dim275_mon01", 0, 1, 1800, 1800, 2400.0f, 700.0f), APIBattleCharacter("DORUMON", "degimon_name_dim137_mon03", "dim137_mon03", 0, 1, 3000, 3000, 5100.0f, 1050.0f) ) @@ -844,6 +844,15 @@ fun BattlesScreen() { championButton() ultimateButton() megaButton() + Button( + onClick = { + val spriteFileManager = SpriteFileManager(context) + spriteFileManager.clearSpriteFiles() + println("Sprite files cleared!") + } + ) { + Text("Clear Sprite Files") + } } }