cleanup
This commit is contained in:
parent
b13d7aaf6d
commit
098dc9517d
2 changed files with 13 additions and 12 deletions
|
@ -215,23 +215,24 @@ impl Board {
|
|||
pub fn draw(&self, d: &mut RaylibDrawHandle, textures: &Textures, offset: Vector2, zoom: i32) {
|
||||
let tile_size = 16 << zoom;
|
||||
|
||||
let start_x = (-offset.x as i32) / tile_size + self.offset_x as i32 - 1;
|
||||
let start_x = (-offset.x as i32) / tile_size - 1;
|
||||
let tile_width = d.get_screen_width() / tile_size + 2;
|
||||
let start_y = (-offset.y as i32) / tile_size + self.offset_y as i32 - 1;
|
||||
let start_y = (-offset.y as i32) / tile_size - 1;
|
||||
let tile_height = d.get_screen_height() / tile_size + 2;
|
||||
|
||||
for x in start_x..(start_x + tile_width) {
|
||||
for y in start_y..(start_y + tile_height) {
|
||||
if self.in_bounds(Pos {
|
||||
x: x as isize,
|
||||
y: y as isize,
|
||||
}) {
|
||||
let tx = x as usize;
|
||||
let ty = y as usize;
|
||||
let tx = (x as isize + self.offset_x) as usize;
|
||||
let ty = (y as isize + self.offset_y) as usize;
|
||||
if self.in_bounds((tx, ty).into()) {
|
||||
let tile = self.rows[ty][tx];
|
||||
let px = (x - self.offset_x as i32) * tile_size + offset.x as i32;
|
||||
let py = (y - self.offset_y as i32) * tile_size + offset.y as i32;
|
||||
let texture = textures.get(&tile.texture());
|
||||
let texname = tile.texture();
|
||||
if texname == "" {
|
||||
continue;
|
||||
}
|
||||
let texture = textures.get(&texname);
|
||||
let px = x * tile_size + offset.x as i32;
|
||||
let py = y * tile_size + offset.y as i32;
|
||||
d.draw_texture_ex(
|
||||
texture,
|
||||
Vector2::new(px as f32, py as f32),
|
||||
|
|
|
@ -162,7 +162,7 @@ impl Tile {
|
|||
|
||||
pub fn texture(&self) -> String {
|
||||
match self {
|
||||
Tile::Blank => "transparent",
|
||||
Tile::Blank => "",
|
||||
Tile::Block => "block",
|
||||
Tile::Marble { value: _, dir: _ } => "marble",
|
||||
Tile::Digit(n) => return format!("digit_{n}"),
|
||||
|
|
Loading…
Reference in a new issue