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 (tileMatchThreshold === 64) {
|
||||
// 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) {
|
||||
return tile.bitmap === pseudoTile;
|
||||
});
|
||||
|
||||
if (bestMatch) {
|
||||
console.debug(pseudoTile === bestMatch.bitmap);
|
||||
bestMatch.match = 64;
|
||||
}
|
||||
} else {
|
||||
|
@ -458,6 +458,8 @@ $(document).ready(function() {
|
|||
$('#save').on('click touchend', function() {
|
||||
var newGameData = $('textarea').val();
|
||||
|
||||
// handle rooms
|
||||
|
||||
// need to import IDs so we don't give the new room a conflicting ID
|
||||
var roomNames = newGameData.match(/ROOM \d+/g);
|
||||
|
||||
|
@ -478,7 +480,30 @@ $(document).ready(function() {
|
|||
|
||||
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
|
||||
$('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)?:\/\/|^\/\//)) {
|
||||
```
|
||||
|
||||
## known bugs
|
||||
|
||||
* new tiles can be duplicates
|
||||
* take a different approach
|
||||
|
||||
## to do
|
||||
|
||||
* allow user to save output as image, or tweet it :)
|
||||
* *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)
|
||||
* re-style the damn thing
|
||||
* reorganise the page layout for a more logical workflow
|
||||
* animate animated tiles
|
||||
* 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 'never'/'always' clickable
|
||||
|
||||
## could do
|
||||
|
||||
|
|
Loading…
Reference in New Issue