Skip to content
Snippets Groups Projects
resources.rs 1.04 KiB
Newer Older
use bevy::asset::AssetServerSettings;
use bevy::prelude::*;
use bevy::render::texture::ImageSettings;
use bevy::window::PresentMode;

use crate::system::camera::spawn_orthographic_camera;

#[cfg(target_arch = "wasm32")]
pub fn get_asset_path_string() -> String {
	String::from("assets")
}
#[cfg(not(target_arch = "wasm32"))]
pub fn get_asset_path_string() -> String {
	std::env::current_dir()
		.unwrap()
		.join("assets")
		.to_str()
		.unwrap()
		.to_string()
}

pub struct DefaultResourcesPlugin;
impl Plugin for DefaultResourcesPlugin {
	fn build(&self, app: &mut App) {
		app.insert_resource(WindowDescriptor {
			width: 1280.0,
			height: 720.0,
			resizable: true,
			title: String::from("Bevy 2D Template"),
			present_mode: PresentMode::AutoNoVsync,
			..Default::default()
		})
		.insert_resource(ImageSettings::default_nearest())
		.insert_resource(Msaa { samples: 1 })
		.insert_resource(ClearColor(Color::hex("040720").unwrap()))
		.insert_resource(AssetServerSettings {
			asset_folder: get_asset_path_string(),
			watch_for_changes: false,
		});
	}
}