From 588797c4b762d6619328e1fb4a79329ff1991f57 Mon Sep 17 00:00:00 2001 From: dani Date: Mon, 10 Jul 2023 14:36:49 +0000 Subject: [PATCH] cleanup --- examples/test.rs | 21 --------------------- src/hexmap.rs | 4 ++-- src/rect.rs | 1 - src/vec_util.rs | 4 ++-- src/window.rs | 8 +------- 5 files changed, 5 insertions(+), 33 deletions(-) diff --git a/examples/test.rs b/examples/test.rs index e6dd78c..792ef1b 100644 --- a/examples/test.rs +++ b/examples/test.rs @@ -1,14 +1,11 @@ use glam::IVec2; use rand::Rng; use skunk2d::*; -use std::rc::Rc; const WIDTH: i32 = 1920 / 3; const HEIGHT: i32 = 1080 / 3; struct World { - img: Rc, - font: Rc, pos: IVec2, map: HexMap, } @@ -23,11 +20,6 @@ impl Game for World { window_state.set_palette(0, 0xc0, 0xf0, 0xd0); window_state.scramble_palette(); Self { - img: Image::load_data(include_bytes!("assets/test.gif")), - font: Tileset::load_data( - include_bytes!("assets/ega-8x14.gif"), - IVec2 { x: 16, y: 16 }, - ), pos: IVec2::ZERO, map: HexMap::new( IVec2 { x: 27, y: 13 }, @@ -59,18 +51,5 @@ impl Game for World { fn draw(&self, target: &mut Image) { target.clear(); target.draw_hexmap(IVec2 { x: 0, y: 0 }, &self.map); - /*target.draw_image(Vec2 { x: 200, y: 100 }, &self.img); - target.draw_image(self.pos, self.font.get(68)); - - target.draw_line( - Vec2 { - x: WIDTH / 2, - y: HEIGHT / 2, - }, - self.pos, - 10, - ); - - */ } } diff --git a/src/hexmap.rs b/src/hexmap.rs index 3c7a501..b6de7f6 100644 --- a/src/hexmap.rs +++ b/src/hexmap.rs @@ -40,9 +40,9 @@ impl HexMap { (match dir { Direction::North => IVec2 { x: 0, y: -1 }, Direction::NorthEast => IVec2 { x: 1, y: -1 + yoff }, - Direction::SouthEast => IVec2 { x: 1, y: 0 + yoff }, + Direction::SouthEast => IVec2 { x: 1, y: yoff }, Direction::South => IVec2 { x: 0, y: 1 }, - Direction::SouthWest => IVec2 { x: -1, y: 0 + yoff }, + Direction::SouthWest => IVec2 { x: -1, y: yoff }, Direction::NorthWest => IVec2 { x: -1, y: -1 + yoff, diff --git a/src/rect.rs b/src/rect.rs index 391357f..a81b6b9 100644 --- a/src/rect.rs +++ b/src/rect.rs @@ -1,6 +1,5 @@ use crate::vec_util::{IVec2Helper, IVec2Iter}; use glam::IVec2; -use num::{Num, ToPrimitive}; #[derive(Copy, Clone)] pub struct IRect { diff --git a/src/vec_util.rs b/src/vec_util.rs index 01dd178..506590f 100644 --- a/src/vec_util.rs +++ b/src/vec_util.rs @@ -41,9 +41,9 @@ impl Iterator for IVec2Iter { type Item = IVec2; fn next(&mut self) -> Option { - self.current.x = self.current.x + 1; + self.current.x += 1; if self.current.x >= self.end.x { - self.current.y = self.current.y + 1; + self.current.y += 1; self.current.x = self.start.x; if self.current.y >= self.end.y { return None; diff --git a/src/window.rs b/src/window.rs index abb4fd8..6ca724b 100644 --- a/src/window.rs +++ b/src/window.rs @@ -3,7 +3,6 @@ use crate::image::Image; use crate::Tileset; use glam::IVec2; use rand::Rng; -use rayon::prelude::*; use std::cmp::{max, min}; use std::num::NonZeroU32; use std::time::{Duration, Instant}; @@ -172,9 +171,7 @@ pub fn run(width: i32, height: i32, target_fps: u32) { WinitMouseButton::Right => MouseButton::Right, WinitMouseButton::Middle => MouseButton::Middle, //todo: handle other mousebuttons - WinitMouseButton::Other(b) => match b { - _ => MouseButton::Back, - }, + WinitMouseButton::Other(_) => MouseButton::Back, }; match state { ElementState::Pressed => { @@ -228,14 +225,11 @@ pub fn run(width: i32, height: i32, target_fps: u32) { { let width = width as usize; - let height = height as usize; let window_width = size.width as usize; - let window_height = size.height as usize; let scale = *scale; let chunk_size = scale * window_width; let screen_data = screen.data(); buf.chunks_exact_mut(chunk_size) - .into_iter() .enumerate() .for_each(|(y, chunk)| { for x in 0..width {