Skip to content

Commit

Permalink
refactor: refactor some code
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenMian committed Jan 15, 2024
1 parent d5ef2c2 commit ce7ca13
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct Database {
}

impl Database {
#[allow(dead_code)]
pub fn from_memory() -> Self {
Self {
connection: Connection::open_in_memory().expect("failed to open database"),
Expand Down
8 changes: 4 additions & 4 deletions src/systems/level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ pub fn spawn_board(
.with_children(|parent| {
for y in 0..level.dimensions.y {
for x in 0..level.dimensions.x {
let grid_position = Vector2::<i32>::new(x, y);
if level.get_unchecked(&grid_position) == Tile::Void {
let position = Vector2::<i32>::new(x, y);
if level.get_unchecked(&position) == Tile::Void {
continue;
}
let tiles = HashMap::from([
Expand All @@ -98,15 +98,15 @@ pub fn spawn_board(
(Tile::Player, 6),
]);
for (tile, sprite_index) in tiles.into_iter() {
if level.get_unchecked(&grid_position).intersects(tile) {
if level.get_unchecked(&position).intersects(tile) {
let mut entity = parent.spawn((
SpriteSheetBundle {
texture_atlas: texture_atlas_handle.clone(),
sprite: TextureAtlasSprite::new(sprite_index),
transform: Transform::from_xyz(0.0, 0.0, sprite_index as f32),
..default()
},
GridPosition(grid_position),
GridPosition(position),
));
if tile == Tile::Player {
entity.insert(Player);
Expand Down

0 comments on commit ce7ca13

Please sign in to comment.