File size: 8,052 Bytes
7428b13 afa3e65 7428b13 bba35f8 7428b13 afa3e65 7428b13 afa3e65 7428b13 afa3e65 bba35f8 afa3e65 bba35f8 afa3e65 20436ef afa3e65 7428b13 afa3e65 7428b13 afa3e65 bba35f8 afa3e65 bba35f8 afa3e65 7428b13 90a88fc 7428b13 afa3e65 7428b13 bba35f8 7428b13 afa3e65 7428b13 afa3e65 7428b13 afa3e65 7428b13 afa3e65 7428b13 afa3e65 7428b13 afa3e65 20436ef 7428b13 afa3e65 7428b13 afa3e65 20436ef afa3e65 686010d afa3e65 15c1c68 190d7a5 7428b13 afa3e65 7428b13 afa3e65 90a88fc afa3e65 90a88fc afa3e65 90a88fc afa3e65 90a88fc afa3e65 b16a79f 90a88fc afa3e65 190d7a5 afa3e65 190d7a5 afa3e65 15c1c68 190d7a5 afa3e65 20436ef afa3e65 190d7a5 afa3e65 15c1c68 afa3e65 90a88fc bba35f8 7428b13 afa3e65 20436ef 7428b13 afa3e65 01069ac afa3e65 01069ac 7428b13 afa3e65 01069ac 7428b13 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
<script lang="ts">
import { onMount } from 'svelte';
import { fade } from 'svelte/transition';
import type { PicletInstance } from '$lib/db/schema';
import PicletInfo from './PicletInfo.svelte';
export let playerPiclet: PicletInstance;
export let enemyPiclet: PicletInstance;
export let playerHpPercentage: number;
export let enemyHpPercentage: number;
export let showIntro: boolean = false;
// Animation states
let playerVisible = false;
let enemyVisible = false;
let trainerVisible = true;
// Calculate player XP percentage (0-100% of current level)
const playerXpPercentage = (playerPiclet.xp / 100) * 100; // Simplified, should use actual XP curve
onMount(() => {
if (showIntro) {
// Intro animation sequence
setTimeout(() => {
trainerVisible = false;
enemyVisible = true;
}, 500);
setTimeout(() => {
playerVisible = true;
}, 1000);
} else {
// Skip intro
playerVisible = true;
enemyVisible = true;
trainerVisible = false;
}
});
</script>
<div class="battle-field">
<!-- Trainer intro image -->
{#if showIntro && trainerVisible}
<div class="trainer-intro" transition:fade={{ duration: 300 }}>
<img src="/assets/default_trainer.png" alt="Trainer" />
</div>
{/if}
<div class="battle-content">
<!-- Enemy Row -->
<div class="enemy-row">
<div class="enemy-stack" class:intro-animations={showIntro}>
<PicletInfo
piclet={enemyPiclet}
hpPercentage={enemyHpPercentage}
xpPercentage={0}
isPlayer={false}
/>
{#if enemyVisible}
<div class="enemy-piclet-wrapper" class:animate-in={showIntro}>
<img
class="piclet-image enemy-image"
src={enemyPiclet.imageData || enemyPiclet.imageUrl}
alt={enemyPiclet.nickname}
on:error={(e) => e.currentTarget.src = 'https://via.placeholder.com/120x120?text=Piclet'}
/>
<img
class="platform enemy-platform"
src="/assets/grass.PNG"
alt="Platform"
on:error={(e) => {
e.currentTarget.style.display = 'none';
e.currentTarget.nextElementSibling.style.display = 'block';
}}
/>
<div class="platform-fallback enemy-platform-fallback" style="display: none;"></div>
</div>
{/if}
</div>
</div>
<div class="spacer"></div>
<!-- Player Row -->
<div class="player-row">
<div class="player-stack" class:intro-animations={showIntro}>
{#if playerVisible}
<div class="player-piclet-wrapper" class:animate-in={showIntro}>
<img
class="piclet-image player-image"
src={playerPiclet.imageData || playerPiclet.imageUrl}
alt={playerPiclet.nickname}
on:error={(e) => e.currentTarget.src = 'https://via.placeholder.com/120x120?text=Piclet'}
/>
<img
class="platform player-platform"
src="/assets/grass.PNG"
alt="Platform"
on:error={(e) => {
e.currentTarget.style.display = 'none';
e.currentTarget.nextElementSibling.style.display = 'block';
}}
/>
<div class="platform-fallback player-platform-fallback" style="display: none;"></div>
</div>
{/if}
<PicletInfo
piclet={playerPiclet}
hpPercentage={playerHpPercentage}
xpPercentage={playerXpPercentage}
isPlayer={true}
/>
</div>
</div>
</div>
</div>
<style>
.battle-field {
height: 280px;
position: relative;
overflow: hidden;
background: repeating-linear-gradient(
to bottom,
rgba(76, 175, 80, 0.2) 0px,
rgba(76, 175, 80, 0.2) 5px,
rgba(76, 175, 80, 0.1) 5px,
rgba(76, 175, 80, 0.1) 10px
);
}
.trainer-intro {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 10;
}
.trainer-intro img {
width: 200px;
height: auto;
animation: trainerPulse 0.5s ease-in-out;
}
@keyframes trainerPulse {
0% {
transform: scale(1);
}
50% {
transform: scale(1.05);
}
100% {
transform: scale(1);
}
}
.battle-content {
display: flex;
flex-direction: column;
height: 100%;
}
/* Enemy Row */
.enemy-row {
flex: 1;
position: relative;
}
.enemy-stack {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
}
.enemy-piclet-wrapper {
position: absolute;
right: 40px;
top: 0;
}
.enemy-image {
width: 120px;
height: 120px;
object-fit: contain;
display: block;
}
.enemy-platform {
width: 160px;
height: 160px;
position: absolute;
bottom: -60px;
left: -20px;
z-index: 0;
object-fit: cover;
}
/* Player Row */
.player-row {
height: 140px;
position: relative;
}
.player-stack {
position: relative;
width: 100%;
height: 100%;
}
.player-piclet-wrapper {
position: absolute;
left: 40px;
bottom: 0;
}
.player-image {
width: 120px;
height: 120px;
object-fit: contain;
display: block;
transform: scaleX(-1);
}
.player-platform {
width: 160px;
height: 160px;
position: absolute;
bottom: -80px;
left: -20px;
z-index: 0;
object-fit: cover;
}
/* Platform fallbacks */
.platform-fallback {
position: absolute;
background: rgba(76, 175, 80, 0.3);
border-radius: 50%;
}
.enemy-platform-fallback {
width: 160px;
height: 160px;
bottom: -80px;
left: -20px;
}
.player-platform-fallback {
width: 160px;
height: 160px;
bottom: -80px;
left: -20px;
}
/* Piclet images */
.piclet-image {
image-rendering: auto;
filter: drop-shadow(-2px 0 4px rgba(0, 0, 0, 0.1));
position: relative;
z-index: 1;
}
.spacer {
flex: 1;
}
/* Animations */
.enemy-piclet-wrapper {
animation-fill-mode: both;
}
.enemy-piclet-wrapper.animate-in {
animation: enemySlideIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.player-piclet-wrapper {
animation-fill-mode: both;
}
.player-piclet-wrapper.animate-in {
animation: playerSlideIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes enemySlideIn {
0% {
transform: translateX(150px) translateY(-50px) scale(1.5);
opacity: 0;
}
50% {
opacity: 1;
}
100% {
transform: translateX(0) translateY(0) scale(1);
opacity: 1;
}
}
@keyframes playerSlideIn {
0% {
transform: translateX(-150px) translateY(50px) scale(0.5);
opacity: 0;
}
50% {
opacity: 1;
}
100% {
transform: translateX(0) translateY(0) scale(1);
opacity: 1;
}
}
/* Info box animations */
.enemy-stack.intro-animations :global(.piclet-info-wrapper) {
animation: fadeSlideDown 0.5s ease-out 0.3s both;
}
.player-stack.intro-animations :global(.piclet-info-wrapper) {
animation: fadeSlideUp 0.5s ease-out 0.3s both;
}
@keyframes fadeSlideDown {
0% {
opacity: 0;
transform: translateY(-20px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeSlideUp {
0% {
opacity: 0;
transform: translateY(20px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
@media (max-width: 768px) {
.enemy-image {
width: 120px;
height: 120px;
}
.player-image {
width: 120px;
height: 120px;
}
.enemy-piclet-wrapper {
right: 40px;
}
.player-piclet-wrapper {
left: 40px;
}
}
</style> |