Skip to content

Commit

Permalink
Chapter 02. Board generation
Browse files Browse the repository at this point in the history
  • Loading branch information
leonidv committed Nov 19, 2023
1 parent bf6a7f7 commit f95f83b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
@@ -1,5 +1,6 @@
{
"rust-analyzer.linkedProjects": [
"./board_plugin/Cargo.toml",
"./board_plugin/Cargo.toml"
],
"rust-analyzer.cargo.features": [
Expand Down
24 changes: 24 additions & 0 deletions board_plugin/src/lib.rs
@@ -1 +1,25 @@
pub mod components;
pub mod resources;

use bevy::log;
use bevy::prelude::*;
use resources::tile_map;
use resources::tile_map::TileMap;

pub struct BoardPlugin;

impl BoardPlugin {
fn create_board() {
let mut tile_map = TileMap::empty(20, 20);
tile_map.set_bombs(40);
#[cfg(feature="debug")]
log::info!("{}", tile_map.console_output());
}
}

impl Plugin for BoardPlugin {
fn build(&self, app: &mut App) {
app.add_systems(Startup, Self::create_board);
log::info!("Loaded Board Plugin");
}
}
6 changes: 6 additions & 0 deletions src/main.rs
@@ -1,7 +1,10 @@
use bevy::{prelude::*, window::WindowResolution};



#[cfg(feature = "debug")]
use bevy_inspector_egui::quick::WorldInspectorPlugin;
use board_plugin::BoardPlugin;

fn main() {
let mut app = App::new();
Expand All @@ -19,6 +22,9 @@ fn main() {
#[cfg(feature = "debug")]
app.add_plugins(WorldInspectorPlugin::new());


app.add_plugins(BoardPlugin);

// adapted from 0.8, 0.10 to 0.11
app.add_systems(Startup, camera_setup);
app.run();
Expand Down

0 comments on commit f95f83b

Please sign in to comment.