feat(projects): scrolling projects
This commit is contained in:
BIN
app/assets/images/projects/bottom-screen/background.png
Normal file
BIN
app/assets/images/projects/bottom-screen/background.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 193 KiB |
BIN
app/assets/images/projects/bottom-screen/project-square.png
Normal file
BIN
app/assets/images/projects/bottom-screen/project-square.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
app/assets/images/projects/bottom-screen/selector.png
Normal file
BIN
app/assets/images/projects/bottom-screen/selector.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
@@ -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"
|
||||||
|
|||||||
17
app/components/Projects/BottomScreen/Background.vue
Normal file
17
app/components/Projects/BottomScreen/Background.vue
Normal 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>
|
||||||
10
app/components/Projects/BottomScreen/BottomScreen.vue
Normal file
10
app/components/Projects/BottomScreen/BottomScreen.vue
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import Background from "./Background.vue";
|
||||||
|
import Projects from "./Projects.vue";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Background />
|
||||||
|
|
||||||
|
<Projects />
|
||||||
|
</template>
|
||||||
71
app/components/Projects/BottomScreen/Projects.vue
Normal file
71
app/components/Projects/BottomScreen/Projects.vue
Normal 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>
|
||||||
3
app/components/Projects/TopScreen/TopScreen.vue
Normal file
3
app/components/Projects/TopScreen/TopScreen.vue
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template></template>
|
||||||
17
app/pages/projects.vue
Normal file
17
app/pages/projects.vue
Normal 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>
|
||||||
Reference in New Issue
Block a user