write new tiles to game data
This commit is contained in:
@@ -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?
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user