Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263use bevy::input::common_conditions::input_toggle_active;use bevy_inspector_egui::{bevy_egui::EguiPlugin, quick::WorldInspectorPlugin};
use crate::prelude::*;
pub struct SetupPlugin;
impl Plugin for SetupPlugin { fn build(&self, app: &mut App) { app.add_plugins(( DefaultPlugins.set(ImagePlugin::default_nearest()), EguiPlugin::default(), WorldInspectorPlugin::new().run_if(input_toggle_active(false, KeyCode::Escape)), )) .insert_resource(ClearColor(Color::BLACK)) .init_resource::<MapEntities>() .init_resource::<PlayerRenderState>() .add_systems(Startup, (setup.spawn(), load_font)); }}
fn setup() -> impl SceneList { bsn_list![Camera2d, background(), player()]}
fn background() -> impl Scene { bsn! { NeedsLayout TileSize { width: {SCREEN_WIDTH as f32 + SCREEN_PADDING * 2.}, height: {SCREEN_HEIGHT as f32 + SCREEN_PADDING * 2.}, } Sprite { color: {color::GRAY_800}, } Transform::from_translation(Vec3::new(0., 0., Z_BACKGROUND)) }}
fn player() -> impl Scene { bsn! { Player Position{ x: 40, y: 25 } Glyph { char: {'@' as u8}, foreground: {color::RED_500}, background: Color::BLACK, } }}
fn load_font( mut commands: Commands, asset_server: Res<AssetServer>, mut texture_atlas_layouts: ResMut<Assets<TextureAtlasLayout>>,) { let texture = asset_server.load("frogblock-2.1.png"); let texture_atlas_layout = TextureAtlasLayout::from_grid(UVec2::splat(8), 16, 16, None, None); let atlas = texture_atlas_layouts.add(texture_atlas_layout);
commands.insert_resource(FontTextureAtlas { texture, atlas });}