Skip to content

Instantly share code, notes, and snippets.

use std::time::Duration;
use bevy::color::palettes::css::RED;
use bevy::math::VectorSpace;
use bevy::prelude::*;
use bevy::time::common_conditions::once_after_delay;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, |mut commands: Commands| {
use bevy::prelude::*;
fn main() {
// create an alternative Update schedule with a new set of systems
// and store it in a resource to swap later
let mut update = Schedule::new(Update);
update.add_systems(bar);
let mut app = App::new();
app
#[allow(unused_imports)]
use tracing::{info,warn,debug,error};
use std::{io, fs};
use std::path::Path;
use tracing_appender::non_blocking::WorkerGuard;
use tracing_subscriber::{fmt, layer::SubscriberExt, EnvFilter };
/// Sets up logging to both stdout and files
pub fn setup<P: AsRef<Path> + Clone>(crate_name: &str, dir: P) -> WorkerGuard {
use bevy::prelude::*;
use bevy::reflect::{GetTypeRegistration, ReflectMut, Typed, TypeInfo};
fn main() {
let mut app = App::new();
app
.add_plugins(MinimalPlugins)
.register_type_data::<String, ReflectFoo>()
.register_type_data::<usize, ReflectFoo>()
.register_type_data::<bool, ReflectFoo>()
@thebluefish
thebluefish / index.html
Created March 20, 2024 19:53
bevy WASM MVCE
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>BEVY</title>
<link data-trunk rel="copy-dir" href="assets" />
<style>
body, html {
height: 100%;
}
use bevy::app::prelude::*;
use dyn_clone::DynClone;
pub trait AppExt {
fn add_all_plugins(&mut self);
}
impl AppExt for App {
fn add_all_plugins(&mut self) {
for plugin in inventory::iter::<AutoPlugin> {
@thebluefish
thebluefish / Cargo.toml
Last active February 24, 2024 00:26
Example for setting up a minimal logger to both file and stdout with tracing
[features]
default = ["tracy"]
tracy = []
[dependencies]
tracing = "0.1"
tracing-appender = "0.2"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tracing-tracy = "0.11.0"
use std::fs::File;
use std::io::{BufWriter, Read};
use walkdir::WalkDir;
use foo::Foo;
/// Converts postcard `.post` files to bincode `.bin` files assuming they represent `Foo` data
fn main() -> anyhow::Result<()> {
let root = std::env::current_dir()?.join("data");
for entry in WalkDir::new(&root).sort_by_file_name().into_iter().filter_map(|e| e.ok()) {
let path = entry.into_path();
use bevy::prelude::*;
fn main() {
divan::main();
}
#[divan::bench]
fn reflect() {
let mut input: Box<dyn MovementField> = Box::new(PlayerInput::default());
for n in 1..=1000 {
use bevy::app::AppExit;
use bevy::prelude::*;
use bevy::window::WindowCloseRequested;
fn main() {
App::new()
.init_state::<ExitState>()
.add_plugins(DefaultPlugins.set(WindowPlugin {
close_when_requested: false,
..default()