Skip to content
Snippets Groups Projects
Commit 5deacce4 authored by radow's avatar radow
Browse files

fiexed level entrance not spawning and a few errors

parent f037e0ab
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,8 @@ use crate::game_state::{config, Point}; ...@@ -2,6 +2,8 @@ use crate::game_state::{config, Point};
use crate::game_state::enemy::Enemy; use crate::game_state::enemy::Enemy;
use crate::game_state::tile::Tile; use crate::game_state::tile::Tile;
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
use tetra::math::Vec2;
use std::cmp;
use std::collections::HashMap; use std::collections::HashMap;
type Board = [[Tile; config::BOARD_HEIGHT as usize]; config::BOARD_WIDTH as usize]; type Board = [[Tile; config::BOARD_HEIGHT as usize]; config::BOARD_WIDTH as usize];
...@@ -102,7 +104,7 @@ impl Level { ...@@ -102,7 +104,7 @@ impl Level {
let with_player = Level::add_player(with_rooms); let with_player = Level::add_player(with_rooms);
let with_enemies = Level::add_enemies(enemy_count, with_player); let with_enemies = Level::add_enemies(enemy_count, with_player);
let with_exit = Level::add_exit(with_enemies); let with_exit = Level::add_exit(with_enemies);
return with_enemies; return with_exit;
} }
fn add_walls(board: Board) -> Board { fn add_walls(board: Board) -> Board {
...@@ -223,8 +225,8 @@ impl Room{ ...@@ -223,8 +225,8 @@ impl Room{
fn new() -> Room{ fn new() -> Room{
let x = thread_rng().gen_range(1, config::BOARD_WIDTH-2); let x = thread_rng().gen_range(1, config::BOARD_WIDTH-2);
let y = thread_rng().gen_range(1, config::BOARD_HEIGHT-2); let y = thread_rng().gen_range(1, config::BOARD_HEIGHT-2);
let w = thread_rng().gen_range(1, cmp::min(6, BOARD_WIDTH-x)); let w = thread_rng().gen_range(1, cmp::min(6, config::BOARD_WIDTH-x));
let h = thread_rng().gen_range(1, cmp::min(6, BOARD_HEIGHT-y)); let h = thread_rng().gen_range(1, cmp::min(6, config::BOARD_HEIGHT-y));
Room{x,y,w,h,} Room{x,y,w,h,}
} }
fn carve(&self, board:Board)->Board{ fn carve(&self, board:Board)->Board{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment