Adds a test line drawn

master
Joey Pollack 2 years ago
parent cbba37a993
commit a14dcff8f9

86
Cargo.lock generated

@ -696,6 +696,18 @@ dependencies = [
"radsort", "radsort",
] ]
[[package]]
name = "bevy_prototype_lyon"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e347c16caede05dc5f774ba388cefeef0ab558a5601fc6b5ffd6606bef77308"
dependencies = [
"bevy",
"lyon_algorithms",
"lyon_tessellation",
"svgtypes",
]
[[package]] [[package]]
name = "bevy_ptr" name = "bevy_ptr"
version = "0.11.0" version = "0.11.0"
@ -1499,6 +1511,15 @@ dependencies = [
"miniz_oxide", "miniz_oxide",
] ]
[[package]]
name = "float_next_after"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fc612c5837986b7104a87a0df74a5460931f1c5274be12f8d0f40aa2f30d632"
dependencies = [
"num-traits",
]
[[package]] [[package]]
name = "fnv" name = "fnv"
version = "1.0.7" version = "1.0.7"
@ -2033,6 +2054,12 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "libm"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4"
[[package]] [[package]]
name = "libudev-sys" name = "libudev-sys"
version = "0.1.4" version = "0.1.4"
@ -2048,6 +2075,7 @@ name = "life_sim"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bevy", "bevy",
"bevy_prototype_lyon",
] ]
[[package]] [[package]]
@ -2066,6 +2094,48 @@ version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
[[package]]
name = "lyon_algorithms"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00a0349cd8f0270781bb93a824b63df6178e3b4a27794e7be3ce3763f5a44d6e"
dependencies = [
"lyon_path",
"num-traits",
]
[[package]]
name = "lyon_geom"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74df1ff0a0147282eb10699537a03baa7d31972b58984a1d44ce0624043fe8ad"
dependencies = [
"arrayvec",
"euclid",
"num-traits",
]
[[package]]
name = "lyon_path"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca507745ba7ccbc76e5c44e7b63b1a29d2b0d6126f375806a5bbaf657c7d6c45"
dependencies = [
"lyon_geom",
"num-traits",
]
[[package]]
name = "lyon_tessellation"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d2124218d5428149f9e09520b9acc024334a607e671f032d06567b61008977c"
dependencies = [
"float_next_after",
"lyon_path",
"thiserror",
]
[[package]] [[package]]
name = "mach2" name = "mach2"
version = "0.4.1" version = "0.4.1"
@ -2326,6 +2396,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"libm",
] ]
[[package]] [[package]]
@ -2820,6 +2891,12 @@ version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "238abfbb77c1915110ad968465608b68e869e0772622c9656714e73e5a1a522f" checksum = "238abfbb77c1915110ad968465608b68e869e0772622c9656714e73e5a1a522f"
[[package]]
name = "siphasher"
version = "0.3.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de"
[[package]] [[package]]
name = "slab" name = "slab"
version = "0.4.8" version = "0.4.8"
@ -2878,6 +2955,15 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fb1df15f412ee2e9dfc1c504260fa695c1c3f10fe9f4a6ee2d2184d7d6450e2" checksum = "8fb1df15f412ee2e9dfc1c504260fa695c1c3f10fe9f4a6ee2d2184d7d6450e2"
[[package]]
name = "svgtypes"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22975e8a2bac6a76bb54f898a6b18764633b00e780330f0b689f65afb3975564"
dependencies = [
"siphasher",
]
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.109" version = "1.0.109"

@ -7,6 +7,7 @@ edition = "2021"
[dependencies] [dependencies]
bevy = "0.11.0" bevy = "0.11.0"
bevy_prototype_lyon = "0.9.0"
# Enable high optimizations for dependencies (incl. Bevy), but not for our code: # Enable high optimizations for dependencies (incl. Bevy), but not for our code:

@ -4,6 +4,7 @@ use bevy::{
diagnostic::{FrameTimeDiagnosticsPlugin, DiagnosticsStore}, diagnostic::{FrameTimeDiagnosticsPlugin, DiagnosticsStore},
window::{PresentMode, WindowTheme}, window::{PresentMode, WindowTheme},
sprite::MaterialMesh2dBundle}; sprite::MaterialMesh2dBundle};
use bevy_prototype_lyon::prelude::*;
use world::WorldPlugin; use world::WorldPlugin;
use std::time::Instant; use std::time::Instant;
@ -43,7 +44,7 @@ fn main()
DefaultPlugins.set(WindowPlugin { DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window { primary_window: Some(Window {
title: "Life Sim".into(), title: "Life Sim".into(),
resolution: (1000., 1000.).into(), resolution: (700., 700.).into(),
present_mode: PresentMode::AutoVsync, present_mode: PresentMode::AutoVsync,
// Tells wasm to resize the window according to the available canvas // Tells wasm to resize the window according to the available canvas
fit_canvas_to_parent: true, fit_canvas_to_parent: true,
@ -59,7 +60,8 @@ fn main()
WorldPlugin { WorldPlugin {
grid_width: 100., grid_width: 100.,
grid_height: 100. grid_height: 100.
} },
ShapePlugin
)) ))
.insert_resource(SimulationState::new(200)) .insert_resource(SimulationState::new(200))
.insert_resource(Time::new(Instant::now())) .insert_resource(Time::new(Instant::now()))
@ -85,6 +87,17 @@ fn setup(mut commands: Commands, mut meshes: ResMut<Assets<Mesh>>, mut materials
Agent Agent
)); ));
// Line test
let line = shapes::Line(Vec2::ZERO, Vec2::new(100.0, 100.0));
commands.spawn((
ShapeBundle {
path: GeometryBuilder::build_as(&line),
..default()
},
Stroke::new(Color::ORANGE_RED, 5.0),
//Fill::color(Color::ORANGE_RED),
));
// UI // UI
// Text with multiple sections // Text with multiple sections
@ -150,3 +163,4 @@ fn ui_update(mut state: Res<SimulationState>, diagnostics: Res<DiagnosticsStore>
} }
} }
} }

@ -1,5 +1,6 @@
use bevy::{prelude::*, sprite::MaterialMesh2dBundle}; use bevy::prelude::*;
use bevy_prototype_lyon::prelude::*;
#[derive(Resource)] #[derive(Resource)]
struct WorldPluginState struct WorldPluginState
@ -42,19 +43,19 @@ impl Plugin for WorldPlugin
fn setup(mut commands: Commands, settings: Res<WorldPluginState>, mut meshes: ResMut<Assets<Mesh>>, mut materials: ResMut<Assets<ColorMaterial>>) fn setup(mut commands: Commands, settings: Res<WorldPluginState>, mut meshes: ResMut<Assets<Mesh>>, mut materials: ResMut<Assets<ColorMaterial>>)
{ {
// Camera // Camera
commands.spawn(Camera2dBundle::default()); //commands.spawn(Camera2dBundle::default());
// Add Grid // Add Grid
let cell_width = settings.window_width / settings.grid_width; // let cell_width = settings.window_width / settings.grid_width;
let cell_height = settings.window_height / settings.grid_height; // let cell_height = settings.window_height / settings.grid_height;
let line_size = 2; // let line_size = 2;
for i in 0..settings.grid_width as i32 // for i in 0..settings.grid_width as i32
{ // {
for j in 0..settings.grid_height as i32 // for j in 0..settings.grid_height as i32
{ // {
} // }
} // }
} }
// fn add_line(mut commands: Commands, point_a: Vec2, point_b: Vec2, line_size: i32) // fn add_line(mut commands: Commands, point_a: Vec2, point_b: Vec2, line_size: i32)

Loading…
Cancel
Save