Skip to content

Commit

Permalink
chore: optimize assets
Browse files Browse the repository at this point in the history
  • Loading branch information
toanbku committed Mar 10, 2023
1 parent f2b36f5 commit 18cb0ba
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
6 changes: 4 additions & 2 deletions components/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ export const Map = () => {
goal.location.row - 1 === rowIndex
);

const selectedGoal = GOALS[goal?.player_id || "a"];

// Step 3: check if this cell has cell value
const cellValue = gameState?.map[rowIndex][colIndex];
let point = 0;
Expand Down Expand Up @@ -157,10 +159,10 @@ export const Map = () => {

{goal && (
<Image
src={GOALS[goal.player_id! || "a"]}
src={selectedGoal.src}
alt="goal"
fill
className="scale-125"
className={`scale-125 ${selectedGoal.css}`}
/>
)}

Expand Down
27 changes: 22 additions & 5 deletions constants/goal.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
export const GOALS: Record<string, string> = {
a: "/assets/spritesheets/portals/portal-green.webp",
b: "/assets/spritesheets/portals/portal-purple.webp",
c: "/assets/spritesheets/portals/portal-red.webp",
d: "/assets/spritesheets/portals/portal-yellow.webp",
type Goal = {
src: string;
css: string;
};

export const GOALS: Record<string, Goal> = {
a: {
src: "/assets/spritesheets/portals/portal-red.webp",
css: "hue-rotate-120", // green
},
b: {
src: "/assets/spritesheets/portals/portal-red.webp",
css: "hue-rotate-240", // purple
},
c: {
src: "/assets/spritesheets/portals/portal-red.webp",
css: "",
},
d: {
src: "/assets/spritesheets/portals/portal-yellow.webp",
css: "",
},
};
Binary file removed public/assets/spritesheets/portals/portal-green.webp
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,11 @@ input[type="text"] {
.card-br::before {
clip-path: polygon(var(--border-path-br));
}

.hue-rotate-120 {
filter: hue-rotate(120deg);
}

.hue-rotate-240 {
filter: hue-rotate(240deg);
}

1 comment on commit 18cb0ba

@vercel
Copy link

@vercel vercel bot commented on 18cb0ba Mar 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

hunger-game – ./

the-hunger-game.vercel.app
hunger-game-podso.vercel.app
hunger-game-git-master-podso.vercel.app

Please sign in to comment.