Skip to content

Commit

Permalink
feat: install gsap
Browse files Browse the repository at this point in the history
  • Loading branch information
PancakePhilarmonych committed Nov 19, 2023
1 parent 47751cd commit 73f9a4d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"gsap": "^3.12.2",
"pinia": "^2.0.32",
"pixi.js": "^7.2.4",
"vue": "^3.2.45"
Expand Down
2 changes: 1 addition & 1 deletion src/modules/GameObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class GameObject {
}
}

onPointedUp(event: PIXI.FederatedPointerEvent) {
onPointedUp() {
clearTimeout(this.ponterDownTimeOut);

this.isDragging = false;
Expand Down
26 changes: 25 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as PIXI from 'pixi.js';
import { gsap } from 'gsap';

import redOne from '../assets/sprites/blocks/red_one.png';
import redTwo from '../assets/sprites/blocks/red_two.png';
Expand All @@ -11,7 +12,6 @@ import blueTwo from '../assets/sprites/blocks/blue_two.png';
import blueThree from '../assets/sprites/blocks/blue_three.png';
import empty from '../assets/sprites/blocks/empty.png';


export enum Colors {
RED = 'RED',
RED_TWO = 'RED_TWO',
Expand All @@ -25,6 +25,19 @@ export enum Colors {
EMPTY = 'EMPTY',
}

const mainColors = [
Colors.RED,
Colors.YELLOW,
Colors.BLUE,
Colors.EMPTY,
];

export const getRandomColor = () => {
const index = Math.floor(Math.random() * mainColors.length);
return mainColors[index];
}


export const ColorsTextMap: Record<Colors, string> = {
[Colors.RED]: 'Красный I',
[Colors.RED_TWO]: 'Красный II',
Expand All @@ -50,3 +63,14 @@ export const getSpriteByColor: Record<Colors, PIXI.Texture> = {
[Colors.BLUE_THREE]: PIXI.Texture.from(blueThree),
[Colors.EMPTY]: PIXI.Texture.from(empty),
}

export const maxLevelColors = [Colors.BLUE_THREE, Colors.RED_THREE, Colors.YELLOW_THREE];

export const smoothMoveTo = (sprite: PIXI.Sprite, x: number, y: number, duration: number = 0.3) => {
gsap.to(sprite, {
duration,
x,
y,
ease: 'power2.out',
});
}

0 comments on commit 73f9a4d

Please sign in to comment.