Skip to content

Commit

Permalink
fixes changing tiles outside orig dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
mswieboda committed Apr 29, 2021
1 parent ca62fba commit fba6883
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 2 additions & 0 deletions source/escape/BaseLevel.hx
Expand Up @@ -161,6 +161,8 @@ class BaseLevel extends FlxGroup {
remove(doors);
remove(ladders);

tiles = new FlxTilemap();

loadTiles();
}

Expand Down
17 changes: 7 additions & 10 deletions source/escape/LevelEditor.hx
Expand Up @@ -96,21 +96,18 @@ class LevelEditor extends BaseLevel {
}
}

if (cursorCol >= levelStrData[cursorRow].length) {
for (c in levelStrData.length...(cursorCol + 1)) {
levelStrData[cursorRow][c] = '0';
tiles.setTile(c, cursorRow, 0);
if (cursorCol >= levelStrData[0].length) {
for (r in 0...levelStrData.length) {
for (c in levelStrData[r].length...(cursorCol + 1)) {
levelStrData[r][c] = '0';
tiles.setTile(c, cursorRow, 0);
}
}
}

var newTile = tile == '0' ? 1 : 0;
// not needed if we're using reloadTiles()
// tiles.setTile(cursorCol, cursorRow, newTile);

// TODO: flip this around in BaseLevel to be [cursorCol][cursorRow] for consistency with tiles.setTile
levelStrData[cursorRow][cursorCol] = Std.string(newTile);
levelStrData[cursorRow][cursorCol] = tile == '0' ? '1' : '0';

// TODO: this isn't working for tiles outside the original range
reloadTiles();
}
}
Expand Down
7 changes: 6 additions & 1 deletion source/escape/LevelEditorMenu.hx
Expand Up @@ -9,11 +9,16 @@ class LevelEditorMenu extends PlayMenu {
var title = "Level Editor";
var itemData = [
{ name: "resume", action: name -> close() },
{ name: "save", action: name -> onSave() },
{ name: "save", action: name -> save(onSave) },
{ name: "load", action: name -> close() },
{ name: "exit", action: name -> FlxG.switchState(new MenuState()) }
];

super(title, itemData);
}

function save(onSave: () -> Void) {
onSave();
close();
}
}

0 comments on commit fba6883

Please sign in to comment.