shifting in mapedit

This commit is contained in:
dani 2023-08-23 19:21:09 +00:00
parent f0ad2726f8
commit 8d79862124
5 changed files with 82 additions and 1 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -49,4 +49,56 @@ impl Background {
}
}
}
/// Shifts all tiles to the left, wrapping
pub fn shift_left(&mut self) {
for y in 0..self.size.y as usize {
let tmp = self.tiles[0][y];
for x in 0..self.size.x as usize - 1 {
self.tiles[x][y] = self.tiles[x+1][y];
}
self.tiles[self.size.x as usize - 1][y] = tmp;
}
}
/// Shifts all tiles to the right, wrapping
pub fn shift_right(&mut self) {
for y in 0..self.size.y as usize {
let tmp = self.tiles[self.size.x as usize - 1][y];
for x in (1..self.size.x as usize).rev() {
self.tiles[x][y] = self.tiles[x-1][y];
}
self.tiles[0][y] = tmp;
}
}
/// Shifts all tiles up, wrapping
pub fn shift_up(&mut self) {
for x in 0..self.size.x as usize {
let tmp = self.tiles[x][0];
for y in 0..self.size.y as usize - 1 {
self.tiles[x][y] = self.tiles[x][y+1];
}
self.tiles[x][self.size.y as usize - 1] = tmp;
}
}
/// Shifts all tiles down, wrapping
pub fn shift_down(&mut self) {
for x in 0..self.size.x as usize {
let tmp = self.tiles[x][self.size.y as usize - 1];
for y in (1..self.size.y as usize).rev() {
self.tiles[x][y] = self.tiles[x][y-1];
}
self.tiles[x][0] = tmp;
}
}
}

View File

@ -22,4 +22,8 @@ pub const BUT_LAYER1: usize = 3;
pub const BUT_LAYER2: usize = 4;
pub const BUT_LAYER3: usize = 5;
pub const BUT_LAYERS: usize = 6;
pub const BUT_EXIT: usize = 8;
pub const BUT_SHIFT_LEFT: usize = 8;
pub const BUT_SHIFT_RIGHT: usize = 9;
pub const BUT_SHIFT_UP: usize = 10;
pub const BUT_SHIFT_DOWN: usize = 11;
pub const BUT_EXIT: usize = 13;

View File

@ -232,6 +232,26 @@ pub(crate) fn run_mapedit() {
stuff.all_layers = !stuff.all_layers;
stuff.set_state(stuff.state);
}
BUT_SHIFT_LEFT => {
stuff.gsa1.bg[0].shift_left();
stuff.gsa1.bg[1].shift_left();
stuff.gsa1.bg[2].shift_left();
}
BUT_SHIFT_RIGHT => {
stuff.gsa1.bg[0].shift_right();
stuff.gsa1.bg[1].shift_right();
stuff.gsa1.bg[2].shift_right();
}
BUT_SHIFT_UP => {
stuff.gsa1.bg[0].shift_up();
stuff.gsa1.bg[1].shift_up();
stuff.gsa1.bg[2].shift_up();
}
BUT_SHIFT_DOWN => {
stuff.gsa1.bg[0].shift_down();
stuff.gsa1.bg[1].shift_down();
stuff.gsa1.bg[2].shift_down();
}
BUT_EXIT => {
println!("exit");
*control_flow = ControlFlow::Exit;

View File

@ -75,6 +75,11 @@ impl Stuff {
};
self.gsa2.bg[2].tiles[0][BUT_LAYERS] = if self.all_layers { 0x7114 } else { 0x7014 };
self.gsa2.bg[2].tiles[0][BUT_SHIFT_LEFT] = 0x7314;
self.gsa2.bg[2].tiles[0][BUT_SHIFT_RIGHT] = 0x7315;
self.gsa2.bg[2].tiles[0][BUT_SHIFT_UP] = 0x7316;
self.gsa2.bg[2].tiles[0][BUT_SHIFT_DOWN] = 0x7317;
self.gsa2.bg[2].size = IVec2 { x: 120, y: 68 }; //enough to cover 4k monitors? <_<
self.gsa2.bg[3].size = IVec2 { x: 240, y: 136 };