Add Pokeball release animations and Fairy Feather item

pull/14/head
Flashfyre 2024-01-04 23:57:21 -05:00
parent f342ea8e67
commit 9037562c5c
11 changed files with 5333 additions and 4904 deletions

View File

@ -0,0 +1,209 @@
{
"textures": [
{
"image": "pb_particles.png",
"format": "RGBA8888",
"size": {
"w": 66,
"h": 8
},
"scale": 1,
"frames": [
{
"filename": "0.png",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 8,
"h": 8
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 8,
"h": 8
},
"frame": {
"x": 0,
"y": 0,
"w": 8,
"h": 8
}
},
{
"filename": "1.png",
"rotated": false,
"trimmed": true,
"sourceSize": {
"w": 8,
"h": 8
},
"spriteSourceSize": {
"x": 2,
"y": 0,
"w": 4,
"h": 8
},
"frame": {
"x": 8,
"y": 0,
"w": 4,
"h": 8
}
},
{
"filename": "2.png",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 8,
"h": 8
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 8,
"h": 8
},
"frame": {
"x": 12,
"y": 0,
"w": 8,
"h": 8
}
},
{
"filename": "3.png",
"rotated": false,
"trimmed": true,
"sourceSize": {
"w": 8,
"h": 8
},
"spriteSourceSize": {
"x": 0,
"y": 2,
"w": 8,
"h": 4
},
"frame": {
"x": 20,
"y": 0,
"w": 8,
"h": 4
}
},
{
"filename": "4.png",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 8,
"h": 8
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 8,
"h": 8
},
"frame": {
"x": 28,
"y": 0,
"w": 8,
"h": 8
}
},
{
"filename": "5.png",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 8,
"h": 8
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 8,
"h": 8
},
"frame": {
"x": 36,
"y": 0,
"w": 8,
"h": 8
}
},
{
"filename": "6.png",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 8,
"h": 8
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 8,
"h": 8
},
"frame": {
"x": 44,
"y": 0,
"w": 8,
"h": 8
}
},
{
"filename": "7.png",
"rotated": false,
"trimmed": false,
"sourceSize": {
"w": 8,
"h": 8
},
"spriteSourceSize": {
"x": 0,
"y": 0,
"w": 8,
"h": 8
},
"frame": {
"x": 52,
"y": 0,
"w": 8,
"h": 8
}
},
{
"filename": "8.png",
"rotated": false,
"trimmed": true,
"sourceSize": {
"w": 8,
"h": 8
},
"spriteSourceSize": {
"x": 1,
"y": 1,
"w": 6,
"h": 6
},
"frame": {
"x": 60,
"y": 0,
"w": 6,
"h": 6
}
}
]
}
],
"meta": {
"app": "https://www.codeandweb.com/texturepacker",
"version": "3.0",
"smartupdate": "$TexturePacker:SmartUpdate:3d90a35bb4610decd755ab4f161b7b2e:b268210eb2ee2dfe30b1474128e3a256:6439796039cb76db5f241df91ac447de$"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 448 B

176
src/anims.ts Normal file
View File

@ -0,0 +1,176 @@
import BattleScene from "./battle-scene";
import { PokeballType } from "./data/pokeball";
import * as Utils from "./utils";
export function addPokeballOpenParticles(scene: BattleScene, x: number, y: number, pokeballType: PokeballType): void {
switch (pokeballType) {
case PokeballType.POKEBALL:
doDefaultPbOpenParticles(scene, x, y, 48);
break;
case PokeballType.GREAT_BALL:
doDefaultPbOpenParticles(scene, x, y, 96);
break;
case PokeballType.ULTRA_BALL:
doUbOpenParticles(scene, x, y);
break;
case PokeballType.MASTER_BALL:
doMbOpenParticles(scene, x, y);
break;
}
}
function doDefaultPbOpenParticles(scene: BattleScene, x: number, y: number, radius: number) {
const pbOpenParticlesFrameNames = scene.anims.generateFrameNames('pb_particles', { start: 0, end: 3, suffix: '.png' });
scene.anims.create({
key: 'pb_open_particle',
frames: pbOpenParticlesFrameNames,
frameRate: 16,
repeat: -1
});
const addParticle = (index: integer) => {
const particle = scene.add.sprite(x, y, 'pb_open_particle');
scene.field.add(particle);
const angle = index * 45;
const [ xCoord, yCoord ] = [ radius * Math.cos(angle * Math.PI / 180), radius * Math.sin(angle * Math.PI / 180) ];
scene.tweens.add({
targets: particle,
x: x + xCoord,
y: y + yCoord,
duration: 575
});
particle.play({
key: 'pb_open_particle',
startFrame: (index + 3) % 4
});
scene.tweens.add({
targets: particle,
delay: 500,
duration: 75,
alpha: 0,
ease: 'Sine.easeIn',
onComplete: () => particle.destroy()
});
};
let particleCount = 0;
scene.time.addEvent({
delay: 20,
repeat: 16,
callback: () => addParticle(++particleCount)
});
}
function doUbOpenParticles(scene: BattleScene, x: number, y: number) {
let particles: Phaser.GameObjects.Image[] = [];
for (let i = 0; i < 10; i++)
particles.push(doFanOutParticle(scene, i * 25, x, y, 1, 1, 5, 8));
scene.tweens.add({
targets: particles,
delay: 750,
duration: 250,
alpha: 0,
ease: 'Sine.easeIn',
onComplete: () => {
for (let particle of particles)
particle.destroy();
}
});
}
function doMbOpenParticles(scene: BattleScene, x: number, y: number) {
let particles: Phaser.GameObjects.Image[] = [];
for (let j = 0; j < 2; j++) {
for (let i = 0; i < 8; i++)
particles.push(doFanOutParticle(scene, i * 32, x, y, j ? 1 : 2, j ? 2 : 1, 8, 4));
scene.tweens.add({
targets: particles,
delay: 750,
duration: 250,
alpha: 0,
ease: 'Sine.easeIn',
onComplete: () => {
for (let particle of particles)
particle.destroy();
}
});
}
}
function doFanOutParticle(scene: BattleScene, trigIndex: integer, x: integer, y: integer, xSpeed: integer, ySpeed: integer, angle: integer, frameIndex: integer): Phaser.GameObjects.Image {
let f = 0;
const particle = scene.add.image(x, y, 'pb_particles', `${frameIndex}.png`);
scene.field.add(particle);
const updateParticle = () => {
if (!particle.scene)
return particleTimer.remove();
particle.x = x + sin(trigIndex, f * xSpeed);
particle.y = y + cos(trigIndex, f * ySpeed);
trigIndex = (trigIndex + angle);
f++;
};
const particleTimer = scene.tweens.addCounter({
repeat: -1,
duration: Utils.getFrameMs(1),
onRepeat: () => {
updateParticle();
}
});
return particle;
}
export function addPokeballCaptureStars(scene: BattleScene, pokeball: Phaser.GameObjects.Sprite): void {
const addParticle = () => {
const particle = scene.add.sprite(pokeball.x, pokeball.y, 'pb_particles', '4.png');
particle.setOrigin(pokeball.originX, pokeball.originY);
particle.setAlpha(0.5);
scene.field.add(particle);
scene.tweens.add({
targets: particle,
y: pokeball.y - 10,
ease: 'Sine.easeOut',
duration: 250,
onComplete: () => {
scene.tweens.add({
targets: particle,
y: pokeball.y,
alpha: 0,
ease: 'Sine.easeIn',
duration: 250
});
}
});
const dist = Utils.randGauss(25);
scene.tweens.add({
targets: particle,
x: pokeball.x + dist,
duration: 500
});
scene.tweens.add({
targets: particle,
alpha: 0,
delay: 425,
duration: 75,
onComplete: () => particle.destroy()
});
};
new Array(3).fill(null).map(() => addParticle());
}
export function sin(index: integer, amplitude: integer): number {
return amplitude * Math.sin(index * (Math.PI / 128));
}
export function cos(index: integer, amplitude: integer): number {
return amplitude * Math.cos(index * (Math.PI / 128));
}

View File

@ -38,6 +38,7 @@ import { Egg } from "./data/egg";
import { vouchers } from "./system/voucher";
import { loggedInUser, updateUserInfo } from "./account";
import { GameDataType } from "./system/game-data";
import { addPokeballCaptureStars, addPokeballOpenParticles } from "./anims";
export class LoginPhase extends BattlePhase {
private showText: boolean;
@ -842,6 +843,7 @@ export class SummonPhase extends PartyMemberPokemonPhase {
this.scene.field.moveBelow(pokemon, playerPokemon);
this.scene.currentBattle.seenEnemyPartyMemberIds.add(pokemon.id);
}
addPokeballOpenParticles(this.scene, pokemon.x, pokemon.y - 16, pokemon.pokeball);
this.scene.updateModifiers(this.player);
pokemon.showInfo();
pokemon.playAnim();
@ -3000,6 +3002,7 @@ export class AttemptCapturePhase extends PokemonPhase {
this.scene.time.delayedCall(300, () => {
this.scene.field.moveBelow(this.pokeball as Phaser.GameObjects.GameObject, pokemon);
});
this.scene.tweens.add({
targets: this.pokeball,
x: { value: 236 + fpOffset[0], ease: 'Linear' },
@ -3010,9 +3013,12 @@ export class AttemptCapturePhase extends PokemonPhase {
this.scene.time.delayedCall(17, () => this.pokeball.setTexture('pb', `${pokeballAtlasKey}_open`));
this.scene.playSound('pb_rel');
pokemon.tint(getPokeballTintColor(this.pokeballType));
addPokeballOpenParticles(this.scene, this.pokeball.x, this.pokeball.y, this.pokeballType);
this.scene.tweens.add({
targets: pokemon,
duration: 250,
duration: 500,
ease: 'Sine.easeIn',
scale: 0.25,
y: 20,
@ -3052,8 +3058,31 @@ export class AttemptCapturePhase extends PokemonPhase {
shakeCounter.stop();
this.failCatch(shakeCount);
}
} else
this.scene.playSound('pb_lock')
} else {
this.scene.playSound('pb_lock');
addPokeballCaptureStars(this.scene, this.pokeball);
const pbTint = this.scene.add.sprite(this.pokeball.x, this.pokeball.y, 'pb', 'pb');
pbTint.setOrigin(this.pokeball.originX, this.pokeball.originY);
pbTint.setTintFill(0);
pbTint.setAlpha(0);
this.scene.field.add(pbTint);
this.scene.tweens.add({
targets: pbTint,
alpha: 0.375,
duration: 200,
easing: 'Sine.easeOut',
onComplete: () => {
this.scene.tweens.add({
targets: pbTint,
alpha: 0,
duration: 200,
easing: 'Sine.easeIn',
onComplete: () => pbTint.destroy()
});
}
});
}
},
onComplete: () => this.catch()
});

View File

@ -301,6 +301,7 @@ export default class BattleScene extends Phaser.Scene {
this.loadImage(`pkmn__sub`, 'pokemon', 'sub.png');
this.loadAtlas('battle_stats', 'effects');
this.loadAtlas('shiny', 'effects');
this.loadAtlas('pb_particles', 'effects');
this.loadImage('evo_sparkle', 'effects');
this.load.video('evo_bg', 'images/effects/evo_bg.mp4', true);

View File

@ -8,6 +8,7 @@ import { Mode } from "./ui/ui";
import { LearnMovePhase } from "./battle-phases";
import { SpeciesFormKey } from "./data/pokemon-species";
import { achvs } from "./system/achv";
import { cos, sin } from "./anims";
export class EvolutionPhase extends BattlePhase {
private partyMemberIndex: integer;
@ -251,14 +252,6 @@ export class EvolutionPhase extends BattlePhase {
});
}
sin(index: integer, amplitude: integer): number {
return amplitude * Math.sin(index * (Math.PI / 128));
}
cos(index: integer, amplitude: integer): number {
return amplitude * Math.cos(index * (Math.PI / 128));
}
doSpiralUpward() {
let f = 0;
@ -381,8 +374,8 @@ export class EvolutionPhase extends BattlePhase {
const updateParticle = () => {
if (!f || particle.y > 8) {
particle.setPosition(initialX, 88 - (f * f) / 80);
particle.y += this.sin(trigIndex, amp) / 4;
particle.x += this.cos(trigIndex, amp);
particle.y += sin(trigIndex, amp) / 4;
particle.x += cos(trigIndex, amp);
particle.setScale(1 - (f / 80));
trigIndex += 4;
if (f & 1)
@ -417,9 +410,9 @@ export class EvolutionPhase extends BattlePhase {
const updateParticle = () => {
if (!f || particle.y < 88) {
particle.setPosition(initialX, 8 + (f * f) / 5);
particle.y += this.sin(trigIndex, amp) / 4;
particle.x += this.cos(trigIndex, amp);
amp = 8 + this.sin(f * 4, 40);
particle.y += sin(trigIndex, amp) / 4;
particle.x += cos(trigIndex, amp);
amp = 8 + sin(f * 4, 40);
f++;
} else {
particle.destroy();
@ -449,8 +442,8 @@ export class EvolutionPhase extends BattlePhase {
const updateParticle = () => {
if (amp > 8) {
particle.setPosition(initialX, initialY);
particle.y += this.sin(trigIndex, amp);
particle.x += this.cos(trigIndex, amp);
particle.y += sin(trigIndex, amp);
particle.x += cos(trigIndex, amp);
amp -= speed;
trigIndex += 4;
} else {
@ -486,7 +479,7 @@ export class EvolutionPhase extends BattlePhase {
yOffset++;
if (trigIndex < 128) {
particle.setPosition(initialX + (speed * f) / 3, initialY + yOffset);
particle.y += -this.sin(trigIndex, amp);
particle.y += -sin(trigIndex, amp);
if (f > 108)
particle.setScale((1 - (f - 108) / 20));
trigIndex++;

View File

@ -313,7 +313,7 @@ function getAttackTypeBoosterItemName(type: Type) {
case Type.DARK:
return 'Black Glasses';
case Type.FAIRY:
return 'Clefairy Doll';
return 'Fairy Feather';
}
}

View File

@ -33,18 +33,18 @@ export function clampInt(value: integer, min: integer, max: integer): integer {
return Math.min(Math.max(value, min), max);
}
export function randGauss(value: number): number {
let rand = 0;
for(var i = value; i > 0; i--)
rand += Math.random();
return rand / value;
export function randGauss(stdev: number, mean: number = 0): number {
const u = 1 - Math.random();
const v = Math.random();
const z = Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v);
return z * stdev + mean;
}
export function randSeedGauss(value: number): number {
let rand = 0;
for(var i = value; i > 0; i--)
rand += Phaser.Math.RND.realInRange(0, 1);
return rand / value;
export function randSeedGauss(stdev: number, mean: number = 0): number {
const u = 1 - Phaser.Math.RND.realInRange(0, 1);
const v = Phaser.Math.RND.realInRange(0, 1);
const z = Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v);
return z * stdev + mean;
}
export function padInt(value: integer, length: integer, padWith?: string): string {