summaryrefslogtreecommitdiff
path: root/test-client/tiles.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test-client/tiles.ts')
-rw-r--r--test-client/tiles.ts159
1 files changed, 105 insertions, 54 deletions
diff --git a/test-client/tiles.ts b/test-client/tiles.ts
index dee93c21..a2b46f59 100644
--- a/test-client/tiles.ts
+++ b/test-client/tiles.ts
@@ -84,7 +84,7 @@ function cross(size: number, stroke: string, stroke_width = 0.05): Component {
}
}
-function arrange_items(...items: string[]): Component[] {
+function arrange_items(...items: ItemName[]): Component[] {
return items.flatMap((item, index) => {
const t = index / items.length * Math.PI * 2.
const radius = items.length == 1 ? 0 : (0.4 / items.length)
@@ -108,81 +108,132 @@ const door: Component = c => {
c.fillRect(-0.5, -0.1, 1, 0.2)
}
-const plate = [circle(0.4, "#b6b6b6", "#f7f7f7", 0.02)];
-const pot = [circle(0.35, "rgb(29, 29, 29)", "rgb(39, 39, 39)", 0.04)];
-const foodprocessor = [circle(0.35, "rgb(86, 168, 189)", "rgb(88, 222, 255)", 0.04)];
-const burned = [circle(0.3, "rgb(61, 18, 0)"), cross(0.2, "red", 0.02)]
-const leek = [circle(0.3, "rgb(50, 133, 17)")]
+const iref = (name: keyof typeof ITEMS): Component => c => ITEMS[name].forEach(f => f(c))
+const tref = (name: keyof typeof TILES): Component => c => TILES[name].forEach(f => f(c))
-const ITEMS: { [key: string]: Component[] } = {
- "pot": pot,
- "foodprocessor": foodprocessor,
- "leek": leek,
- "leek-foodprocessor": [...foodprocessor, ...leek],
- "leek-pot": [...pot, ...leek],
- "raw-steak": [circle(0.3, "#cc3705")],
- "raw-steak-pot": [...pot, circle(0.3, "#cc3705")],
- "steak-pot": [...pot, circle(0.3, "#702200")],
- "burned-pot": [...pot, ...burned],
- "steak": [circle(0.3, "#702200")],
+type HelperItemName = "steak" | "milk" | "cooked-rice" | "curry" | "strawberry-icecream" | "strawberry-shake"
+type ItemName = HelperItemName | "dirty-plate" | "plate" | "tomato" | "raw-steak" | "flour" | "leek" | "rice" | "fish" | "coconut" | "strawberry" | "foodprocessor" | "flour-foodprocessor" | "dough-foodprocessor" | "dough" | "bread" | "burned" | "bread-slice" | "pot" | "raw-steak-pot" | "steak-pot" | "burned-pot" | "sliced-tomato" | "steak-plate" | "sliced-tomato-plate" | "bread-slice-plate" | "bread-slice-steak-plate" | "bread-slice-sliced-tomato-plate" | "bread-slice-sliced-tomato-steak-plate" | "sliced-tomato-steak-plate" | "tomato-foodprocessor" | "tomato-juice-foodprocessor" | "leek-pot" | "tomato-juice-pot" | "leek-tomato-juice-pot" | "tomato-soup-pot" | "tomato-soup-plate" | "sliced-fish" | "rice-pot" | "cooked-rice-pot" | "nigiri" | "nigiri-plate" | "strawberry-foodprocessor" | "strawberry-puree-foodprocessor" | "coconut-foodprocessor" | "milk-foodprocessor" | "coconut-strawberry-puree-foodprocessor" | "strawberry-shake-foodprocessor" | "milk-strawberry-foodprocessor" | "strawberry-icecream-foodprocessor" | "strawberry-icecream-plate" | "rice-foodprocessor" | "rice-flour-foodprocessor" | "rice-flour-pot" | "mochi-dough-pot" | "strawberry-mochi" | "glass" | "strawberry-shake-glass" | "tomato-juice-glass" | "water-glass" | "milk-pot" | "tomato-pot" | "leek-milk-pot" | "leek-tomato-pot" | "leek-milk-tomato-pot" | "milk-tomato-pot" | "curry-pot" | "cooked-rice-plate" | "curry-plate" | "cooked-rice-curry-plate"
+type TileName = "sink" | "conveyor" | "book" | "tomato-crate" | "raw-steak-crate" | "flour-crate" | "leek-crate" | "rice-crate" | "fish-crate" | "coconut-crate" | "strawberry-crate" | "oven" | "cuttingboard" | "stove" | "freezer" | "trash" | "grass" | "tree" | "wall" | "chair" | "floor" | "door" | "counter" | "wall-window" | "table" | "counter-window" | "path" | "lamp" | "street"
+
+const pot = iref("pot")
+const plate = iref("plate")
+const foodprocessor = iref("foodprocessor")
+const glass = iref("glass")
+const ITEMS: { [key in ItemName]: Component[] } = {
+ "tomato": [circle(0.3, "#d63838")],
+ "raw-steak": [circle(0.3, "#ca3510")],
"flour": [circle(0.3, "#d8c9c2")],
- "flour-foodprocessor": [...foodprocessor, circle(0.3, "#d8c9c2")],
+ "leek": [circle(0.3, "rgb(50, 133, 17)")],
+ "rice": [circle(0.3, "rgb(163, 163, 163)")],
+ "fish": [circle(0.3, "rgb(62, 66, 104)")],
+ "coconut": [circle(0.3, "rgb(75, 49, 25)")],
+ "strawberry": [circle(0.3, "rgb(228, 79, 111)")],
+
+ "pot": [circle(0.35, "rgb(29, 29, 29)", "rgb(39, 39, 39)", 0.04)],
+ "foodprocessor": [circle(0.35, "rgb(86, 168, 189)", "rgb(88, 222, 255)", 0.04)],
+ "plate": [circle(0.4, "#b6b6b6", "#f7f7f7", 0.02)],
+ "glass": [circle(0.35, "rgb(150, 255, 237)", "rgb(52, 129, 155)", 0.02)],
+
+ "steak": [circle(0.3, "#702200")],
"dough": [circle(0.3, "#b38d7d")],
- "dough-foodprocessor": [...foodprocessor, circle(0.3, "#b38d7d")],
"bread": [circle(0.3, "#853e20")],
+ "milk": [circle(0.3, "rgb(252, 243, 208)")],
+ "curry": [circle(0.3, "rgb(185, 67, 37)")],
+ "cooked-rice": [circle(0.3, "rgb(233, 233, 233)")],
"bread-slice": [circle(0.3, "#853e20")],
- "tomato": [circle(0.3, "#d63838")],
- "tomato-foodprocessor": [...foodprocessor, circle(0.3, "#d63838")],
- "tomato-juice-foodprocessor": [...foodprocessor, circle(0.3, "#b80000")],
- "tomato-juice-pot": [...pot, circle(0.3, "#b80000")],
- "leek-tomato-juice-pot": [...pot, circle(0.3, "#dd5800")],
- "tomato-soup-pot": [...pot, circle(0.3, "#ff2600")],
- "tomato-soup-plate": [...plate, circle(0.3, "#ff2600")],
- "burned": burned,
- "sliced-tomato": [circle(0.3, "#d16363", "#d63838", 0.08)],
- "plate": plate,
- "dirty-plate": [circle(0.4, "#947a6f", "#d3a187", 0.02)],
+ "sliced-fish": [circle(0.3, "salmon", "rgb(62, 66, 104)")],
+ "nigiri": [circle(0.25, "rgb(233, 233, 233)", "salmon")],
+ "burned": [circle(0.3, "rgb(61, 18, 0)"), cross(0.2, "red", 0.02)],
+ "strawberry-icecream": [circle(0.2, "rgb(250, 148, 236)")],
+ "strawberry-shake": [circle(0.3, "rgb(255, 180, 180)")],
- "steak-plate": [...plate, ...arrange_items("steak")],
- "bread-slice-plate": [...plate, ...arrange_items("bread-slice")],
- "sliced-tomato-plate": [...plate, ...arrange_items("sliced-tomato")],
- "bread-slice-steak-plate": [...plate, ...arrange_items("bread-slice", "steak")],
- "bread-slice-sliced-tomato-plate": [...plate, ...arrange_items("bread-slice", "sliced-tomato")],
- "sliced-tomato-steak-plate": [...plate, ...arrange_items("sliced-tomato", "steak")],
- "bread-slice-sliced-tomato-steak-plate": [...plate, ...arrange_items("bread-slice", "sliced-tomato", "steak")],
+ "bread-slice-plate": [plate, ...arrange_items("bread-slice")],
+ "bread-slice-sliced-tomato-plate": [plate, ...arrange_items("bread-slice", "sliced-tomato")],
+ "bread-slice-sliced-tomato-steak-plate": [plate, ...arrange_items("bread-slice", "sliced-tomato", "steak")],
+ "bread-slice-steak-plate": [plate, ...arrange_items("bread-slice", "steak")],
+ "burned-pot": [pot, iref("burned")],
+ "coconut-foodprocessor": [foodprocessor, iref("coconut")],
+ "coconut-strawberry-puree-foodprocessor": [foodprocessor, iref("coconut"), iref("strawberry")],
+ "cooked-rice-curry-plate": [plate, ...arrange_items("curry", "cooked-rice")],
+ "cooked-rice-plate": [plate, iref("cooked-rice")],
+ "cooked-rice-pot": [pot, iref("rice")],
+ "curry-plate": [plate, iref("curry")],
+ "curry-pot": [pot, iref("curry")],
+ "dirty-plate": [circle(0.4, "#947a6f", "#d3a187", 0.02)],
+ "dough-foodprocessor": [foodprocessor, circle(0.3, "#b38d7d")],
+ "flour-foodprocessor": [foodprocessor, circle(0.3, "#d8c9c2")],
+ "leek-milk-pot": [pot, ...arrange_items("leek", "milk")],
+ "leek-milk-tomato-pot": [pot, ...arrange_items("leek", "milk", "tomato")],
+ "leek-pot": [pot, iref("leek")],
+ "leek-tomato-juice-pot": [pot, circle(0.3, "#dd5800")],
+ "leek-tomato-pot": [pot, ...arrange_items("leek", "tomato")],
+ "milk-foodprocessor": [foodprocessor, iref("milk")],
+ "milk-pot": [pot, iref("milk")],
+ "milk-strawberry-foodprocessor": [foodprocessor, iref("strawberry"), circle(0.2, "rgb(252, 243, 208)")],
+ "milk-tomato-pot": [pot, ...arrange_items("milk", "tomato")],
+ "mochi-dough-pot": [pot, circle(0.3, "rgb(172, 162, 151)")],
+ "nigiri-plate": [plate, iref("nigiri")],
+ "raw-steak-pot": [pot, iref("raw-steak")],
+ "rice-flour-foodprocessor": [foodprocessor, iref("rice")],
+ "rice-flour-pot": [pot, iref("rice")],
+ "rice-foodprocessor": [foodprocessor, iref("rice")],
+ "rice-pot": [pot, iref("rice")],
+ "sliced-tomato-plate": [plate, ...arrange_items("sliced-tomato")],
+ "sliced-tomato-steak-plate": [plate, ...arrange_items("sliced-tomato", "steak")],
+ "sliced-tomato": [circle(0.3, "#d16363", "#d63838", 0.08)],
+ "steak-plate": [plate, ...arrange_items("steak")],
+ "steak-pot": [pot, iref("steak")],
+ "strawberry-foodprocessor": [foodprocessor, iref("strawberry")],
+ "strawberry-icecream-foodprocessor": [foodprocessor, iref("strawberry-icecream")],
+ "strawberry-icecream-plate": [plate, iref("strawberry-icecream")],
+ "strawberry-mochi": [pot, circle(0.2, "rgb(161, 111, 132)")],
+ "strawberry-puree-foodprocessor": [foodprocessor, iref("strawberry")],
+ "strawberry-shake-foodprocessor": [foodprocessor, iref("strawberry-shake")],
+ "strawberry-shake-glass": [glass, iref("strawberry-shake")],
+ "tomato-foodprocessor": [foodprocessor, circle(0.3, "#d63838")],
+ "tomato-juice-foodprocessor": [foodprocessor, circle(0.3, "#b80000")],
+ "tomato-juice-glass": [glass, circle(0.3, "#b80000")],
+ "tomato-juice-pot": [pot, circle(0.3, "#b80000")],
+ "tomato-pot": [pot, iref("tomato")],
+ "tomato-soup-plate": [plate, circle(0.3, "#ff2600")],
+ "tomato-soup-pot": [pot, circle(0.3, "#ff2600")],
+ "water-glass": [glass, circle(0.3, "rgb(86, 92, 206)")],
}
-const table = [base("rgb(133, 76, 38)")];
-const floor = [base("#333", "#222", 0.05)];
-const counter = [base("rgb(182, 172, 164)")];
-const crate = (i: string) => [base("#60701e", "#b9da37", 0.05), ...ITEMS[i]];
-
-const TILES: { [key: string]: Component[] } = {
- "floor": floor,
+const crate = (i: ItemName) => [base("#60701e", "#b9da37", 0.05), iref(i)];
+const floor = tref("floor");
+const counter = tref("counter");
+const TILES: { [key in TileName]: Component[] } = {
+ "floor": [base("#333", "#222", 0.05)],
"street": [base("rgb(19, 19, 19)")],
- "table": table,
- "door": [...floor, door],
- "chair": [...floor, circle(0.45, "rgb(136, 83, 41)")],
+ "table": [base("rgb(133, 76, 38)")],
+ "door": [floor, door],
+ "chair": [floor, circle(0.45, "rgb(136, 83, 41)")],
"wall": [base("rgb(0, 14, 56)")],
"wall-window": [base("rgb(19, 40, 102)")],
- "counter": counter,
+ "counter": [base("rgb(182, 172, 164)")],
"counter-window": [base("rgb(233, 233, 233)")],
"grass": [base("rgb(0, 107, 4)")],
"path": [base("rgb(100, 80, 55)")],
"conveyor": [base("rgb(107, 62, 128)")],
"tree": [base("rgb(1, 82, 4)")],
- "cuttingboard": [...counter, rect(0.3, "rgb(158, 236, 68)", "rgb(158, 236, 68)", 0.2)],
- "trash": [...floor, circle(0.4, "rgb(20, 20, 20)"), cross(0.3, "rgb(90, 36, 36)")],
+ "cuttingboard": [counter, rect(0.3, "rgb(158, 236, 68)", "rgb(158, 236, 68)", 0.2)],
+ "trash": [floor, circle(0.4, "rgb(20, 20, 20)"), cross(0.3, "rgb(90, 36, 36)")],
"sink": [base("rgb(131, 129, 161)", "rgb(177, 174, 226)", 0.2)],
"oven": [base("rgb(241, 97, 61)", "rgb(109, 84, 84)", 0.3)],
"freezer": [base("rgb(61, 97, 241)", "rgb(84, 88, 109)", 0.3)],
- "stove": [...counter, circle(0.4, "#444", "#999")],
- "book": [...counter, rect(0.2, "rgb(88, 44, 7)")],
+ "stove": [counter, circle(0.4, "#444", "#999")],
+ "book": [counter, rect(0.2, "rgb(88, 44, 7)")],
+ "lamp": [tref("grass"), rect(0.3, "rgb(255, 217, 127)", "rgb(32, 32, 32)", 0.1)],
"flour-crate": crate("flour"),
"raw-steak-crate": crate("raw-steak"),
"tomato-crate": crate("tomato"),
"leek-crate": crate("leek"),
+ "rice-crate": crate("rice"),
+ "fish-crate": crate("fish"),
+ "coconut-crate": crate("coconut"),
+ "strawberry-crate": crate("strawberry"),
}
function debug_label(ctx: CanvasRenderingContext2D, name: string) {
@@ -199,7 +250,7 @@ function debug_label(ctx: CanvasRenderingContext2D, name: string) {
ctx.restore()
}
-export function draw_item_sprite(ctx: CanvasRenderingContext2D, name: string) {
+export function draw_item_sprite(ctx: CanvasRenderingContext2D, name: ItemName) {
const comps = ITEMS[name]
if (comps) {
for (const c of comps) {
@@ -210,7 +261,7 @@ export function draw_item_sprite(ctx: CanvasRenderingContext2D, name: string) {
debug_label(ctx, name)
}
}
-export function draw_tile_sprite(ctx: CanvasRenderingContext2D, name: string) {
+export function draw_tile_sprite(ctx: CanvasRenderingContext2D, name: TileName) {
const comps = TILES[name]
if (comps) {
for (const c of comps) {