ported items from sandboxels + consistent saving

This commit is contained in:
tdgmdev 2023-11-23 05:27:45 -05:00
parent aeb84e2634
commit 869055a67e
3 changed files with 43 additions and 13 deletions

View file

@ -1,4 +1,4 @@
# altboxels
A sandbox game based on https://sandboxels.r74n.com/, with a cleaner codebase and secure/simple modding support in mind.
A sandbox game inspired by https://sandboxels.r74n.com/, with a cleaner codebase and secure/simple modding support in mind.
Some of the elements are derived from other games in the falling sand genre, especially Sandboxels. However, the physics engine and other backend code are custom and independently developed.

View file

@ -29,17 +29,29 @@ mainTiles.loadSet(
'Vanilla/Earth',
[
new Tile('rgb(153, 102, 51)', 'Earth').gravity(1000, 1, 9800),
new Tile('rgb(255,0,0)', 'Barrier').unGravity(),
new Tile('rgb(20,20,20)', 'Charcoal').gravity(1100, 1, 9800)
.combine(['Vanilla/Fire', 'Fire'], ['Vanilla/Air', 'Carbon Dioxide'], ['Vanilla/Water', 'Steam']),
new Tile('rgb(53,46,32)', 'Mud').cohesion(2).gravity(950, 1.5, 9800),
new Tile('rgb(43, 33, 42)', 'Mudstone').gravity(1500, 1, 8000)
.combine(['Vanilla/Water', 'Water'], ['Vanilla/Earth', 'Mud'], ['Vanilla/Air', 'Air']),
new Tile('rgb(252,224,133)', 'Sand').gravity(1500, 1, 9800)
.combine(['Vanilla/Fire', 'Fire'], ['Vanilla/Air', 'Air'], ['Vanilla/Earth', 'Sand']),
new Tile('rgb(117,111,86)', 'Wet Sand').cohesion(2).gravity(2000, 1, 18100)
.combine(['Vanilla/Fire', 'Fire'], ['Vanilla/Air', 'Air'], ['Vanilla/Earth', 'Sand']),
.combine(['Vanilla/Fire', 'Fire'], ['Vanilla/Air', 'Air'], ['Vanilla/Earth', 'Packed Sand']),
new Tile('rgb(255,0,0)', 'Barrier').unGravity(),
new Tile('rgb(187,158,110)', 'Packed Sand').gravity(2000, 1, 18100),
new Tile('rgb(20,20,20)', 'Charcoal').gravity(1100, 1, 9800)
.combine(['Vanilla/Fire', 'Fire'], ['Vanilla/Air', 'Carbon Dioxide'], ['Vanilla/Water', 'Steam'])
new Tile('rgb(66, 64, 62)', 'Rock').gravity(1500, 1, 8000),
new Tile('rgb(56, 54, 52)', 'Rock Barrier').unGravity()
.combine(['Vanilla/Fire', 'Fire'], ['Vanilla/Earth', 'Rock'], ['Vanilla/Fire', 'Fire'])
.combine(['Vanilla/Water', 'Water'], ['Vanilla/Earth', 'Rock'], ['Vanilla/Water', 'Water']),
]
)

View file

@ -5,7 +5,19 @@
*/
function save() {
let json = [];
let jason = {
'pal': [],
'data': []
};
for (let item of mainTiles.tiles) {
jason.pal.push([
item.namespace,
item.id
])
}
let json = jason.data;
for (let i = 0; i < canvas.blocks.length; i += 256) {
let arr = canvas.blocks.slice(i, i + 256);
@ -35,12 +47,18 @@ function save() {
};
}
document.querySelector('#code').value = JSON.stringify(json);
document.querySelector('#code').value = JSON.stringify(jason);
}
function load() {
let json = JSON.parse(document.querySelector('#code').value);
let jason = JSON.parse(document.querySelector('#code').value);
let json = jason.data;
let mainPal = jason.pal.map(x => mainTiles.resolveID(x[0],x[1]));
console.log(mainPal);
for (let i in json) {
let data = json[i];
let pal = data.pal;
@ -51,18 +69,18 @@ function load() {
if (pal.length < 2) {
for (let i in otherArray) {
otherArray[i] = (pal[0]) & 0xFF;
otherArray[i] = mainPal[(pal[0])];
}
} else if (pal.length < 17) {
for (let i in dat) {
otherArray[i*2] = pal[((dat[i] - 'A'.charCodeAt()) & 0xF0) / 16];
otherArray[i*2+1] = pal[(dat[i] - 'A'.charCodeAt()) & 0xF];
otherArray[i*2] = mainPal[pal[((dat[i] - 'A'.charCodeAt()) & 0xF0) / 16]];
otherArray[i*2+1] = mainPal[pal[(dat[i] - 'A'.charCodeAt()) & 0xF]];
}
} else {
for (let i in dat) {
otherArray[i] = pal[(dat[i] - 'A'.charCodeAt()) & 0xFF];
otherArray[i] = mainPal[pal[(dat[i] - 'A'.charCodeAt()) & 0xFF]];
}
}