diff --git a/src/data/examples.ts b/src/data/examples.ts index c75743e..44fd358 100644 --- a/src/data/examples.ts +++ b/src/data/examples.ts @@ -193,9 +193,9 @@ export const examplesMetaData: Record> = { tags: ["basic concepts", "physics"], difficulty: "medium", }, - "flameBar": { + "flamebar": { formatedName: "Flame bar", - description: "How to make mario-like flamebars using parent/children.", + description: "How to make mario-like flame bars using parent/children.", tags: ["basic concepts"], difficulty: "medium", }, @@ -250,7 +250,7 @@ export const examplesMetaData: Record> = { tags: ["ui"], difficulty: "easy", }, - "simpleLayers": { + "layer": { formatedName: "Simple layers", description: "How to make use of a simple layering system.", tags: ["ui"], @@ -269,12 +269,13 @@ export const examplesMetaData: Record> = { difficulty: "medium", }, // TODO: im not sure what this is - // "levelRaycast": { - // formatedName: "Level raycast", - // description: "How to create levels using layouts and symbols.", - // tags: ["basic concepts"], - // difficulty: "medium", - // }, + "levelraycast": { + formatedName: "Level raycast", + description: "How to create levels using layouts and symbols.", + tags: ["basic concepts"], + difficulty: "medium", + hidden: true, + }, "linecap": { formatedName: "Line cap", description: "How to add caps to lines.", @@ -311,7 +312,7 @@ export const examplesMetaData: Record> = { tags: ["basic concepts"], difficulty: "easy", }, - "multiGamepad": { + "multigamepad": { formatedName: "Multi gamepad", description: "How to use multiple gamepads in your game.", tags: ["input"], @@ -343,13 +344,13 @@ export const examplesMetaData: Record> = { difficulty: "medium", }, // TODO: Not sure what this is either - // "physics": { - // formatedName: "Physics", - // description: "How to predict physics?.", - // tags: ["math"], - // difficulty: "hard", - // }, - "physicsFactory": { + "physics": { + formatedName: "Physics", + description: "How to predict physics?.", + tags: ["math"], + difficulty: "hard", + }, + "physicsfactory": { formatedName: "Physics Factory", description: "How to make use of various types of physics.", tags: ["math"], @@ -368,12 +369,12 @@ export const examplesMetaData: Record> = { difficulty: "medium", }, // TODO: Not sure what this is - // "polygonuv": { - // formatedName: "PolygonUV", - // description: "Wobbly ghosts.", - // tags: ["math"], - // difficulty: "medium", - // }, + "polygonuv": { + formatedName: "PolygonUV", + description: "Wobbly ghosts.", + tags: ["math"], + difficulty: "medium", + }, "pong": { formatedName: "Pong", description: "How to make pong.", @@ -407,12 +408,13 @@ export const examplesMetaData: Record> = { difficulty: "medium", }, // TODO: i think these two are the same - // "raycastShape": { - // formatedName: "Raycasts shapes", - // description: "How to shoot a raycast and make it bounce.", - // tags: ["math"], - // difficulty: "medium", - // }, + "raycastShape": { + formatedName: "Raycasts shapes", + description: "How to shoot a raycast and make it bounce.", + tags: ["math"], + difficulty: "medium", + hidden: true, + }, "raycaster3d": { formatedName: "3D Raycaster", description: "Basically, how to make 3D in KAPLAY.", diff --git a/src/hooks/useEditor.ts b/src/hooks/useEditor.ts index afc3d1a..e4ec9e0 100644 --- a/src/hooks/useEditor.ts +++ b/src/hooks/useEditor.ts @@ -8,6 +8,7 @@ import type { File } from "../stores/storage/files"; import { wrapGame } from "../util/compiler"; import { debug } from "../util/logs"; import { useProject } from "./useProject"; +import { examples } from "../data/examples"; /** The internal API to interact with the editor */ type EditorStore = { @@ -217,12 +218,15 @@ export const useEditor = create((set, get) => ({ editor.setValue(value); }, loadExample(exampleIndex) { + const exampleId = examplesList.filter(example => example.index === exampleIndex)[0].name; + const exampleName = examples.filter(example => example.name === exampleId)[0].formatedName + useProject.persist.setOptions({ - name: "Untitled Example", + name: exampleName, }); useProject.getState().replaceProject({ - name: "Untitled Example", + name: exampleName, assets: new Map(), files: new Map(), kaplayConfig: {}, diff --git a/vite.config.ts.timestamp-1727450712615-9c59fdf28d21e.mjs b/vite.config.ts.timestamp-1727450712615-9c59fdf28d21e.mjs new file mode 100644 index 0000000..3a2deeb --- /dev/null +++ b/vite.config.ts.timestamp-1727450712615-9c59fdf28d21e.mjs @@ -0,0 +1,25 @@ +// vite.config.ts +import react from "file:///C:/Users/USUARIO/Desktop/kaplayground/node_modules/.pnpm/@vitejs+plugin-react@4.3.1_vite@5.4.2_@types+node@22.7.0_/node_modules/@vitejs/plugin-react/dist/index.mjs"; +import { defineConfig } from "file:///C:/Users/USUARIO/Desktop/kaplayground/node_modules/.pnpm/vite@5.4.2_@types+node@22.7.0/node_modules/vite/dist/node/index.js"; +import { viteStaticCopy } from "file:///C:/Users/USUARIO/Desktop/kaplayground/node_modules/.pnpm/vite-plugin-static-copy@1.0.6_vite@5.4.2_@types+node@22.7.0_/node_modules/vite-plugin-static-copy/dist/index.js"; +var vite_config_default = defineConfig({ + plugins: [ + react(), + viteStaticCopy({ + targets: [ + { + src: "kaplay/assets/sprites/**", + dest: "sprites/" + }, + { + src: "kaplay/examples/**", + dest: "examples/" + } + ] + }) + ] +}); +export { + vite_config_default as default +}; +//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCJDOlxcXFxVc2Vyc1xcXFxVU1VBUklPXFxcXERlc2t0b3BcXFxca2FwbGF5Z3JvdW5kXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ZpbGVuYW1lID0gXCJDOlxcXFxVc2Vyc1xcXFxVU1VBUklPXFxcXERlc2t0b3BcXFxca2FwbGF5Z3JvdW5kXFxcXHZpdGUuY29uZmlnLnRzXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ltcG9ydF9tZXRhX3VybCA9IFwiZmlsZTovLy9DOi9Vc2Vycy9VU1VBUklPL0Rlc2t0b3Ava2FwbGF5Z3JvdW5kL3ZpdGUuY29uZmlnLnRzXCI7aW1wb3J0IHJlYWN0IGZyb20gXCJAdml0ZWpzL3BsdWdpbi1yZWFjdFwiO1xyXG5pbXBvcnQgeyBkZWZpbmVDb25maWcgfSBmcm9tIFwidml0ZVwiO1xyXG5pbXBvcnQgeyB2aXRlU3RhdGljQ29weSB9IGZyb20gXCJ2aXRlLXBsdWdpbi1zdGF0aWMtY29weV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