poc
This commit is contained in:
8
bun.lock
8
bun.lock
@@ -5,9 +5,11 @@
|
||||
"": {
|
||||
"name": "scrumFun",
|
||||
"dependencies": {
|
||||
"@kaplayjs/crew": "^2.1.0",
|
||||
"kaplay": "^4000.0.0-alpha.26",
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tsconfig/bun": "^1.0.10",
|
||||
"@types/node": "^25.3.0",
|
||||
"vite": "^7.3.1",
|
||||
},
|
||||
@@ -66,6 +68,8 @@
|
||||
|
||||
"@esbuild/win32-x64": ["@esbuild/win32-x64@0.27.3", "", { "os": "win32", "cpu": "x64" }, "sha512-4uJGhsxuptu3OcpVAzli+/gWusVGwZZHTlS63hh++ehExkVT8SgiEf7/uC/PclrPPkLhZqGgCTjd0VWLo6xMqA=="],
|
||||
|
||||
"@kaplayjs/crew": ["@kaplayjs/crew@2.1.0", "", { "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-kkRQTppRCfg7Lr3eclMluENopqHEde67zyWATYoMYNyw0FF1ReGpDBcXPH4zBQcOQ+qhM+pPRPyoT2FBtIZucw=="],
|
||||
|
||||
"@rollup/rollup-android-arm-eabi": ["@rollup/rollup-android-arm-eabi@4.57.1", "", { "os": "android", "cpu": "arm" }, "sha512-A6ehUVSiSaaliTxai040ZpZ2zTevHYbvu/lDoeAteHI8QnaosIzm4qwtezfRg1jOYaUmnzLX1AOD6Z+UJjtifg=="],
|
||||
|
||||
"@rollup/rollup-android-arm64": ["@rollup/rollup-android-arm64@4.57.1", "", { "os": "android", "cpu": "arm64" }, "sha512-dQaAddCY9YgkFHZcFNS/606Exo8vcLHwArFZ7vxXq4rigo2bb494/xKMMwRRQW6ug7Js6yXmBZhSBRuBvCCQ3w=="],
|
||||
@@ -116,6 +120,8 @@
|
||||
|
||||
"@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.57.1", "", { "os": "win32", "cpu": "x64" }, "sha512-mxRFDdHIWRxg3UfIIAwCm6NzvxG0jDX/wBN6KsQFTvKFqqg9vTrWUE68qEjHt19A5wwx5X5aUi2zuZT7YR0jrA=="],
|
||||
|
||||
"@tsconfig/bun": ["@tsconfig/bun@1.0.10", "", {}, "sha512-5AV5YknQjNyoYzZ/8NG0dawqew/wH+x7ANiCfCIn29qo0cdbd1EryvFD1k5NSZWLBMOI/fGqMIaxi58GPIP9Cg=="],
|
||||
|
||||
"@types/estree": ["@types/estree@1.0.8", "", {}, "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w=="],
|
||||
|
||||
"@types/node": ["@types/node@25.3.0", "", { "dependencies": { "undici-types": "~7.18.0" } }, "sha512-4K3bqJpXpqfg2XKGK9bpDTc6xO/xoUP/RBWS7AtRMug6zZFaRekiLzjVtAoZMquxoAbzBvy5nxQ7veS5eYzf8A=="],
|
||||
@@ -142,6 +148,8 @@
|
||||
|
||||
"tinyglobby": ["tinyglobby@0.2.15", "", { "dependencies": { "fdir": "^6.5.0", "picomatch": "^4.0.3" } }, "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ=="],
|
||||
|
||||
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
||||
|
||||
"undici-types": ["undici-types@7.18.2", "", {}, "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w=="],
|
||||
|
||||
"vite": ["vite@7.3.1", "", { "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", "picomatch": "^4.0.3", "postcss": "^8.5.6", "rollup": "^4.43.0", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "jiti": ">=1.21.0", "less": "^4.0.0", "lightningcss": "^1.21.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA=="],
|
||||
|
||||
23
index.html
23
index.html
@@ -1,9 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>scrumFun</title>
|
||||
</head>
|
||||
<body style="overflow:hidden">
|
||||
<script src="src/main.js" type="module"></script>
|
||||
</body>
|
||||
</html>
|
||||
<head>
|
||||
<title>Scrum FUN (TM)</title>
|
||||
</head>
|
||||
<body style="overflow: hidden">
|
||||
<script src="src/main.js" type="module"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<style>
|
||||
body {
|
||||
background-color: #4e495f;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -8,9 +8,11 @@
|
||||
"zip": "bun run build && mkdir -p dist && zip -r dist/game.zip dist -x \"**/.DS_Store\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@kaplayjs/crew": "^2.1.0",
|
||||
"kaplay": "^4000.0.0-alpha.26"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tsconfig/bun": "^1.0.10",
|
||||
"@types/node": "^25.3.0",
|
||||
"vite": "^7.3.1"
|
||||
}
|
||||
|
||||
BIN
public/sprites/bubble.aseprite
Normal file
BIN
public/sprites/bubble.aseprite
Normal file
Binary file not shown.
BIN
public/sprites/bubble.png
Normal file
BIN
public/sprites/bubble.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 578 B |
BIN
public/sprites/card.aseprite
Normal file
BIN
public/sprites/card.aseprite
Normal file
Binary file not shown.
BIN
public/sprites/card.png
Normal file
BIN
public/sprites/card.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 375 B |
BIN
public/sprites/dead.aseprite
Normal file
BIN
public/sprites/dead.aseprite
Normal file
Binary file not shown.
BIN
public/sprites/dead.png
Normal file
BIN
public/sprites/dead.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 589 B |
BIN
public/sprites/octo.aseprite
Normal file
BIN
public/sprites/octo.aseprite
Normal file
Binary file not shown.
BIN
public/sprites/octo.png
Normal file
BIN
public/sprites/octo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 606 B |
BIN
public/sprites/triboi.aseprite
Normal file
BIN
public/sprites/triboi.aseprite
Normal file
Binary file not shown.
BIN
public/sprites/triboi.png
Normal file
BIN
public/sprites/triboi.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 559 B |
BIN
public/sprites/wolfi.aseprite
Normal file
BIN
public/sprites/wolfi.aseprite
Normal file
Binary file not shown.
BIN
public/sprites/wolfi.png
Normal file
BIN
public/sprites/wolfi.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 546 B |
101
src/card.ts
Normal file
101
src/card.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
import "kaplay/global";
|
||||
|
||||
type ScrumCard = {
|
||||
name: string;
|
||||
title?: string;
|
||||
sprite?: string;
|
||||
};
|
||||
|
||||
const scrumCards = [
|
||||
{
|
||||
name: "?",
|
||||
sprite: "been",
|
||||
},
|
||||
{
|
||||
name: "0",
|
||||
title: "0",
|
||||
},
|
||||
{
|
||||
name: "1",
|
||||
title: "1",
|
||||
},
|
||||
{
|
||||
name: "2",
|
||||
title: "2",
|
||||
},
|
||||
{
|
||||
name: "3",
|
||||
title: "3",
|
||||
},
|
||||
{
|
||||
name: "5",
|
||||
title: "5",
|
||||
},
|
||||
{
|
||||
name: "8",
|
||||
title: "8",
|
||||
},
|
||||
{
|
||||
name: "13",
|
||||
title: "13",
|
||||
},
|
||||
{
|
||||
name: "20",
|
||||
title: "20",
|
||||
},
|
||||
{
|
||||
name: "40",
|
||||
title: "40",
|
||||
},
|
||||
{
|
||||
name: "100",
|
||||
title: "100",
|
||||
},
|
||||
{
|
||||
name: "pineapple",
|
||||
sprite: "pineapple",
|
||||
},
|
||||
];
|
||||
|
||||
const cards = [];
|
||||
|
||||
const BOARD_SLOT = 150;
|
||||
|
||||
export const createCards = () => {
|
||||
const board = add([pos(100, 100), "board"]);
|
||||
|
||||
scrumCards.forEach((scrumCard, i) => {
|
||||
const newCard = board.add([
|
||||
pos((BOARD_SLOT * i) % (4 * BOARD_SLOT), BOARD_SLOT * Math.floor(i / 4)),
|
||||
sprite("card"),
|
||||
rotate(),
|
||||
animate(),
|
||||
anchor("center"),
|
||||
area({
|
||||
isSensor: true,
|
||||
}),
|
||||
scale(1),
|
||||
"card",
|
||||
]);
|
||||
|
||||
if (scrumCard.title) {
|
||||
newCard.add([
|
||||
text(scrumCard.title, { font: "happy", size: 32 }),
|
||||
anchor("center"),
|
||||
"title",
|
||||
]);
|
||||
} else {
|
||||
newCard.add([sprite(scrumCard.sprite), anchor("center"), "title"]);
|
||||
}
|
||||
|
||||
newCard.onCollide("player", (player) => {
|
||||
newCard.scaleTo(1.2);
|
||||
});
|
||||
|
||||
newCard.onCollideEnd("player", () => {
|
||||
newCard.scaleTo(1);
|
||||
});
|
||||
|
||||
cards.push(newCard);
|
||||
});
|
||||
};
|
||||
2
src/constants.ts
Normal file
2
src/constants.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export const WOBBLE_ANGLE = 5;
|
||||
export const SPEED = 3;
|
||||
157
src/main.ts
157
src/main.ts
@@ -1,12 +1,155 @@
|
||||
import kaplay, { Color } from "kaplay";
|
||||
// import "kaplay/global"; // uncomment if you want to use without the k. prefix
|
||||
import { crew } from "@kaplayjs/crew";
|
||||
import kaplay, { Comp, EmptyComp } from "kaplay";
|
||||
import { createCards } from "./card";
|
||||
import { WOBBLE_ANGLE, SPEED } from "./constants";
|
||||
import "kaplay/global"; // uncomment if you want to use without the prefix
|
||||
|
||||
const k = kaplay();
|
||||
export const k = kaplay({
|
||||
plugins: [crew],
|
||||
background: "#4e495f",
|
||||
scale: 2,
|
||||
debugKey: "r",
|
||||
});
|
||||
|
||||
k.loadRoot("./"); // A good idea for Itch.io publishing later
|
||||
k.loadSprite("bean", "sprites/bean.png");
|
||||
loadRoot("./"); // A good idea for Itch.io publishing later
|
||||
loadSprite("card", "sprites/card.png");
|
||||
loadSprite("octo", "sprites/octo.png");
|
||||
loadSprite("dead", "sprites/dead.png");
|
||||
loadSprite("triboi", "sprites/triboi.png");
|
||||
loadSprite("wolfi", "sprites/wolfi.png");
|
||||
loadSprite("bubble", "sprites/bubble.png");
|
||||
|
||||
k.add([k.pos(120, 80), k.sprite("bean")]);
|
||||
k.loadCrew("sprite", "cursor");
|
||||
k.loadCrew("sprite", "pointer");
|
||||
k.loadCrew("sprite", "kat");
|
||||
k.loadCrew("sprite", "pineapple");
|
||||
k.loadCrew("sprite", "been");
|
||||
k.loadCrew("font", "happy");
|
||||
|
||||
k.onClick(() => k.addKaboom(k.mousePos()));
|
||||
setLayers(["game", "hover", "ui"], "game");
|
||||
|
||||
const createPlayer = (scravatar: string) => {
|
||||
const player = add([
|
||||
sprite(scravatar),
|
||||
pos(outerWidth / 4, outerWidth / 4),
|
||||
anchor("center"),
|
||||
area({
|
||||
isSensor: true,
|
||||
}),
|
||||
rotate(),
|
||||
animate(),
|
||||
named("player"),
|
||||
"player",
|
||||
]);
|
||||
|
||||
player.animate("angle", [WOBBLE_ANGLE, -WOBBLE_ANGLE], {
|
||||
easing: easings.easeInOutCubic,
|
||||
direction: "ping-pong",
|
||||
duration: 1,
|
||||
});
|
||||
|
||||
const bubble = player.add([sprite("bubble"), anchor("center"), pos(30, -50)]);
|
||||
|
||||
const bubbleText = bubble.add([
|
||||
text("9", { font: "happy", size: 24 }),
|
||||
pos(-5, -24),
|
||||
color(Color.BLACK),
|
||||
timer(),
|
||||
]);
|
||||
|
||||
bubble.hidden = true;
|
||||
|
||||
player.on("countdown", () => {
|
||||
bubble.hidden = false;
|
||||
let time = 9;
|
||||
bubbleText.loop(
|
||||
1,
|
||||
() => {
|
||||
if (time === -1) {
|
||||
bubble.hidden = true;
|
||||
}
|
||||
|
||||
bubbleText.text = time.toString();
|
||||
time--;
|
||||
},
|
||||
11,
|
||||
);
|
||||
});
|
||||
|
||||
return player;
|
||||
};
|
||||
|
||||
scene("menu", () => {
|
||||
add([text("Choose your Scravatar", { font: "happy" })]);
|
||||
["wolfi", "octo", "dead", "triboi"].forEach((image, i) => {
|
||||
const selection = add([
|
||||
pos(88 * i + 100, 100),
|
||||
anchor("center"),
|
||||
circle(32, { fill: true }),
|
||||
opacity(0.1),
|
||||
z(-1),
|
||||
area(),
|
||||
]);
|
||||
|
||||
selection.add([
|
||||
text(image.toUpperCase(), { font: "happy", size: 14 }),
|
||||
anchor("center"),
|
||||
pos(0, 40),
|
||||
]);
|
||||
|
||||
const avatar = selection.add([
|
||||
sprite(image),
|
||||
rotate(),
|
||||
animate(),
|
||||
anchor("center"),
|
||||
]);
|
||||
|
||||
selection.onHover(() => {
|
||||
selection.opacity = 1;
|
||||
setCursor("pointer");
|
||||
});
|
||||
|
||||
selection.onHoverEnd(() => {
|
||||
selection.opacity = 0.1;
|
||||
setCursor("default");
|
||||
});
|
||||
|
||||
selection.onClick(() => {
|
||||
pushScene("game", image);
|
||||
}, "left");
|
||||
|
||||
avatar.animate("angle", [WOBBLE_ANGLE, -WOBBLE_ANGLE], {
|
||||
easing: easings.easeInOutCubic,
|
||||
direction: "ping-pong",
|
||||
duration: 1,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
scene("game", (scravatar: string) => {
|
||||
createCards();
|
||||
const player = createPlayer(scravatar);
|
||||
|
||||
onKeyDown(["w", "up"], () => {
|
||||
player.moveBy(0, -SPEED);
|
||||
});
|
||||
|
||||
onKeyDown(["a", "left"], () => {
|
||||
player.moveBy(-SPEED, 0);
|
||||
});
|
||||
|
||||
onKeyDown(["s", "down"], () => {
|
||||
player.moveBy(0, SPEED);
|
||||
});
|
||||
|
||||
onKeyDown(["d", "right"], () => {
|
||||
player.moveBy(SPEED, 0);
|
||||
});
|
||||
|
||||
onKeyDown("u", () => {
|
||||
player.trigger("countdown");
|
||||
});
|
||||
});
|
||||
|
||||
// pushScene("menu");
|
||||
pushScene("game", "wolfi");
|
||||
|
||||
1
tsconfig.json
Normal file
1
tsconfig.json
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
Reference in New Issue
Block a user