2022-09-03 21:40:18 +02:00
|
|
|
#![warn(absolute_paths_not_starting_with_crate)]
|
|
|
|
// #![warn(box_pointers)]
|
|
|
|
#![warn(elided_lifetimes_in_paths)]
|
|
|
|
#![warn(explicit_outlives_requirements)]
|
|
|
|
#![warn(keyword_idents)]
|
|
|
|
#![warn(macro_use_extern_crate)]
|
|
|
|
#![warn(meta_variable_misuse)]
|
|
|
|
#![warn(missing_abi)]
|
|
|
|
#![warn(missing_copy_implementations)]
|
|
|
|
#![warn(missing_debug_implementations)]
|
|
|
|
// #![warn(missing_docs)]
|
|
|
|
#![warn(non_ascii_idents)]
|
|
|
|
#![warn(noop_method_call)]
|
|
|
|
#![warn(pointer_structural_match)]
|
|
|
|
#![warn(rust_2021_incompatible_closure_captures)]
|
|
|
|
#![warn(rust_2021_incompatible_or_patterns)]
|
|
|
|
#![warn(rust_2021_prefixes_incompatible_syntax)]
|
|
|
|
#![warn(rust_2021_prelude_collisions)]
|
|
|
|
#![warn(single_use_lifetimes)]
|
|
|
|
#![warn(trivial_casts)]
|
|
|
|
#![warn(trivial_numeric_casts)]
|
|
|
|
#![warn(unreachable_pub)]
|
|
|
|
#![warn(unsafe_code)]
|
|
|
|
#![warn(unsafe_op_in_unsafe_fn)]
|
|
|
|
#![warn(unstable_features)]
|
|
|
|
#![warn(unused_crate_dependencies)]
|
|
|
|
#![warn(unused_extern_crates)]
|
|
|
|
#![warn(unused_import_braces)]
|
|
|
|
#![warn(unused_lifetimes)]
|
|
|
|
#![warn(unused_macro_rules)]
|
|
|
|
#![warn(unused_qualifications)]
|
|
|
|
#![warn(unused_results)]
|
|
|
|
#![warn(variant_size_differences)]
|
2022-08-25 15:45:45 +02:00
|
|
|
|
2022-09-03 21:40:18 +02:00
|
|
|
use bevy::{
|
|
|
|
app::App,
|
|
|
|
asset::Assets,
|
|
|
|
core_pipeline::core_2d::Camera2dBundle,
|
|
|
|
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
|
|
|
ecs::{
|
|
|
|
change_detection::ResMut,
|
|
|
|
system::{Commands, Res},
|
|
|
|
},
|
|
|
|
render::{
|
|
|
|
render_resource::{
|
|
|
|
Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages,
|
|
|
|
},
|
|
|
|
texture::{Image, ImageSettings},
|
|
|
|
},
|
2022-09-04 19:17:17 +02:00
|
|
|
ui::{entity::ImageBundle, Size, Style, UiImage, Val},
|
2022-09-03 21:40:18 +02:00
|
|
|
utils::default,
|
|
|
|
window::WindowDescriptor,
|
|
|
|
winit::WinitSettings,
|
|
|
|
DefaultPlugins,
|
|
|
|
};
|
|
|
|
use save::*;
|
2022-08-25 15:45:45 +02:00
|
|
|
|
2022-09-03 21:40:18 +02:00
|
|
|
fn generate_texture(
|
|
|
|
mut commands: Commands<'_, '_>,
|
|
|
|
mut images: ResMut<'_, Assets<Image>>,
|
|
|
|
world_manager: Res<'_, WorldManager>,
|
|
|
|
) {
|
|
|
|
let world = world_manager.get_world().unwrap();
|
|
|
|
|
|
|
|
let image_handle = images.add(Image {
|
2022-09-04 12:41:11 +02:00
|
|
|
data: world_manager.world_color_bytes(),
|
2022-09-03 21:40:18 +02:00
|
|
|
texture_descriptor: TextureDescriptor {
|
|
|
|
label: None,
|
|
|
|
size: Extent3d {
|
|
|
|
width: world.width as u32,
|
|
|
|
height: world.height as u32,
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
dimension: TextureDimension::D2,
|
|
|
|
format: TextureFormat::Rgba32Float,
|
|
|
|
mip_level_count: 1,
|
|
|
|
sample_count: 1,
|
|
|
|
usage: TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING,
|
|
|
|
},
|
|
|
|
..default()
|
|
|
|
});
|
|
|
|
|
|
|
|
_ = commands.spawn_bundle(Camera2dBundle::default());
|
2022-09-04 19:17:17 +02:00
|
|
|
_ = commands.spawn_bundle(ImageBundle {
|
|
|
|
style: Style {
|
|
|
|
size: Size::new(Val::Auto, Val::Auto),
|
2022-09-03 21:40:18 +02:00
|
|
|
..default()
|
2022-09-04 19:17:17 +02:00
|
|
|
},
|
|
|
|
image: UiImage(image_handle),
|
|
|
|
..default()
|
|
|
|
});
|
2022-09-03 21:40:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
|
let mut manager = WorldManager::new();
|
|
|
|
let world = manager.new_world()?;
|
|
|
|
|
|
|
|
App::new()
|
|
|
|
// Only run the app when there is user input. This will significantly reduce CPU/GPU use.
|
|
|
|
.insert_resource(WinitSettings::desktop_app())
|
|
|
|
// Use nearest-neighbor rendering for cripsier pixels
|
|
|
|
.insert_resource(ImageSettings::default_nearest())
|
|
|
|
.insert_resource(WindowDescriptor {
|
|
|
|
width: world.width as f32,
|
|
|
|
height: world.height as f32,
|
|
|
|
title: String::from("World-RS"),
|
|
|
|
resizable: true,
|
|
|
|
..default()
|
|
|
|
})
|
|
|
|
.insert_resource(manager)
|
|
|
|
.add_startup_system(generate_texture)
|
|
|
|
.add_plugins(DefaultPlugins)
|
|
|
|
.add_plugin(LogDiagnosticsPlugin::default())
|
|
|
|
.add_plugin(FrameTimeDiagnosticsPlugin::default())
|
|
|
|
.run();
|
|
|
|
|
|
|
|
Ok(())
|
2022-08-25 15:45:45 +02:00
|
|
|
}
|