write new tiles to game data
This commit is contained in:
parent
e0420606d9
commit
4af4d7ac7d
|
@ -291,12 +291,12 @@ $(document).ready(function() {
|
||||||
// if we want to always create new tiles, don't bother trying to check matches
|
// if we want to always create new tiles, don't bother trying to check matches
|
||||||
if (tileMatchThreshold === 64) {
|
if (tileMatchThreshold === 64) {
|
||||||
// even if we want to "always create new tiles" we still don't want to create duplicates
|
// even if we want to "always create new tiles" we still don't want to create duplicates
|
||||||
|
// THIS SEEMS TO NOT BE WORKING
|
||||||
var bestMatch = _.find(bitsyData.tiles, function(tile) {
|
var bestMatch = _.find(bitsyData.tiles, function(tile) {
|
||||||
return tile.bitmap === pseudoTile;
|
return tile.bitmap === pseudoTile;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (bestMatch) {
|
if (bestMatch) {
|
||||||
console.debug(pseudoTile === bestMatch.bitmap);
|
|
||||||
bestMatch.match = 64;
|
bestMatch.match = 64;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -458,6 +458,8 @@ $(document).ready(function() {
|
||||||
$('#save').on('click touchend', function() {
|
$('#save').on('click touchend', function() {
|
||||||
var newGameData = $('textarea').val();
|
var newGameData = $('textarea').val();
|
||||||
|
|
||||||
|
// handle rooms
|
||||||
|
|
||||||
// need to import IDs so we don't give the new room a conflicting ID
|
// need to import IDs so we don't give the new room a conflicting ID
|
||||||
var roomNames = newGameData.match(/ROOM \d+/g);
|
var roomNames = newGameData.match(/ROOM \d+/g);
|
||||||
|
|
||||||
|
@ -478,7 +480,30 @@ $(document).ready(function() {
|
||||||
|
|
||||||
newRoom += "PAL " + palette.id + "\n";
|
newRoom += "PAL " + palette.id + "\n";
|
||||||
|
|
||||||
|
newGameData = newGameData.replace(/(ROOM .*\n(.*\n)*PAL .*)/g, '$1\n\n' + newRoom);
|
||||||
|
|
||||||
|
// handle tiles
|
||||||
|
|
||||||
|
var newTiles = _.filter(bitsyData.tiles, 'new');
|
||||||
|
var tileText = "";
|
||||||
|
|
||||||
|
_.each(newTiles, function(tile) {
|
||||||
|
tileText += "TIL " + tile.name + "\n"; //again, rename tile name to id...
|
||||||
|
|
||||||
|
_.each(tile.bitmap, function(row) {
|
||||||
|
tileText += row.join('') + "\n";
|
||||||
|
});
|
||||||
|
|
||||||
|
// don't need to worry about animation right now
|
||||||
|
|
||||||
|
tileText += "\n";
|
||||||
|
});
|
||||||
|
|
||||||
|
newGameData = newGameData.replace(/(TIL.*(.*\n)*)SPR/g, '$1\n\n' + tileText + '\nSPR');
|
||||||
|
|
||||||
// write
|
// write
|
||||||
$('textarea').val(newGameData.replace(/(ROOM .*\n(.*\n)*PAL .*)/g, '$1\n\n' + newRoom));
|
$('textarea').val(newGameData);
|
||||||
|
|
||||||
|
// todo: give the user some nice "yay! it worked!" kinda feedback?
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,19 +40,22 @@ croppie.js:182 (mine)
|
||||||
if (src.match(/^(file|https)?:\/\/|^\/\//)) {
|
if (src.match(/^(file|https)?:\/\/|^\/\//)) {
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## known bugs
|
||||||
|
|
||||||
|
* new tiles can be duplicates
|
||||||
|
* take a different approach
|
||||||
|
|
||||||
## to do
|
## to do
|
||||||
|
|
||||||
* allow user to save output as image, or tweet it :)
|
* allow user to save output as image, or tweet it :)
|
||||||
* *user can currently right-click -> Save As but the 128x128 size is not great*
|
* *user can currently right-click -> Save As but the 128x128 size is not great*
|
||||||
* create new tiles based on image
|
|
||||||
* only add unique new tiles
|
|
||||||
* don't write the 0 tile (implicit background-only tile)
|
|
||||||
* implement slider (*always use existing tiles* -> *always create new tiles*) (representing 0-64 threshold for # of common pixels)
|
* implement slider (*always use existing tiles* -> *always create new tiles*) (representing 0-64 threshold for # of common pixels)
|
||||||
* re-style the damn thing
|
* re-style the damn thing
|
||||||
* reorganise the page layout for a more logical workflow
|
* reorganise the page layout for a more logical workflow
|
||||||
* animate animated tiles
|
* animate animated tiles
|
||||||
* profile script performance and optimise where most needed
|
* profile script performance and optimise where most needed
|
||||||
* make brightness slider trigger redraw every so often while being dragged, instead of waiting until drag stop
|
* make brightness slider trigger redraw every so often while being dragged, instead of waiting until drag stop
|
||||||
|
* make 'never'/'always' clickable
|
||||||
|
|
||||||
## could do
|
## could do
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue