cleanup
Before Width: | Height: | Size: 198 B After Width: | Height: | Size: 198 B |
Before Width: | Height: | Size: 211 B After Width: | Height: | Size: 203 B |
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 207 B |
Before Width: | Height: | Size: 205 B After Width: | Height: | Size: 211 B |
Before Width: | Height: | Size: 220 B After Width: | Height: | Size: 224 B |
Before Width: | Height: | Size: 205 B After Width: | Height: | Size: 205 B |
|
@ -154,7 +154,8 @@ impl Game {
|
|||
self.machine
|
||||
.board()
|
||||
.draw(d, textures, self.view_offset, self.zoom);
|
||||
self.machine.draw_marble_values(d, self.view_offset, self.zoom);
|
||||
self.machine
|
||||
.draw_marble_values(d, self.view_offset, self.zoom);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,7 +173,7 @@ impl Game {
|
|||
Color::new(32, 32, 32, 255),
|
||||
);
|
||||
|
||||
let tile_size = (16 << 1) as f32;
|
||||
let tile_size = (16 << self.zoom) as f32;
|
||||
let grid_spill_x = (self.view_offset.x).rem(tile_size) - tile_size;
|
||||
let grid_spill_y = (self.view_offset.y).rem(tile_size) - tile_size;
|
||||
d.gui_grid(
|
||||
|
|
|
@ -75,11 +75,11 @@ impl Machine {
|
|||
if let Some(tile) = self.board.get((x, y).into()) {
|
||||
let px = x as i32 * tile_size + offset.x as i32 + tile_size / 2;
|
||||
let py = y as i32 * tile_size + offset.y as i32 + tile_size / 2;
|
||||
if let Tile::Marble { value, dir } = tile{
|
||||
if let Tile::Marble { value, dir: _ } = tile {
|
||||
d.draw_text(
|
||||
&format!("{value}"),
|
||||
px - tile_size / 2 + 2,
|
||||
py - tile_size / 2 + 2,
|
||||
py - tile_size / 2 + 2,
|
||||
20,
|
||||
Color::MAGENTA,
|
||||
)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use raylib::prelude::*;
|
||||
use super::tile::*;
|
||||
use raylib::prelude::*;
|
||||
|
||||
#[derive(Debug, Default, Clone, Copy, PartialEq)]
|
||||
pub struct Pos {
|
||||
|
@ -94,7 +94,7 @@ impl Board {
|
|||
textures: &HashMap<String, Texture2D>,
|
||||
offset: Vector2,
|
||||
zoom: i32,
|
||||
){
|
||||
) {
|
||||
let tile_size = 16 << zoom;
|
||||
for x in 0..self.width {
|
||||
for y in 0..self.height {
|
||||
|
|
|
@ -92,7 +92,7 @@ impl Tile {
|
|||
x: i32,
|
||||
y: i32,
|
||||
size: i32,
|
||||
zoom:i32,
|
||||
zoom: i32,
|
||||
) {
|
||||
let tex_name = match self {
|
||||
Tile::Blank => "",
|
||||
|
@ -145,7 +145,7 @@ impl Tile {
|
|||
texture,
|
||||
Vector2::new((x - size / 2) as f32, (y - size / 2) as f32),
|
||||
0.0,
|
||||
(1<<zoom) as f32,
|
||||
(1 << zoom) as f32,
|
||||
Color::WHITE,
|
||||
);
|
||||
return;
|
||||
|
@ -153,40 +153,14 @@ impl Tile {
|
|||
|
||||
match self {
|
||||
Tile::Blank => (),
|
||||
Tile::Block => d.draw_rectangle(x - size / 2, y - size / 2, size, size, Color::DIMGRAY),
|
||||
Tile::Comment(c) => {
|
||||
d.draw_rectangle(x - size / 2, y - size / 2, size, size, Color::DIMGRAY);
|
||||
d.draw_text(&format!("{}", *c as char), x - 10, y - 10, 20, Color::WHITE);
|
||||
}
|
||||
Tile::Marble { value, dir } => {
|
||||
d.draw_circle(x, y, size as f32 * 0.35, Color::new(15, 15, 15, 255));
|
||||
d.draw_text(
|
||||
&format!("{value}"),
|
||||
x - size / 2 + 2,
|
||||
y - size / 2 + 2,
|
||||
20,
|
||||
Color::MAGENTA,
|
||||
);
|
||||
}
|
||||
Tile::Digit(n) => {
|
||||
d.draw_text(&String::from(*n as char), x - 10, y - 10, 20, Color::ORANGE)
|
||||
}
|
||||
Tile::Mirror(mirror) => {
|
||||
let height = size as f32 * 1.25;
|
||||
let width = (size / 4) as f32;
|
||||
let rec = Rectangle {
|
||||
x: x as f32,
|
||||
y: y as f32,
|
||||
width,
|
||||
height,
|
||||
};
|
||||
let rot = match mirror {
|
||||
MirrorType::Forward => 45.0,
|
||||
MirrorType::Back => -45.0,
|
||||
};
|
||||
d.draw_rectangle_pro(rec, Vector2::new(width, height) * 0.5, rot, Color::CYAN);
|
||||
}
|
||||
_ => d.draw_rectangle(x - size / 2, y - size / 2, size, size, Color::YELLOW),
|
||||
_ => d.draw_rectangle(x - size / 2, y - size / 2, size, size, Color::RED),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|