-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathClubBeach.tsx
73 lines (67 loc) · 1.92 KB
/
ClubBeach.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import InteractableSprite from "@/features/render/components/InteractableSprite";
import type { RenderEngineWorld } from "@/features/render/components/RenderEngine";
import { TileLoader } from "@/features/render/components/TileLoader";
import type { Bounds, Dimension, Position } from "@/features/render/lib/schema";
import { GenericLayout, type GenericTileSet, tileSize } from "./components/GenericLayout";
const getCollisionFunction = (
roomSizeTiles: Dimension,
) => {
const movementBounds: Bounds = {
tl: {
x: 1,
y: 1,
},
br: {
x: roomSizeTiles.w - 2,
y: roomSizeTiles.h - 2,
},
};
return (position: Position) => {
const { x, y } = position;
const insideBounds =
x >= movementBounds.tl.x &&
x <= movementBounds.br.x &&
y >= movementBounds.tl.y &&
y <= movementBounds.br.y;
return !insideBounds // || clipsObstacle;
};
};
export const ObstacleTypes = ["tree", "scream"] as const;
export type ObstacleType = (typeof ObstacleTypes)[number];
export const createClubBeach = (
tileSet: GenericTileSet,
roomDimensions: Dimension,
// windowSpacing = 4,
// obstacleSpacing?: Dimension,
// obstacleType: ObstacleType = "tree",
onViewFeed: () => void,
): RenderEngineWorld => {
return {
collision: getCollisionFunction(roomDimensions, /*obstacleLocations*/),
tileSet: (
<TileLoader alias="clubbeach" src="assets/tiles/clubbeach.json">
<GenericLayout
tileSet={tileSet}
roomSizeTiles={roomDimensions}
// windowSpacing={windowSpacing}
/>
</TileLoader>
),
spritesBg: (
<>
<InteractableSprite
image="assets/sprite/object/board.png"
scale={4}
anchor={{ x: 0.5, y: 0.45 }}
onclick={() => onViewFeed()}
x={tileSize.w * 5.5}
y={tileSize.h * 1.25}
/>
</>
),
spritesFg: (
<>
</>
),
};
};