Coder Social home page Coder Social logo

getkey / ble Goto Github PK

View Code? Open in Web Editor NEW
16.0 3.0 5.0 2.65 MB

BombHopper.io's Level Editor

Home Page: https://editor.bombhopper.io

License: Apache License 2.0

JavaScript 2.44% TypeScript 96.65% Shell 0.04% EJS 0.62% CSS 0.26%
level-editor react pixijs mobx-state-tree rxjs hacktoberfest

ble's People

Contributors

dependabot[bot] avatar fju avatar getkey avatar lejara avatar matt-ross16 avatar nobody5050 avatar voxxal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ble's Issues

Place points in the closest segment

The current algorithm looks at all the segments and find the ones that have a point closest to the vertex you are trying to add.

But in some cases, 2 segments can fit these criteria, in which case, a segment gets randomly chosen. For a human, it would make more sense that the chosen segment be the one whose second point is closest.

example

More context: https://discordapp.com/channels/526188679006388254/601609930486841365/737049529869926482

(This issue is labeled as good first issue because you don't need to know the codebase well to contribute, not because of the difficulty of implementing the algorithm 🙂)

Revamp meta-tools and level settings

Conceptually, this editor has 4 category of tools:

  • Edition tools
    • Select
    • Create vertex
    • Create entity
    • Clear level
    • Set grid size (can it also be considered a level setting?)
  • Level settings
    • Level name
    • Stars
  • Meta-tools
    • Save file
    • Load file
    • Upload
    • Test
    • Home
    • Undo/redo
  • Entity specific tools
    • Rotation
    • Bombs
    • Text content
    • Staticness
    • Text content
    • etc.

New design idea

A bar on the top that goes accros the window. On the top left, the level name and the stars. On the top right, the meta-tools. On small screens, the meta-tools move below the level name and the stars

The edition tools are floating ~10px below that bar, on the left.

Some inspiration:

google sheets

inkscape

iOS pages

Multiple selection

Support for having multiple entities selected.

  • Ctrl+clic shortcut
  • entity params box shows something meaningful (maybe just "X entities selected" for a start)
  • copy-pasting works
  • moving entities around works

Out of scope:

  • selection box: it would need a new select mode in the editor because currently the behavior when click-dragging is panning the level.

https://discord.com/channels/526188679006388254/644549821922803712/702588436015742977
https://discord.com/channels/526188679006388254/644549821922803712/709806784063471717

Shareable prefabs

Using @ErikSom's trick of compressing JSON, then turning it into base64 so prefabs can be shared on Discord.

Let's use https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs as the format.
A good compression algorithm is necessary because Discord's character limit per message is presently 2000.

data:application/bombhopperio-prefab+json;compression=lz-string;base64,NobwRALgngDgpmAXJOAPCYA0YYEMBOuAtgM5LipIBMADDdlEgKy3YDGA9jI4uHAHZIwAFQAWASxIACSVIii4UgCZwAZrgCuAGwhStcAG5wtAQgA6/AKJLxuiBylQOG/HvEBrcfwDmYAL7YuPxsohz45GCUiDQAdEwMSLFMAWBB3vqJfgHg0PBC/GFEuFpYOATEZLxgRvgQ4mxwlaCRSAAsdAmIABy02S2I7fRgPF1dNH1RLEMjYxPMrMNIPeMAutiSAMoQuHVsSBD4GnBZmDmwCMj1CNh4hKQRNbuNSM1RALRUAGzTzLOn/R9vp1lnMBh1Ft1ev8ooNOgB2b6ggCMQIhCPG0KQHx+iE+7VBbyR7U6eNW6xIWx29X2h2OfVyFzAAiUMA4XgwN3K9yqkyYOM+AGYhpttrsaUdsPhxN5RBAAGK4NheXyIA4S1I+DLRE5nPLIGBaXBQODhTl3SoULGonifBZpLXCimi6mIdRaEhwbBFby4ABeXguwDA3nwAlwKlKcCIMGgpQARtp9BgVjrIOd8oViqVbhUHiank1LYgPgLPp0qABOKgEpEI8tVmt1iEClgEqilzot6trMAiql7V3FD1ZFZAA

Tour of the compression algorithms

  • lz-string: works well (sadly operates only on strings, so array buffers need to be turned into strings)
  • lzma: works well, small file size
  • brotli: dependency is too big to include in this project
  • zstd: https://www.npmjs.com/package/zstddec is to be tested, others are too big

My tests

How small can the entities in this level can turn out to be?

The comparisons below are done on base64 strings, close to real-world.

  • json + lz-string: 1712B
  • messagepack + lz-string: 1312B 5ms
  • messagepack + lzma: 872B 77ms

Some naive non-base64 benchmarks (because they all use the default paramters)

615 msgPacked.bin.br
638 msgPacked.bin.zopfli.deflate
644 msgPacked.bin.zopfli.zlib
652 msgPacked.bin.lzma
656 msgPacked.bin.zopfli.gzip
668 msgPacked.bin.lz
682 msgPacked.bin.bz2
690 msgPacked.bin.gz
700 msgPacked.bin.xz
721 msgPacked.bin.lzham
762 msgPacked.bin.zst
1018 msgPacked.bin.lzo
1035 msgPacked.bin.lz4
1065 msgPacked.bin.Z
2464 msgPacked.bin

TL;DR: the lzma module is sturdy and has a good ratio, so let's use that. (but let's make sure the service worker works since it's slow!)

The prefix will be as follow: data:application/vnd.bombhopperio-prefab+msgpack;compression=lzma;base64

Align copypasting to the grid

Currently, pasted objects appear at the center of the screen. It would be nice if the top-left corner of their AABB could be aligned to the grid.

Round the number of milliseconds in the star timings

Right now the editor allows you to set any digit as the star timing.

But actually it must be an integer in millisecond (or in seconds, have a maximum of 3 decimal places).

Currently, if you put for example 9.9999999999 as the number of seconds then try to save the level file, it will complain that the level is corrupted.

ble/src/models/Level.ts

Lines 13 to 28 in 203fd61

set2StarsTime(ms: number): void {
self.timings[0] = ms;
// 2 stars must always be bigger or equal to 3 stars
if (ms < self.timings[1]) {
self.timings[1] = ms;
}
},
set3StarsTime(ms: number): void {
self.timings[1] = ms;
// 3 stars must always be smaller or equal to 2 stars
if (ms > self.timings[0]) {
self.timings[0] = ms;
}
},

Freeze after deleting during block creation

How to reproduce:

  • select create tool
  • place the first point
  • delete it (without switching to another tool)
  • place a new point
  • get error below
add.ts:65 Uncaught Error: Trying to add a vertex but no entity is selected
    at t._tapNext (add.ts:65)
    at t._next (tap.js:45)
    at t.next (Subscriber.js:53)
    at t._next (filter.js:38)
    at t.next (Subscriber.js:53)
    at t.next (Subject.js:47)
    at t._tapNext (control.js:11)
    at t._next (tap.js:45)
    at t.next (Subscriber.js:53)
    at t.notifyNext (mergeMap.js:87)

An elegant fix for this would need mobxjs/mobx-state-tree#1540 to be merged, in the meantime, this issue is blocked 🙂

Ask for confirmation before auto-deleting an invalid polygon

The editor should warn you that if you unselect this polygon, it will be destroyed since it's invalid. But you will also be given the option to cancel to keep your invalid polygon selected so you can fix it.

Unselecting this polygon will remove it because it is invalid. Are you fine with that?
[Cancel] [OK]

More context: WMGX on Discord

Right-click menu

People often more naturally right-click than use shortcuts. Also, you can't use the shortcuts on mobile.

In the first version, it would have copy, cut and paste (more things can be added to it later).

It needs to be able to trigger with:

  • contextmenu event on desktop
  • long press on mobile

Turn Blé into a library

Right now, the editor is a standalone application. When it's loaded in the game, it's via an iframe, which is slow. If Blé was a library that could be directly used by the game, it could be cached more efficiently, and it would only be downloaded once per gaming session. Besides, common dependencies would be shared by the game and the editor.

API proposal

import { Ble } from 'ble';

const ble = new Ble(document.getElementById('ble-app'));

ble.loadLevel(someLevel);
const currentLevel = ble.getCurrentLevel();

// later
ble.destroy();

Level optimization

Sometimes levels can contain long numbers, probably because of floating point issues. It increases the size of levels while not adding any useful information.

Example from [luw4n on Discord](https://discord.com/channels/526188679006388254/681629693501243393/863836754905268264)
		{
			"type": "deadly",
			"params": {
				"isStatic": true,
				"vertices": [
					{
						"x": 300,
						"y": -88.00000000000001
					},
					{
						"x": 300,
						"y": -89.00000000000001
					},
					{
						"x": 290,
						"y": -109.00000000000001
					},
					{
						"x": 280,
						"y": -89.00000000000001
					},
					{
						"x": 270,
						"y": -109.00000000000001
					},
					{
						"x": 260,
						"y": -89.00000000000001
					},
					{
						"x": 250.00000000000003,
						"y": -109.00000000000001
					},
					{
						"x": 240.00000000000003,
						"y": -89.00000000000001
					}

It would be great if the levels could be optimized, either:

  • automatically in the editor after each edition
  • automatically in the editor on upload
  • manually in the editor (a button that asks the precision you need?)
  • automatically by the backend

I'm not sure what's the best option for now, so tracking that here. I've added the functionality to BLT: getkey/bombhopperio-level-tools@e0134d8, which should be useful whatever the decision.

Hamburger menu on mobile

The interface takes up a lot of screen space on mobile. It should be hidden in a hamburger menu.

Entity library

Replace the dropdown menu with a library (located on the side perhaps) from which entities can be dragged and dropped into the editor.

Screenshot 2020-10-14 at 23 12 44

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.