mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-06-17 11:44:54 -04:00
wip
This commit is contained in:
parent
cb90fef3a9
commit
401e9b4548
22 changed files with 1024 additions and 959 deletions
|
@ -2,14 +2,13 @@ import { Level, Palette, RawLevel } from "../types";
|
|||
import _backgrounds from "../data/backgrounds.json";
|
||||
import _palette from "../data/palette.json";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { moveLevel, resizeLevel, setBrick } from "./levels_editor_util";
|
||||
import {
|
||||
automaticBackgroundColor,
|
||||
levelCodeToRawLevel,
|
||||
} from "../pure_functions";
|
||||
|
||||
|
||||
const palette = _palette as Palette;
|
||||
|
||||
let allLevels = null;
|
||||
|
@ -22,13 +21,22 @@ function App() {
|
|||
fetch("http://localhost:4400/src/data/levels.json")
|
||||
.then((r) => r.json())
|
||||
.then((lvls) => {
|
||||
|
||||
const cleaned = lvls.map(l=>({name:l.name, size:l.size, bricks:(l.bricks+'_'.repeat(l.size*l.size)).slice(0,l.size*l.size), credit:l.credit||''}))
|
||||
const sorted = [
|
||||
...cleaned.filter(l=>l.name.match('icon:')).sort((a,b)=>a.name>b.name ? 1:-1),
|
||||
...cleaned.filter(l=>!l.name.match('icon:'))
|
||||
]
|
||||
setLevels(sorted as RawLevel[])
|
||||
const cleaned = lvls.map((l) => ({
|
||||
name: l.name,
|
||||
size: l.size,
|
||||
bricks: (l.bricks + "_".repeat(l.size * l.size)).slice(
|
||||
0,
|
||||
l.size * l.size,
|
||||
),
|
||||
credit: l.credit || "",
|
||||
}));
|
||||
const sorted = [
|
||||
...cleaned
|
||||
.filter((l) => l.name.match("icon:"))
|
||||
.sort((a, b) => (a.name > b.name ? 1 : -1)),
|
||||
...cleaned.filter((l) => !l.name.match("icon:")),
|
||||
];
|
||||
setLevels(sorted as RawLevel[]);
|
||||
allLevels = sorted;
|
||||
});
|
||||
}, []);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue