Always update the previous cell when drawing force floors
This commit is contained in:
parent
d710e3ee0a
commit
ee333ddb7d
23
js/main.js
23
js/main.js
@ -843,6 +843,8 @@ class Editor extends PrimaryView {
|
|||||||
else if (this.current_tool === 'force-floors') {
|
else if (this.current_tool === 'force-floors') {
|
||||||
// Walk the mouse movement and change each we touch to match the direction we
|
// Walk the mouse movement and change each we touch to match the direction we
|
||||||
// crossed the border
|
// crossed the border
|
||||||
|
// FIXME occasionally i draw a tetris S kinda shape and both middle parts point
|
||||||
|
// the same direction, but shouldn't
|
||||||
let i = 0;
|
let i = 0;
|
||||||
let prevx, prevy;
|
let prevx, prevy;
|
||||||
for (let [cx, cy] of walk_grid(this.mouse_cell[0], this.mouse_cell[1], x, y)) {
|
for (let [cx, cy] of walk_grid(this.mouse_cell[0], this.mouse_cell[1], x, y)) {
|
||||||
@ -855,12 +857,7 @@ class Editor extends PrimaryView {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let name;
|
let name;
|
||||||
let cell = this.stored_level.cells[cy][cx];
|
if (cx === prevx) {
|
||||||
if (cell[0].name.startsWith('force_floor_')) {
|
|
||||||
// Drawing a loop with force floors creates ice
|
|
||||||
name = 'ice';
|
|
||||||
}
|
|
||||||
else if (cx === prevx) {
|
|
||||||
if (cy > prevy) {
|
if (cy > prevy) {
|
||||||
name = 'force_floor_s';
|
name = 'force_floor_s';
|
||||||
}
|
}
|
||||||
@ -876,16 +873,24 @@ class Editor extends PrimaryView {
|
|||||||
name = 'force_floor_w';
|
name = 'force_floor_w';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.place_in_cell(cx, cy, name);
|
|
||||||
|
|
||||||
// The second cell tells us the direction to use for the first, assuming it
|
// The second cell tells us the direction to use for the first, assuming it
|
||||||
// had an RFF marking it
|
// had some kind of force floor
|
||||||
if (i === 2) {
|
if (i === 2) {
|
||||||
let prevcell = this.stored_level.cells[prevy][prevx];
|
let prevcell = this.stored_level.cells[prevy][prevx];
|
||||||
if (prevcell[0].name === 'force_floor_all') {
|
if (prevcell[0].name.startsWith('force_floor_')) {
|
||||||
prevcell[0].name = name;
|
prevcell[0].name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Drawing a loop with force floors creates ice (but not in the previous
|
||||||
|
// cell, obviously)
|
||||||
|
let cell = this.stored_level.cells[cy][cx];
|
||||||
|
if (cell[0].name.startsWith('force_floor_') && cell[0].name !== name) {
|
||||||
|
name = 'ice';
|
||||||
|
}
|
||||||
|
this.place_in_cell(cx, cy, name);
|
||||||
|
|
||||||
prevx = cx;
|
prevx = cx;
|
||||||
prevy = cy;
|
prevy = cy;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user