convert to macroquad and make it compile
This commit is contained in:
parent
1cc8e999b7
commit
f4348599f6
15 changed files with 1023 additions and 1090 deletions
|
@ -1,4 +1,4 @@
|
|||
use raylib::prelude::*;
|
||||
use macroquad::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::{tile::*, Pos, PosInt};
|
||||
|
@ -287,42 +287,41 @@ impl Grid {
|
|||
|
||||
pub fn draw(
|
||||
&self,
|
||||
d: &mut RaylibDrawHandle,
|
||||
textures: &Textures,
|
||||
offset: Vector2,
|
||||
offset: Vec2,
|
||||
scale: f32,
|
||||
power_directions: bool,
|
||||
) {
|
||||
let tile_size = (TILE_TEXTURE_SIZE * scale) as i32;
|
||||
|
||||
let start_x = (-offset.x as i32) / tile_size - 1;
|
||||
let tiles_width = d.get_screen_width() / tile_size + 3;
|
||||
let tiles_width = screen_width() as i32/ tile_size + 3;
|
||||
let start_y = (-offset.y as i32) / tile_size - 1;
|
||||
let tiles_height = d.get_screen_height() / tile_size + 3;
|
||||
let tiles_height = screen_height() as i32 / tile_size + 3;
|
||||
|
||||
for x in start_x..(start_x + tiles_width) {
|
||||
for y in start_y..(start_y + tiles_height) {
|
||||
let px = x * tile_size + offset.x as i32;
|
||||
let py = y * tile_size + offset.y as i32;
|
||||
let px = (x * tile_size) as f32 + offset.x;
|
||||
let py = (y * tile_size) as f32 + offset.y;
|
||||
if let Some(tile) = self.get((x, y).into()) {
|
||||
let texname = tile.texture();
|
||||
if texname.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let texture = textures.get(texname);
|
||||
draw_scaled_texture(d, texture, px, py, scale);
|
||||
draw_scaled_texture( texture, px, py, scale);
|
||||
if power_directions {
|
||||
if let Tile::Powerable(_, state) = &tile {
|
||||
for dir in Direction::ALL {
|
||||
if state.get_dir(dir) {
|
||||
let texture = textures.get(dir.debug_arrow_texture_name());
|
||||
draw_scaled_texture(d, texture, px, py, scale);
|
||||
draw_scaled_texture( texture, px, py, scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
d.draw_rectangle(px, py, tile_size, tile_size, Color::new(0, 0, 0, 80));
|
||||
draw_rectangle(px, py, tile_size as _, tile_size as _, Color::from_rgba(0, 0, 0, 80));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue