cleanup
This commit is contained in:
parent
6a11320b27
commit
353f5b74e5
3 changed files with 39 additions and 26 deletions
11
README.md
11
README.md
|
@ -19,6 +19,17 @@ logic mostly like https://git.crispypin.cc/CrispyPin/marble
|
||||||
- option to use 8-bit marbles?
|
- option to use 8-bit marbles?
|
||||||
- blueprint rotation?
|
- blueprint rotation?
|
||||||
|
|
||||||
|
# physics
|
||||||
|
- find direct bounces (todo consistency)
|
||||||
|
- execute direct bounces
|
||||||
|
- mark tiles as Claimed, ClaimedIndirect, BlockedIndirect, Blocked
|
||||||
|
- direct movements can move to any but Blocked tiles
|
||||||
|
- indirect movements can only move to ClaimedIndirect
|
||||||
|
- Claimed + ClaimedIndirect = BlockedIndirect
|
||||||
|
- ClaimedIndirect + ClaimedIndirect = BlockedIndirect
|
||||||
|
- Claimed + Claimed = Blocked
|
||||||
|
- BlockedIndirect + Claimed = Claimed
|
||||||
|
|
||||||
## file hierarchy
|
## file hierarchy
|
||||||
```
|
```
|
||||||
- assets/
|
- assets/
|
||||||
|
|
|
@ -269,15 +269,7 @@ impl Editor {
|
||||||
let max = selection.0.max(selection.1) + (1, 1).into();
|
let max = selection.0.max(selection.1) + (1, 1).into();
|
||||||
let width = (max.x - min.x) as usize;
|
let width = (max.x - min.x) as usize;
|
||||||
let height = (max.y - min.y) as usize;
|
let height = (max.y - min.y) as usize;
|
||||||
let mut board = Board::new_empty(width, height);
|
self.source_board.get_rect(min, width, height)
|
||||||
for (target_x, x) in (min.x..=max.x).enumerate() {
|
|
||||||
for (target_y, y) in (min.y..=max.y).enumerate() {
|
|
||||||
if let Some(tile) = self.source_board.get(Pos { x, y }) {
|
|
||||||
board.set((target_x, target_y).into(), tile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
board
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn save_blueprint(&mut self, selection: (Pos, Pos)) {
|
fn save_blueprint(&mut self, selection: (Pos, Pos)) {
|
||||||
|
@ -914,14 +906,7 @@ impl Editor {
|
||||||
self.grow_board_and_update_view(
|
self.grow_board_and_update_view(
|
||||||
&mut (pos + (board.width() - 1, board.height() - 1).into()),
|
&mut (pos + (board.width() - 1, board.height() - 1).into()),
|
||||||
);
|
);
|
||||||
for x in 0..board.width() {
|
self.source_board.paste_board(pos, &board);
|
||||||
for y in 0..board.height() {
|
|
||||||
let p = (x, y).into();
|
|
||||||
if let Some(tile) = board.get(p) {
|
|
||||||
self.source_board.set(p + pos, tile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1024,14 +1009,7 @@ impl Editor {
|
||||||
self.grow_board_and_update_view(
|
self.grow_board_and_update_view(
|
||||||
&mut (pos + (board.width() - 1, board.height() - 1).into()),
|
&mut (pos + (board.width() - 1, board.height() - 1).into()),
|
||||||
);
|
);
|
||||||
for x in 0..board.width() {
|
self.source_board.paste_board(pos, &board);
|
||||||
for y in 0..board.height() {
|
|
||||||
let p = (x, y).into();
|
|
||||||
if let Some(tile) = board.get(p) {
|
|
||||||
self.source_board.set(p + pos, tile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,31 @@ impl Board {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn grow_to_include(&mut self, p: Pos) -> (PosInt,PosInt) {
|
pub fn paste_board(&mut self, pos: Pos, source: &Board) {
|
||||||
|
for x in 0..source.width() {
|
||||||
|
for y in 0..source.height() {
|
||||||
|
let offset = (x, y).into();
|
||||||
|
if let Some(tile) = source.get(offset) {
|
||||||
|
self.set(offset + pos, tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_rect(&self, pos: Pos, width: usize, height: usize) -> Board {
|
||||||
|
let mut out = Board::new_empty(width, height);
|
||||||
|
for x in 0..width {
|
||||||
|
for y in 0..height {
|
||||||
|
let offset = (x, y).into();
|
||||||
|
if let Some(tile) = self.get(offset + pos) {
|
||||||
|
out.set(offset, tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn grow_to_include(&mut self, p: Pos) -> (PosInt, PosInt) {
|
||||||
let mut offset_x = 0;
|
let mut offset_x = 0;
|
||||||
let mut offset_y = 0;
|
let mut offset_y = 0;
|
||||||
if p.x < 0 {
|
if p.x < 0 {
|
||||||
|
|
Loading…
Reference in a new issue