feat(projects): scrolling projects

This commit is contained in:
2025-11-18 14:56:28 +01:00
parent 44d647696d
commit 8b492e1392
9 changed files with 131 additions and 17 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -6,44 +6,40 @@ import Selector from "~/components/Common/ButtonSelector.vue";
const store = useHomeStore(); const store = useHomeStore();
const BUTTONS_CONFIG = {
game: [31, 23, 193, 49],
contact: [31, 71, 97, 49],
downloadPlay: [127, 71, 97, 49],
} as const satisfies Record<string, ButtonConfig>;
type ButtonType = keyof typeof BUTTONS_CONFIG;
const { selectedButton, selectorPosition } = useButtonNavigation({ const { selectedButton, selectorPosition } = useButtonNavigation({
buttons: BUTTONS_CONFIG, buttons: {
initialButton: "game", projects: [31, 23, 193, 49],
contact: [31, 71, 97, 49],
downloadPlay: [127, 71, 97, 49],
},
initialButton: "projects",
onButtonClick: (button) => { onButtonClick: (button) => {
store.animateOutro(`/${button}`); store.animateOutro(`/${button}`);
}, },
navigation: { navigation: {
game: { projects: {
down: "last", down: "last",
left: "contact", left: "contact",
right: "downloadPlay", right: "downloadPlay",
horizontalMode: "preview", horizontalMode: "preview",
}, },
contact: { contact: {
up: "game", up: "projects",
right: "downloadPlay", right: "downloadPlay",
}, },
downloadPlay: { downloadPlay: {
up: "game", up: "projects",
left: "contact", left: "contact",
}, },
}, },
}); });
const getButtonOffset = (button: ButtonType) => { const getButtonOffset = (button: (typeof selectedButton)["value"]) => {
if (selectedButton.value === button) return store.outro.buttonOffsetY; if (selectedButton.value === button) return store.outro.buttonOffsetY;
return 0; return 0;
}; };
const getOpacity = (button?: ButtonType) => { const getOpacity = (button?: (typeof selectedButton)["value"]) => {
if (store.isIntro) return store.intro.stage1Opacity; if (store.isIntro) return store.intro.stage1Opacity;
if (selectedButton.value === button) return 1; if (selectedButton.value === button) return 1;
if (store.isOutro) return store.outro.stage1Opacity; if (store.isOutro) return store.outro.stage1Opacity;
@@ -54,8 +50,8 @@ const getOpacity = (button?: ButtonType) => {
<template> <template>
<GameButton <GameButton
:x="33" :x="33"
:y="25 + getButtonOffset('game')" :y="25 + getButtonOffset('projects')"
:opacity="getOpacity('game')" :opacity="getOpacity('projects')"
/> />
<DownloadPlayButton <DownloadPlayButton
:x="128" :x="128"

View File

@@ -0,0 +1,17 @@
<script setup lang="ts">
const backgroundImage = useTemplateRef("backgroundImage");
useRender((ctx) => {
if (!backgroundImage.value) return;
ctx.drawImage(backgroundImage.value, 0, 0);
});
</script>
<template>
<img
ref="backgroundImage"
src="/assets/images/projects/bottom-screen/background.png"
hidden
/>
</template>

View File

@@ -0,0 +1,10 @@
<script setup lang="ts">
import Background from "./Background.vue";
import Projects from "./Projects.vue";
</script>
<template>
<Background />
<Projects />
</template>

View File

@@ -0,0 +1,71 @@
<script setup lang="ts">
import gsap from "gsap";
const selectorImage = useTemplateRef("selectorImage");
const projectSquareImage = useTemplateRef("projectSquareImage");
const projects = ["a", "b", "c", "d", "e", "f", "g", "h"];
let currentProject = 0;
const offsetX = ref(0);
useRender((ctx) => {
if (!selectorImage.value || !projectSquareImage.value) return;
const startIndex = Math.max(currentProject - 3, 0);
const endIndex = Math.min(currentProject + 3 + 1, projects.length);
for (let i = startIndex; i < endIndex; i += 1) {
const offsetFromCenter = i - currentProject;
const x = 101 + 69 * offsetFromCenter + offsetX.value;
ctx.drawImage(projectSquareImage.value, x, 81);
}
ctx.drawImage(selectorImage.value, 96, 76);
ctx.font = "10px NDS10";
ctx.fillText(projects[currentProject]!, 20, 20);
});
const handleKeyDown = (e: KeyboardEvent) => {
let from = 0;
if (e.key === "ArrowRight" && currentProject < projects.length - 1) {
currentProject += 1;
from = 69;
}
if (e.key === "ArrowLeft" && currentProject > 0) {
currentProject -= 1;
from = -69;
}
if (from != 0) {
gsap.fromTo(
offsetX,
{
value: from,
},
{
value: 0,
duration: 0.075,
ease: "none",
},
);
}
};
onMounted(() => window.addEventListener("keydown", handleKeyDown));
onUnmounted(() => window.removeEventListener("keydown", handleKeyDown));
</script>
<template>
<img
ref="selectorImage"
src="/assets/images/projects/bottom-screen/selector.png"
hidden
/>
<img
ref="projectSquareImage"
src="/assets/images/projects/bottom-screen/project-square.png"
hidden
/>
</template>

View File

@@ -0,0 +1,3 @@
<script setup lang="ts"></script>
<template></template>

17
app/pages/projects.vue Normal file
View File

@@ -0,0 +1,17 @@
<script setup lang="ts">
definePageMeta({
layout: false,
});
</script>
<template>
<NuxtLayout name="default">
<template #top>
<ProjectsTopScreen />
</template>
<template #bottom>
<ProjectsBottomScreen />
</template>
</NuxtLayout>
</template>