From c24adc47a8ccd7072a79b2e27b65f516c7b338d2 Mon Sep 17 00:00:00 2001 From: cha0s Date: Tue, 17 Sep 2024 01:25:39 -0500 Subject: [PATCH] refactor: resources --- .eslintrc.cjs | 3 +- app/ecs/components/alive.js | 2 +- app/react/components/pixi/tile-layer.jsx | 2 +- app/root.css | 4 +-- app/routes/_main-menu.play.$.$/route.jsx | 2 +- app/routes/gen/route.jsx | 8 ++--- app/server/create/forest.js | 10 +++---- app/server/create/homestead.js | 28 +++++++++--------- app/server/create/house.js | 2 +- app/server/create/player.js | 6 ++-- app/server/create/town.js | 4 +-- public/assets/brush/brush.json | 5 ---- public/assets/furball/furball.json | 4 --- public/assets/magic-swords/magic-swords.json | 5 ---- public/assets/potion/potion.json | 5 ---- public/assets/tomato-seeds/tomato-seeds.json | 14 --------- public/assets/tomato/tomato.json | 3 -- public/assets/watering-can/watering-can.json | 14 --------- public/{assets => }/fonts/Cookbook.woff | Bin public/{assets => }/fonts/Joystix.woff | Bin .../assets => resources}/ambient/blossom.json | 0 .../assets => resources}/ambient/blossom.png | Bin .../assets => resources}/ambient/flower.json | 0 .../assets => resources}/ambient/flower.png | Bin .../assets => resources}/ambient/shrub.json | 0 .../assets => resources}/ambient/shrub.png | Bin .../assets => resources}/ambient/tree.json | 0 {public/assets => resources}/ambient/tree.png | Bin resources/brush/brush.json | 5 ++++ {public/assets => resources}/brush/brush.png | Bin {public/assets => resources}/brush/brush.wav | Bin {public/assets => resources}/brush/start.js | 6 ++-- {public/assets => resources}/chest/chest.json | 0 {public/assets => resources}/chest/chest.png | Bin {public/assets => resources}/dude/dude.json | 0 {public/assets => resources}/dude/dude.png | Bin .../farm/animals/bull-adult/bull-adult.png | Bin .../farm/animals/bull-baby/bull-baby.png | Bin .../farm/animals/cow-adult/cow-adult.json | 0 .../farm/animals/cow-adult/cow-adult.png | Bin .../farm/animals/cow-adult/initial.js | 0 .../farm/animals/cow-baby/cow-baby.png | Bin .../farm/animals/goat-black/goat-black.png | Bin .../farm/animals/goat-white/goat-white.json | 0 .../farm/animals/goat-white/goat-white.png | Bin .../farm/animals/goat-white/initial.js | 0 .../farm/animals/pig-adult/pig-adult.png | Bin .../farm/animals/pig-baby/pig-baby.png | Bin resources/furball/furball.json | 4 +++ .../assets => resources}/furball/furball.png | Bin {public/assets => resources}/heart/heart.png | Bin {public/assets => resources}/hoe/dig.wav | Bin {public/assets => resources}/hoe/hoe.json | 6 ++-- {public/assets => resources}/hoe/icon.png | Bin .../hoe/projection-check.js | 0 {public/assets => resources}/hoe/start.js | 2 +- {public/assets => resources}/kitty/initial.js | 0 {public/assets => resources}/kitty/kitty.json | 0 {public/assets => resources}/kitty/kitty.png | Bin .../magic-swords/collision-start.js | 0 .../magic-swords/icon.png | Bin .../magic-swords/magic-sword-shot.json | 0 .../magic-swords/magic-sword-shot.png | Bin resources/magic-swords/magic-swords.json | 5 ++++ .../magic-swords/start.js | 4 +-- .../misc/death-default.js | 0 {public/assets => resources}/potion/icon.png | Bin resources/potion/potion.json | 5 ++++ {public/assets => resources}/potion/start.js | 0 .../shit-shack/shit-shack.json | 0 .../shit-shack/shit-shack.normals.json | 0 .../shit-shack/shit-shack.normals.png | Bin .../shit-shack/shit-shack.png | Bin {public/assets => resources}/sow.wav | Bin {public/assets => resources}/sprite.js | 0 {public/assets => resources}/tileset.json | 0 .../assets => resources}/tileset.normals.json | 0 .../assets => resources}/tileset.normals.png | Bin {public/assets => resources}/tileset.png | Bin .../assets => resources}/tomato-plant/grow.js | 0 .../tomato-plant/interact.js | 4 +-- .../tomato-plant/may-grow.js | 0 .../tomato-plant/tomato-plant.json | 0 .../tomato-plant/tomato-plant.png | Bin .../tomato-seeds/icon.png | Bin .../tomato-seeds/projection-check.js | 0 .../tomato-seeds/start.js | 10 +++---- resources/tomato-seeds/tomato-seeds.json | 14 +++++++++ .../tomato/tomato-sprite.json | 0 resources/tomato/tomato.json | 3 ++ .../assets => resources}/tomato/tomato.png | Bin .../watering-can/icon.png | Bin .../watering-can/projection-check.js | 0 .../watering-can/start.js | 2 +- .../watering-can/water.wav | Bin resources/watering-can/watering-can.json | 14 +++++++++ {public/assets => resources}/yuff.wav | Bin server.js | 6 ++++ stories/hotbar.stories.js | 2 +- stories/slot.stories.js | 2 +- 100 files changed, 110 insertions(+), 105 deletions(-) delete mode 100644 public/assets/brush/brush.json delete mode 100644 public/assets/furball/furball.json delete mode 100644 public/assets/magic-swords/magic-swords.json delete mode 100644 public/assets/potion/potion.json delete mode 100644 public/assets/tomato-seeds/tomato-seeds.json delete mode 100644 public/assets/tomato/tomato.json delete mode 100644 public/assets/watering-can/watering-can.json rename public/{assets => }/fonts/Cookbook.woff (100%) rename public/{assets => }/fonts/Joystix.woff (100%) rename {public/assets => resources}/ambient/blossom.json (100%) rename {public/assets => resources}/ambient/blossom.png (100%) rename {public/assets => resources}/ambient/flower.json (100%) rename {public/assets => resources}/ambient/flower.png (100%) rename {public/assets => resources}/ambient/shrub.json (100%) rename {public/assets => resources}/ambient/shrub.png (100%) rename {public/assets => resources}/ambient/tree.json (100%) rename {public/assets => resources}/ambient/tree.png (100%) create mode 100644 resources/brush/brush.json rename {public/assets => resources}/brush/brush.png (100%) rename {public/assets => resources}/brush/brush.wav (100%) rename {public/assets => resources}/brush/start.js (93%) rename {public/assets => resources}/chest/chest.json (100%) rename {public/assets => resources}/chest/chest.png (100%) rename {public/assets => resources}/dude/dude.json (100%) rename {public/assets => resources}/dude/dude.png (100%) rename {public/assets => resources}/farm/animals/bull-adult/bull-adult.png (100%) rename {public/assets => resources}/farm/animals/bull-baby/bull-baby.png (100%) rename {public/assets => resources}/farm/animals/cow-adult/cow-adult.json (100%) rename {public/assets => resources}/farm/animals/cow-adult/cow-adult.png (100%) rename {public/assets => resources}/farm/animals/cow-adult/initial.js (100%) rename {public/assets => resources}/farm/animals/cow-baby/cow-baby.png (100%) rename {public/assets => resources}/farm/animals/goat-black/goat-black.png (100%) rename {public/assets => resources}/farm/animals/goat-white/goat-white.json (100%) rename {public/assets => resources}/farm/animals/goat-white/goat-white.png (100%) rename {public/assets => resources}/farm/animals/goat-white/initial.js (100%) rename {public/assets => resources}/farm/animals/pig-adult/pig-adult.png (100%) rename {public/assets => resources}/farm/animals/pig-baby/pig-baby.png (100%) create mode 100644 resources/furball/furball.json rename {public/assets => resources}/furball/furball.png (100%) rename {public/assets => resources}/heart/heart.png (100%) rename {public/assets => resources}/hoe/dig.wav (100%) rename {public/assets => resources}/hoe/hoe.json (51%) rename {public/assets => resources}/hoe/icon.png (100%) rename {public/assets => resources}/hoe/projection-check.js (100%) rename {public/assets => resources}/hoe/start.js (97%) rename {public/assets => resources}/kitty/initial.js (100%) rename {public/assets => resources}/kitty/kitty.json (100%) rename {public/assets => resources}/kitty/kitty.png (100%) rename {public/assets => resources}/magic-swords/collision-start.js (100%) rename {public/assets => resources}/magic-swords/icon.png (100%) rename {public/assets => resources}/magic-swords/magic-sword-shot.json (100%) rename {public/assets => resources}/magic-swords/magic-sword-shot.png (100%) create mode 100644 resources/magic-swords/magic-swords.json rename {public/assets => resources}/magic-swords/start.js (93%) rename {public/assets => resources}/misc/death-default.js (100%) rename {public/assets => resources}/potion/icon.png (100%) create mode 100644 resources/potion/potion.json rename {public/assets => resources}/potion/start.js (100%) rename {public/assets => resources}/shit-shack/shit-shack.json (100%) rename {public/assets => resources}/shit-shack/shit-shack.normals.json (100%) rename {public/assets => resources}/shit-shack/shit-shack.normals.png (100%) rename {public/assets => resources}/shit-shack/shit-shack.png (100%) rename {public/assets => resources}/sow.wav (100%) rename {public/assets => resources}/sprite.js (100%) rename {public/assets => resources}/tileset.json (100%) rename {public/assets => resources}/tileset.normals.json (100%) rename {public/assets => resources}/tileset.normals.png (100%) rename {public/assets => resources}/tileset.png (100%) rename {public/assets => resources}/tomato-plant/grow.js (100%) rename {public/assets => resources}/tomato-plant/interact.js (95%) rename {public/assets => resources}/tomato-plant/may-grow.js (100%) rename {public/assets => resources}/tomato-plant/tomato-plant.json (100%) rename {public/assets => resources}/tomato-plant/tomato-plant.png (100%) rename {public/assets => resources}/tomato-seeds/icon.png (100%) rename {public/assets => resources}/tomato-seeds/projection-check.js (100%) rename {public/assets => resources}/tomato-seeds/start.js (88%) create mode 100644 resources/tomato-seeds/tomato-seeds.json rename {public/assets => resources}/tomato/tomato-sprite.json (100%) create mode 100644 resources/tomato/tomato.json rename {public/assets => resources}/tomato/tomato.png (100%) rename {public/assets => resources}/watering-can/icon.png (100%) rename {public/assets => resources}/watering-can/projection-check.js (100%) rename {public/assets => resources}/watering-can/start.js (96%) rename {public/assets => resources}/watering-can/water.wav (100%) create mode 100644 resources/watering-can/watering-can.json rename {public/assets => resources}/yuff.wav (100%) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 55ec17b..a56fa0e 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -71,7 +71,6 @@ module.exports = { '.eslintrc.cjs', 'server.js', 'vite.config.js', - 'public/assets/tileset.js', ], env: { node: true, @@ -81,7 +80,7 @@ module.exports = { // Assets { files: [ - 'public/assets/**/*.js', + 'resources/**/*.js', ], rules: { 'no-undef': 0, diff --git a/app/ecs/components/alive.js b/app/ecs/components/alive.js index be03f84..7266d3b 100644 --- a/app/ecs/components/alive.js +++ b/app/ecs/components/alive.js @@ -44,7 +44,7 @@ export default class Alive extends Component { } static properties = { deathScript: { - defaultValue: '/assets/misc/death-default.js', + defaultValue: '/resources/misc/death-default.js', type: 'string', }, health: {type: 'uint32'}, diff --git a/app/react/components/pixi/tile-layer.jsx b/app/react/components/pixi/tile-layer.jsx index 815e127..a7fd40c 100644 --- a/app/react/components/pixi/tile-layer.jsx +++ b/app/react/components/pixi/tile-layer.jsx @@ -18,7 +18,7 @@ const TileLayerInternal = PixiComponent('TileLayer', { }, applyProps: (container, {tileLayer: oldTileLayer}, props) => { const {asset, group, renderer, tileLayer} = props; - const extless = tileLayer.source.slice('/assets/'.length, -'.json'.length); + const extless = tileLayer.source.slice('/resources/'.length, -'.json'.length); const {textures} = asset; if (tileLayer === oldTileLayer) { return; diff --git a/app/root.css b/app/root.css index dd9a515..16809e1 100644 --- a/app/root.css +++ b/app/root.css @@ -29,10 +29,10 @@ body { @font-face { font-family: "Cookbook"; - src: url("/assets/fonts/Cookbook.woff"); + src: url("/fonts/Cookbook.woff"); } @font-face { font-family: "Joystix"; - src: url("/assets/fonts/Joystix.woff"); + src: url("/fonts/Joystix.woff"); } diff --git a/app/routes/_main-menu.play.$.$/route.jsx b/app/routes/_main-menu.play.$.$/route.jsx index b1d146d..4cd43e0 100644 --- a/app/routes/_main-menu.play.$.$/route.jsx +++ b/app/routes/_main-menu.play.$.$/route.jsx @@ -122,7 +122,7 @@ export default function PlaySpecific() { // let source = true; // async function play() { // const ctx = new AudioContext(); - // const response = await fetch(new URL('/assets/yuff.wav', window.location.origin)); + // const response = await fetch(new URL('/resources/yuff.wav', window.location.origin)); // const buffer = await ctx.decodeAudioData(await response.arrayBuffer()); // if (!source) { // return; diff --git a/app/routes/gen/route.jsx b/app/routes/gen/route.jsx index 05acee0..00b0ca1 100644 --- a/app/routes/gen/route.jsx +++ b/app/routes/gen/route.jsx @@ -78,7 +78,7 @@ function Gen() { ), compute: (x, y) => ({ anchor:{x: 0.5, y: 0.875}, - image: '/assets/ambient/tree.png', + image: '/resources/ambient/tree.png', x: x * 16, y: y * 16, }), @@ -91,7 +91,7 @@ function Gen() { ), compute: (x, y, noise) => ({ anchor:{x: 0.5, y: 0.7}, - image: '/assets/ambient/flower.png', + image: '/resources/ambient/flower.png', x: x * 16 + (noise(x, y) * 8 - 4), y: y * 16 + (noise(y, x) * 8 - 4), }), @@ -104,7 +104,7 @@ function Gen() { ), compute: (x, y, noise) => ({ anchor:{x: 0.5, y: 0.7}, - image: '/assets/ambient/shrub.png', + image: '/resources/ambient/shrub.png', x: x * 16 + (noise(x, y) * 8 - 4), y: y * 16 + (noise(y, x) * 8 - 4), }), @@ -117,7 +117,7 @@ function Gen() { Math.ceil(area.x / CHUNK_SIZE) * Math.ceil(area.y / CHUNK_SIZE) ).fill(0).map(() => ({})), data: Array(area.x * area.y).fill(1), - source: '/assets/tileset.json', + source: '/resources/tileset.json', tileSize: {x: 16, y: 16}, }; const tileGenerator = new Generator({ diff --git a/app/server/create/forest.js b/app/server/create/forest.js index e490062..59dfa91 100644 --- a/app/server/create/forest.js +++ b/app/server/create/forest.js @@ -63,13 +63,13 @@ export default async function createForest() { { area, data: Array(w * h).fill(0), - source: '/assets/tileset.json', + source: '/resources/tileset.json', tileSize: {x: 16, y: 16}, }, { area, data: Array(w * h).fill(0), - source: '/assets/tileset.json', + source: '/resources/tileset.json', tileSize: {x: 16, y: 16}, }, ], @@ -113,7 +113,7 @@ export default async function createForest() { Position: entityPosition(x, y), Sprite: { anchorY: 0.7, - source: '/assets/ambient/shrub.json', + source: '/resources/ambient/shrub.json', }, VisibleAabb: {}, }); @@ -123,7 +123,7 @@ export default async function createForest() { Position: entityPosition(x, y), Sprite: { anchorY: 0.875, - source: '/assets/ambient/tree.json', + source: '/resources/ambient/tree.json', }, VisibleAabb: {}, }); @@ -134,7 +134,7 @@ export default async function createForest() { Position: entityPosition(x, y), Sprite: { anchorY: 0.7, - source: '/assets/ambient/flower.json', + source: '/resources/ambient/flower.json', }, VisibleAabb: {}, }); diff --git a/app/server/create/homestead.js b/app/server/create/homestead.js index 2e74ff5..7c7617d 100644 --- a/app/server/create/homestead.js +++ b/app/server/create/homestead.js @@ -33,13 +33,13 @@ export default async function createHomestead(id) { { area, data, - source: '/assets/tileset.json', + source: '/resources/tileset.json', tileSize: {x: 16, y: 16}, }, { area, data: Array(area.x * area.y).fill(0), - source: '/assets/tileset.json', + source: '/resources/tileset.json', tileSize: {x: 16, y: 16}, }, ], @@ -68,7 +68,7 @@ export default async function createHomestead(id) { Sprite: { anchorX: 0.5, anchorY: 0.8, - source: '/assets/shit-shack/shit-shack.json', + source: '/resources/shit-shack/shit-shack.json', }, Ticking: {}, VisibleAabb: {}, @@ -135,19 +135,19 @@ export default async function createHomestead(id) { slots: { 2: { qty: 1, - source: '/assets/watering-can/watering-can.json', + source: '/resources/watering-can/watering-can.json', }, 3: { qty: 1, - source: '/assets/tomato-seeds/tomato-seeds.json', + source: '/resources/tomato-seeds/tomato-seeds.json', }, 4: { qty: 1, - source: '/assets/hoe/hoe.json', + source: '/resources/hoe/hoe.json', }, 5: { qty: 1, - source: '/assets/brush/brush.json', + source: '/resources/brush/brush.json', }, }, }, @@ -155,7 +155,7 @@ export default async function createHomestead(id) { Sprite: { anchorX: 0.5, anchorY: 0.7, - source: '/assets/chest/chest.json', + source: '/resources/chest/chest.json', }, Ticking: {}, VisibleAabb: {}, @@ -166,7 +166,7 @@ export default async function createHomestead(id) { ...animalJson, Behaving: { routines: { - initial: '/assets/kitty/initial.js', + initial: '/resources/kitty/initial.js', }, }, Collider: { @@ -209,7 +209,7 @@ export default async function createHomestead(id) { ...animalJson.Sprite, anchorX: 0.5, anchorY: 0.7, - source: '/assets/kitty/kitty.json', + source: '/resources/kitty/kitty.json', speed: 0.115, }, Tags: {tags: ['kittan']}, @@ -220,7 +220,7 @@ export default async function createHomestead(id) { ...animalJson, Behaving: { routines: { - initial: '/assets/farm/animals/cow-adult/initial.js', + initial: '/resources/farm/animals/cow-adult/initial.js', }, }, Collider: { @@ -260,7 +260,7 @@ export default async function createHomestead(id) { ...animalJson.Sprite, anchorX: 0.5, anchorY: 0.8, - source: '/assets/farm/animals/cow-adult/cow-adult.json', + source: '/resources/farm/animals/cow-adult/cow-adult.json', speed: 0.25, }, }); @@ -270,7 +270,7 @@ export default async function createHomestead(id) { ...animalJson, Behaving: { routines: { - initial: '/assets/farm/animals/goat-white/initial.js', + initial: '/resources/farm/animals/goat-white/initial.js', }, }, Collider: { @@ -309,7 +309,7 @@ export default async function createHomestead(id) { ...animalJson.Sprite, anchorX: 0.5, anchorY: 0.8, - source: '/assets/farm/animals/goat-white/goat-white.json', + source: '/resources/farm/animals/goat-white/goat-white.json', speed: 0.25, }, }); diff --git a/app/server/create/house.js b/app/server/create/house.js index 9e45e9c..218d890 100644 --- a/app/server/create/house.js +++ b/app/server/create/house.js @@ -11,7 +11,7 @@ export default async function createHouse(Ecs, id) { { area, data: Array(area.x * area.y).fill(0).map(() => 5 + Math.floor(Math.random() * 2)), - source: '/assets/tileset.json', + source: '/resources/tileset.json', tileSize: {x: 16, y: 16}, } ], diff --git a/app/server/create/player.js b/app/server/create/player.js index b2a3808..f5c1080 100644 --- a/app/server/create/player.js +++ b/app/server/create/player.js @@ -24,11 +24,11 @@ export default async function createPlayer(id) { slots: { 1: { qty: 100, - source: '/assets/potion/potion.json', + source: '/resources/potion/potion.json', }, 2: { qty: 1, - source: '/assets/magic-swords/magic-swords.json', + source: '/resources/magic-swords/magic-swords.json', }, }, }, @@ -44,7 +44,7 @@ export default async function createPlayer(id) { anchorY: 0.9, animation: 'moving:down', frame: 0, - source: '/assets/dude/dude.json', + source: '/resources/dude/dude.json', speed: 0.115, }, Ticking: {}, diff --git a/app/server/create/town.js b/app/server/create/town.js index 1848ed3..20b2c65 100644 --- a/app/server/create/town.js +++ b/app/server/create/town.js @@ -11,13 +11,13 @@ export default async function createTown() { { area, data, - source: '/assets/tileset.json', + source: '/resources/tileset.json', tileSize: {x: 16, y: 16}, }, { area, data: Array(area.x * area.y).fill(0), - source: '/assets/tileset.json', + source: '/resources/tileset.json', tileSize: {x: 16, y: 16}, }, ], diff --git a/public/assets/brush/brush.json b/public/assets/brush/brush.json deleted file mode 100644 index 330dd78..0000000 --- a/public/assets/brush/brush.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "icon": "/assets/brush/brush.png", - "label": "Brush", - "start": "/assets/brush/start.js" -} \ No newline at end of file diff --git a/public/assets/furball/furball.json b/public/assets/furball/furball.json deleted file mode 100644 index dfa7448..0000000 --- a/public/assets/furball/furball.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "icon": "/assets/furball/furball.png", - "label": "Fur Ball" -} diff --git a/public/assets/magic-swords/magic-swords.json b/public/assets/magic-swords/magic-swords.json deleted file mode 100644 index 238ad41..0000000 --- a/public/assets/magic-swords/magic-swords.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "icon": "/assets/magic-swords/icon.png", - "label": "Magic swords", - "start": "/assets/magic-swords/start.js" -} \ No newline at end of file diff --git a/public/assets/potion/potion.json b/public/assets/potion/potion.json deleted file mode 100644 index b6cad1b..0000000 --- a/public/assets/potion/potion.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "icon": "/assets/potion/icon.png", - "label": "Potion", - "start": "/assets/potion/start.js" -} \ No newline at end of file diff --git a/public/assets/tomato-seeds/tomato-seeds.json b/public/assets/tomato-seeds/tomato-seeds.json deleted file mode 100644 index 5ab032a..0000000 --- a/public/assets/tomato-seeds/tomato-seeds.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "icon": "/assets/tomato-seeds/icon.png", - "label": "Tomato Seeds", - "projection": { - "distance": [1, -1], - "grid": [ - [1, 1, 1], - [1, 1, 1], - [1, 1, 1] - ] - }, - "projectionCheck": "/assets/tomato-seeds/projection-check.js", - "start": "/assets/tomato-seeds/start.js" -} diff --git a/public/assets/tomato/tomato.json b/public/assets/tomato/tomato.json deleted file mode 100644 index b121603..0000000 --- a/public/assets/tomato/tomato.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "icon": "/assets/tomato/tomato.png" -} diff --git a/public/assets/watering-can/watering-can.json b/public/assets/watering-can/watering-can.json deleted file mode 100644 index 6ceeb55..0000000 --- a/public/assets/watering-can/watering-can.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "icon": "/assets/watering-can/icon.png", - "label": "Watering Can", - "projectionCheck": "/assets/watering-can/projection-check.js", - "projection": { - "distance": [3, -1], - "grid": [ - [1, 1, 1], - [1, 1, 1], - [1, 1, 1] - ] - }, - "start": "/assets/watering-can/start.js" -} diff --git a/public/assets/fonts/Cookbook.woff b/public/fonts/Cookbook.woff similarity index 100% rename from public/assets/fonts/Cookbook.woff rename to public/fonts/Cookbook.woff diff --git a/public/assets/fonts/Joystix.woff b/public/fonts/Joystix.woff similarity index 100% rename from public/assets/fonts/Joystix.woff rename to public/fonts/Joystix.woff diff --git a/public/assets/ambient/blossom.json b/resources/ambient/blossom.json similarity index 100% rename from public/assets/ambient/blossom.json rename to resources/ambient/blossom.json diff --git a/public/assets/ambient/blossom.png b/resources/ambient/blossom.png similarity index 100% rename from public/assets/ambient/blossom.png rename to resources/ambient/blossom.png diff --git a/public/assets/ambient/flower.json b/resources/ambient/flower.json similarity index 100% rename from public/assets/ambient/flower.json rename to resources/ambient/flower.json diff --git a/public/assets/ambient/flower.png b/resources/ambient/flower.png similarity index 100% rename from public/assets/ambient/flower.png rename to resources/ambient/flower.png diff --git a/public/assets/ambient/shrub.json b/resources/ambient/shrub.json similarity index 100% rename from public/assets/ambient/shrub.json rename to resources/ambient/shrub.json diff --git a/public/assets/ambient/shrub.png b/resources/ambient/shrub.png similarity index 100% rename from public/assets/ambient/shrub.png rename to resources/ambient/shrub.png diff --git a/public/assets/ambient/tree.json b/resources/ambient/tree.json similarity index 100% rename from public/assets/ambient/tree.json rename to resources/ambient/tree.json diff --git a/public/assets/ambient/tree.png b/resources/ambient/tree.png similarity index 100% rename from public/assets/ambient/tree.png rename to resources/ambient/tree.png diff --git a/resources/brush/brush.json b/resources/brush/brush.json new file mode 100644 index 0000000..fa2d886 --- /dev/null +++ b/resources/brush/brush.json @@ -0,0 +1,5 @@ +{ + "icon": "/resources/brush/brush.png", + "label": "Brush", + "start": "/resources/brush/start.js" +} \ No newline at end of file diff --git a/public/assets/brush/brush.png b/resources/brush/brush.png similarity index 100% rename from public/assets/brush/brush.png rename to resources/brush/brush.png diff --git a/public/assets/brush/brush.wav b/resources/brush/brush.wav similarity index 100% rename from public/assets/brush/brush.wav rename to resources/brush/brush.wav diff --git a/public/assets/brush/start.js b/resources/brush/start.js similarity index 93% rename from public/assets/brush/start.js rename to resources/brush/start.js index 0bb3b01..b9bc453 100644 --- a/public/assets/brush/start.js +++ b/resources/brush/start.js @@ -6,7 +6,7 @@ for (const entity of entities) { Controlled.locked = 1 const [, direction] = Sprite.animation.split(':') for (let i = 0; i < 2; ++i) { - Sound.play('/assets/brush/brush.wav'); + Sound.play('/resources/brush/brush.wav'); Sprite.animation = ['moving', direction].join(':'); await wait(0.3) Sprite.animation = ['idle', direction].join(':'); @@ -14,7 +14,7 @@ for (const entity of entities) { } Inventory.give({ qty: 1, - source: '/assets/furball/furball.json', + source: '/resources/furball/furball.json', }); Controlled.locked = 0; @@ -69,7 +69,7 @@ for (const entity of entities) { { type: 'textureSingle', config: { - texture: '/assets/heart/heart.png', + texture: '/resources/heart/heart.png', } }, ], diff --git a/public/assets/chest/chest.json b/resources/chest/chest.json similarity index 100% rename from public/assets/chest/chest.json rename to resources/chest/chest.json diff --git a/public/assets/chest/chest.png b/resources/chest/chest.png similarity index 100% rename from public/assets/chest/chest.png rename to resources/chest/chest.png diff --git a/public/assets/dude/dude.json b/resources/dude/dude.json similarity index 100% rename from public/assets/dude/dude.json rename to resources/dude/dude.json diff --git a/public/assets/dude/dude.png b/resources/dude/dude.png similarity index 100% rename from public/assets/dude/dude.png rename to resources/dude/dude.png diff --git a/public/assets/farm/animals/bull-adult/bull-adult.png b/resources/farm/animals/bull-adult/bull-adult.png similarity index 100% rename from public/assets/farm/animals/bull-adult/bull-adult.png rename to resources/farm/animals/bull-adult/bull-adult.png diff --git a/public/assets/farm/animals/bull-baby/bull-baby.png b/resources/farm/animals/bull-baby/bull-baby.png similarity index 100% rename from public/assets/farm/animals/bull-baby/bull-baby.png rename to resources/farm/animals/bull-baby/bull-baby.png diff --git a/public/assets/farm/animals/cow-adult/cow-adult.json b/resources/farm/animals/cow-adult/cow-adult.json similarity index 100% rename from public/assets/farm/animals/cow-adult/cow-adult.json rename to resources/farm/animals/cow-adult/cow-adult.json diff --git a/public/assets/farm/animals/cow-adult/cow-adult.png b/resources/farm/animals/cow-adult/cow-adult.png similarity index 100% rename from public/assets/farm/animals/cow-adult/cow-adult.png rename to resources/farm/animals/cow-adult/cow-adult.png diff --git a/public/assets/farm/animals/cow-adult/initial.js b/resources/farm/animals/cow-adult/initial.js similarity index 100% rename from public/assets/farm/animals/cow-adult/initial.js rename to resources/farm/animals/cow-adult/initial.js diff --git a/public/assets/farm/animals/cow-baby/cow-baby.png b/resources/farm/animals/cow-baby/cow-baby.png similarity index 100% rename from public/assets/farm/animals/cow-baby/cow-baby.png rename to resources/farm/animals/cow-baby/cow-baby.png diff --git a/public/assets/farm/animals/goat-black/goat-black.png b/resources/farm/animals/goat-black/goat-black.png similarity index 100% rename from public/assets/farm/animals/goat-black/goat-black.png rename to resources/farm/animals/goat-black/goat-black.png diff --git a/public/assets/farm/animals/goat-white/goat-white.json b/resources/farm/animals/goat-white/goat-white.json similarity index 100% rename from public/assets/farm/animals/goat-white/goat-white.json rename to resources/farm/animals/goat-white/goat-white.json diff --git a/public/assets/farm/animals/goat-white/goat-white.png b/resources/farm/animals/goat-white/goat-white.png similarity index 100% rename from public/assets/farm/animals/goat-white/goat-white.png rename to resources/farm/animals/goat-white/goat-white.png diff --git a/public/assets/farm/animals/goat-white/initial.js b/resources/farm/animals/goat-white/initial.js similarity index 100% rename from public/assets/farm/animals/goat-white/initial.js rename to resources/farm/animals/goat-white/initial.js diff --git a/public/assets/farm/animals/pig-adult/pig-adult.png b/resources/farm/animals/pig-adult/pig-adult.png similarity index 100% rename from public/assets/farm/animals/pig-adult/pig-adult.png rename to resources/farm/animals/pig-adult/pig-adult.png diff --git a/public/assets/farm/animals/pig-baby/pig-baby.png b/resources/farm/animals/pig-baby/pig-baby.png similarity index 100% rename from public/assets/farm/animals/pig-baby/pig-baby.png rename to resources/farm/animals/pig-baby/pig-baby.png diff --git a/resources/furball/furball.json b/resources/furball/furball.json new file mode 100644 index 0000000..7ccc3ee --- /dev/null +++ b/resources/furball/furball.json @@ -0,0 +1,4 @@ +{ + "icon": "/resources/furball/furball.png", + "label": "Fur Ball" +} diff --git a/public/assets/furball/furball.png b/resources/furball/furball.png similarity index 100% rename from public/assets/furball/furball.png rename to resources/furball/furball.png diff --git a/public/assets/heart/heart.png b/resources/heart/heart.png similarity index 100% rename from public/assets/heart/heart.png rename to resources/heart/heart.png diff --git a/public/assets/hoe/dig.wav b/resources/hoe/dig.wav similarity index 100% rename from public/assets/hoe/dig.wav rename to resources/hoe/dig.wav diff --git a/public/assets/hoe/hoe.json b/resources/hoe/hoe.json similarity index 51% rename from public/assets/hoe/hoe.json rename to resources/hoe/hoe.json index c0977cf..0ae663f 100644 --- a/public/assets/hoe/hoe.json +++ b/resources/hoe/hoe.json @@ -1,7 +1,7 @@ { - "icon": "/assets/hoe/icon.png", + "icon": "/resources/hoe/icon.png", "label": "Hoe", - "projectionCheck": "/assets/hoe/projection-check.js", + "projectionCheck": "/resources/hoe/projection-check.js", "projection": { "distance": [3, -1], "grid": [ @@ -10,5 +10,5 @@ [1, 1, 1] ] }, - "start": "/assets/hoe/start.js" + "start": "/resources/hoe/start.js" } diff --git a/public/assets/hoe/icon.png b/resources/hoe/icon.png similarity index 100% rename from public/assets/hoe/icon.png rename to resources/hoe/icon.png diff --git a/public/assets/hoe/projection-check.js b/resources/hoe/projection-check.js similarity index 100% rename from public/assets/hoe/projection-check.js rename to resources/hoe/projection-check.js diff --git a/public/assets/hoe/start.js b/resources/hoe/start.js similarity index 97% rename from public/assets/hoe/start.js rename to resources/hoe/start.js index 258e22d..cc5f98d 100644 --- a/public/assets/hoe/start.js +++ b/resources/hoe/start.js @@ -10,7 +10,7 @@ if (projected?.length > 0) { const [, direction] = Sprite.animation.split(':') for (let i = 0; i < 2; ++i) { - Sound.play('/assets/hoe/dig.wav'); + Sound.play('/resources/hoe/dig.wav'); for (const {x, y} of projected) { Emitter.emit({ entity: { diff --git a/public/assets/kitty/initial.js b/resources/kitty/initial.js similarity index 100% rename from public/assets/kitty/initial.js rename to resources/kitty/initial.js diff --git a/public/assets/kitty/kitty.json b/resources/kitty/kitty.json similarity index 100% rename from public/assets/kitty/kitty.json rename to resources/kitty/kitty.json diff --git a/public/assets/kitty/kitty.png b/resources/kitty/kitty.png similarity index 100% rename from public/assets/kitty/kitty.png rename to resources/kitty/kitty.png diff --git a/public/assets/magic-swords/collision-start.js b/resources/magic-swords/collision-start.js similarity index 100% rename from public/assets/magic-swords/collision-start.js rename to resources/magic-swords/collision-start.js diff --git a/public/assets/magic-swords/icon.png b/resources/magic-swords/icon.png similarity index 100% rename from public/assets/magic-swords/icon.png rename to resources/magic-swords/icon.png diff --git a/public/assets/magic-swords/magic-sword-shot.json b/resources/magic-swords/magic-sword-shot.json similarity index 100% rename from public/assets/magic-swords/magic-sword-shot.json rename to resources/magic-swords/magic-sword-shot.json diff --git a/public/assets/magic-swords/magic-sword-shot.png b/resources/magic-swords/magic-sword-shot.png similarity index 100% rename from public/assets/magic-swords/magic-sword-shot.png rename to resources/magic-swords/magic-sword-shot.png diff --git a/resources/magic-swords/magic-swords.json b/resources/magic-swords/magic-swords.json new file mode 100644 index 0000000..65573d0 --- /dev/null +++ b/resources/magic-swords/magic-swords.json @@ -0,0 +1,5 @@ +{ + "icon": "/resources/magic-swords/icon.png", + "label": "Magic swords", + "start": "/resources/magic-swords/start.js" +} \ No newline at end of file diff --git a/public/assets/magic-swords/start.js b/resources/magic-swords/start.js similarity index 93% rename from public/assets/magic-swords/start.js rename to resources/magic-swords/start.js index a3784b0..a15904a 100644 --- a/public/assets/magic-swords/start.js +++ b/resources/magic-swords/start.js @@ -24,7 +24,7 @@ for (let i = 0; i < N; ++i) { unstoppable: 1, }, ], - collisionStartScript: '/assets/magic-swords/collision-start.js', + collisionStartScript: '/resources/magic-swords/collision-start.js', }, Controlled: {}, Direction: {direction: Math.TAU * (i / N)}, @@ -35,7 +35,7 @@ for (let i = 0; i < N; ++i) { Speed: {}, Sprite: { alpha: 0, - source: '/assets/magic-swords/magic-sword-shot.json', + source: '/resources/magic-swords/magic-sword-shot.json', }, Ticking: {}, VisibleAabb: {}, diff --git a/public/assets/misc/death-default.js b/resources/misc/death-default.js similarity index 100% rename from public/assets/misc/death-default.js rename to resources/misc/death-default.js diff --git a/public/assets/potion/icon.png b/resources/potion/icon.png similarity index 100% rename from public/assets/potion/icon.png rename to resources/potion/icon.png diff --git a/resources/potion/potion.json b/resources/potion/potion.json new file mode 100644 index 0000000..9fb2299 --- /dev/null +++ b/resources/potion/potion.json @@ -0,0 +1,5 @@ +{ + "icon": "/resources/potion/icon.png", + "label": "Potion", + "start": "/resources/potion/start.js" +} \ No newline at end of file diff --git a/public/assets/potion/start.js b/resources/potion/start.js similarity index 100% rename from public/assets/potion/start.js rename to resources/potion/start.js diff --git a/public/assets/shit-shack/shit-shack.json b/resources/shit-shack/shit-shack.json similarity index 100% rename from public/assets/shit-shack/shit-shack.json rename to resources/shit-shack/shit-shack.json diff --git a/public/assets/shit-shack/shit-shack.normals.json b/resources/shit-shack/shit-shack.normals.json similarity index 100% rename from public/assets/shit-shack/shit-shack.normals.json rename to resources/shit-shack/shit-shack.normals.json diff --git a/public/assets/shit-shack/shit-shack.normals.png b/resources/shit-shack/shit-shack.normals.png similarity index 100% rename from public/assets/shit-shack/shit-shack.normals.png rename to resources/shit-shack/shit-shack.normals.png diff --git a/public/assets/shit-shack/shit-shack.png b/resources/shit-shack/shit-shack.png similarity index 100% rename from public/assets/shit-shack/shit-shack.png rename to resources/shit-shack/shit-shack.png diff --git a/public/assets/sow.wav b/resources/sow.wav similarity index 100% rename from public/assets/sow.wav rename to resources/sow.wav diff --git a/public/assets/sprite.js b/resources/sprite.js similarity index 100% rename from public/assets/sprite.js rename to resources/sprite.js diff --git a/public/assets/tileset.json b/resources/tileset.json similarity index 100% rename from public/assets/tileset.json rename to resources/tileset.json diff --git a/public/assets/tileset.normals.json b/resources/tileset.normals.json similarity index 100% rename from public/assets/tileset.normals.json rename to resources/tileset.normals.json diff --git a/public/assets/tileset.normals.png b/resources/tileset.normals.png similarity index 100% rename from public/assets/tileset.normals.png rename to resources/tileset.normals.png diff --git a/public/assets/tileset.png b/resources/tileset.png similarity index 100% rename from public/assets/tileset.png rename to resources/tileset.png diff --git a/public/assets/tomato-plant/grow.js b/resources/tomato-plant/grow.js similarity index 100% rename from public/assets/tomato-plant/grow.js rename to resources/tomato-plant/grow.js diff --git a/public/assets/tomato-plant/interact.js b/resources/tomato-plant/interact.js similarity index 95% rename from public/assets/tomato-plant/interact.js rename to resources/tomato-plant/interact.js index 9ea48ad..53261aa 100644 --- a/public/assets/tomato-plant/interact.js +++ b/resources/tomato-plant/interact.js @@ -21,7 +21,7 @@ for (let i = 0; i < 10; ++i) { 'if (other.Inventory) {', ' other.Inventory.give({', ' qty: 1,', - " source: '/assets/tomato/tomato.json',", + " source: '/resources/tomato/tomato.json',", ' })', ' ecs.destroy(entity.id)', '}', @@ -35,7 +35,7 @@ for (let i = 0; i < 10; ++i) { anchorY: 0.5, scaleX: 0.333, scaleY: 0.333, - source: '/assets/tomato/tomato-sprite.json', + source: '/resources/tomato/tomato-sprite.json', }, Ticking: {}, VisibleAabb: {}, diff --git a/public/assets/tomato-plant/may-grow.js b/resources/tomato-plant/may-grow.js similarity index 100% rename from public/assets/tomato-plant/may-grow.js rename to resources/tomato-plant/may-grow.js diff --git a/public/assets/tomato-plant/tomato-plant.json b/resources/tomato-plant/tomato-plant.json similarity index 100% rename from public/assets/tomato-plant/tomato-plant.json rename to resources/tomato-plant/tomato-plant.json diff --git a/public/assets/tomato-plant/tomato-plant.png b/resources/tomato-plant/tomato-plant.png similarity index 100% rename from public/assets/tomato-plant/tomato-plant.png rename to resources/tomato-plant/tomato-plant.png diff --git a/public/assets/tomato-seeds/icon.png b/resources/tomato-seeds/icon.png similarity index 100% rename from public/assets/tomato-seeds/icon.png rename to resources/tomato-seeds/icon.png diff --git a/public/assets/tomato-seeds/projection-check.js b/resources/tomato-seeds/projection-check.js similarity index 100% rename from public/assets/tomato-seeds/projection-check.js rename to resources/tomato-seeds/projection-check.js diff --git a/public/assets/tomato-seeds/start.js b/resources/tomato-seeds/start.js similarity index 88% rename from public/assets/tomato-seeds/start.js rename to resources/tomato-seeds/start.js index 7781925..d059e36 100644 --- a/public/assets/tomato-seeds/start.js +++ b/resources/tomato-seeds/start.js @@ -22,17 +22,17 @@ if (projected?.length > 0) { ], }, Interactive: { - interactScript: '/assets/tomato-plant/interact.js', + interactScript: '/resources/tomato-plant/interact.js', }, Plant: { - growScript: '/assets/tomato-plant/grow.js', - mayGrowScript: '/assets/tomato-plant/may-grow.js', + growScript: '/resources/tomato-plant/grow.js', + mayGrowScript: '/resources/tomato-plant/may-grow.js', stages: [0.5, 0.5, 0.5, 0.5, 0.5], }, Sprite: { anchorY: 0.75, animation: 'stage/0', - source: '/assets/tomato-plant/tomato-plant.json', + source: '/resources/tomato-plant/tomato-plant.json', }, Ticking: {}, VisibleAabb: {}, @@ -60,7 +60,7 @@ if (projected?.length > 0) { } }); - Sound.play('/assets/sow.wav'); + Sound.play('/resources/sow.wav'); Sprite.animation = ['moving', direction].join(':'); const directionMap = {0: 'right', 1: 'down', 2: 'left', 3: 'up'}; diff --git a/resources/tomato-seeds/tomato-seeds.json b/resources/tomato-seeds/tomato-seeds.json new file mode 100644 index 0000000..dcafb37 --- /dev/null +++ b/resources/tomato-seeds/tomato-seeds.json @@ -0,0 +1,14 @@ +{ + "icon": "/resources/tomato-seeds/icon.png", + "label": "Tomato Seeds", + "projection": { + "distance": [1, -1], + "grid": [ + [1, 1, 1], + [1, 1, 1], + [1, 1, 1] + ] + }, + "projectionCheck": "/resources/tomato-seeds/projection-check.js", + "start": "/resources/tomato-seeds/start.js" +} diff --git a/public/assets/tomato/tomato-sprite.json b/resources/tomato/tomato-sprite.json similarity index 100% rename from public/assets/tomato/tomato-sprite.json rename to resources/tomato/tomato-sprite.json diff --git a/resources/tomato/tomato.json b/resources/tomato/tomato.json new file mode 100644 index 0000000..c413f76 --- /dev/null +++ b/resources/tomato/tomato.json @@ -0,0 +1,3 @@ +{ + "icon": "/resources/tomato/tomato.png" +} diff --git a/public/assets/tomato/tomato.png b/resources/tomato/tomato.png similarity index 100% rename from public/assets/tomato/tomato.png rename to resources/tomato/tomato.png diff --git a/public/assets/watering-can/icon.png b/resources/watering-can/icon.png similarity index 100% rename from public/assets/watering-can/icon.png rename to resources/watering-can/icon.png diff --git a/public/assets/watering-can/projection-check.js b/resources/watering-can/projection-check.js similarity index 100% rename from public/assets/watering-can/projection-check.js rename to resources/watering-can/projection-check.js diff --git a/public/assets/watering-can/start.js b/resources/watering-can/start.js similarity index 96% rename from public/assets/watering-can/start.js rename to resources/watering-can/start.js index dba019c..b464fc8 100644 --- a/public/assets/watering-can/start.js +++ b/resources/watering-can/start.js @@ -10,7 +10,7 @@ if (projected?.length > 0) { const [, direction] = Sprite.animation.split(':') Sprite.animation = ['idle', direction].join(':'); - Sound.play('/assets/watering-can/water.wav'); + Sound.play('/resources/watering-can/water.wav'); for (const {x, y} of projected) { Emitter.emit({ diff --git a/public/assets/watering-can/water.wav b/resources/watering-can/water.wav similarity index 100% rename from public/assets/watering-can/water.wav rename to resources/watering-can/water.wav diff --git a/resources/watering-can/watering-can.json b/resources/watering-can/watering-can.json new file mode 100644 index 0000000..85661c4 --- /dev/null +++ b/resources/watering-can/watering-can.json @@ -0,0 +1,14 @@ +{ + "icon": "/resources/watering-can/icon.png", + "label": "Watering Can", + "projectionCheck": "/resources/watering-can/projection-check.js", + "projection": { + "distance": [3, -1], + "grid": [ + [1, 1, 1], + [1, 1, 1], + [1, 1, 1] + ] + }, + "start": "/resources/watering-can/start.js" +} diff --git a/public/assets/yuff.wav b/resources/yuff.wav similarity index 100% rename from public/assets/yuff.wav rename to resources/yuff.wav diff --git a/server.js b/server.js index 902c027..e5469b2 100644 --- a/server.js +++ b/server.js @@ -85,6 +85,12 @@ else { ); } +// silphius resources +app.use( + '/resources', + express.static('resources', { maxAge: '1h' }), +); + // Everything else (like favicon.ico) is cached for an hour. You may want to be // more aggressive with this caching. app.use(express.static('build/client', { maxAge: '1h' })); diff --git a/stories/hotbar.stories.js b/stories/hotbar.stories.js index 6d1b8b9..a92bc66 100644 --- a/stories/hotbar.stories.js +++ b/stories/hotbar.stories.js @@ -6,7 +6,7 @@ import Hotbar from '@/react/components/hotbar.jsx'; import DomDecorator from './dom-decorator.jsx'; const slots = Array(10).fill({}); -slots[2] = {qty: 24, icon: '/assets/potion/icon.png'}; +slots[2] = {qty: 24, icon: '/resources/potion/icon.png'}; export default { title: 'Dom/Inventory/Hotbar', diff --git a/stories/slot.stories.js b/stories/slot.stories.js index c99ae77..376c21b 100644 --- a/stories/slot.stories.js +++ b/stories/slot.stories.js @@ -31,7 +31,7 @@ export default { }, }, args: { - icon: '/assets/potion/icon.png', + icon: '/resources/potion/icon.png', }, };