Skip to content

Instantly share code, notes, and snippets.

use bevy::prelude::*;
use std::collections::HashSet;
/// Example demonstrating despawning all entities that were spawned during a specific state
fn main() {
let mut app = App::new();
app
.add_state::<AppState>()
.insert_resource(EntityRecord(HashSet::new()))
use bevy::prelude::*;
use bevy::reflect::{ReflectFromPtr, ReflectMut};
/// Example demonstrating how to print and mutate the resources of a world using reflection
fn main() {
App::new()
.init_resource::<AppTypeRegistry>()
.register_type::<Foo>()
.register_type::<Bar>()
.insert_resource(Foo::A)
use bevy::app::ScheduleRunnerPlugin;
use bevy::ecs::schedule::{ExecutorKind, ScheduleLabel};
use bevy::prelude::*;
fn main() {
let mut app = App::empty();
let mut schedule = Schedule::new();
schedule.set_executor_kind(ExecutorKind::SingleThreaded);
<!-- Avilable under MIT, Apache-2.0, The Unlicense, or the WTFPL at your choice -->
<svg class="eye" class:eye-open={$is_connected} viewBox="0 -150 400 300" width="80" xmlns="http://www.w3.org/2000/svg">
<g stroke-width="32" fill="none">
<path d={top_path} stroke="currentColor">
<animate bind:this={eyecon_close_top_anim} dur="0.2s" attributeName="d" from={top_path} to={path_closed} fill="freeze" begin="indefinite" />
<animate bind:this={eyecon_open_top_anim} dur="0.2s" attributeName="d" from={path_closed} to={top_path} fill="freeze" begin="indefinite" />
</path>
<path d={bottom_path} stroke="currentColor">
<animate bind:this={eyecon_close_bottom_anim} dur="0.2s" attributeName="d" from={bottom_path} to={path_closed} fill="freeze" begin="indefinite" />
<animate bind:this={eyecon_open_bottom_anim} dur="0.2s" attributeName="d" from={path_closed} to={bottom_path} fill="freeze" begin="indefinite" />
//! A shader that uses "shaders defs", which selectively toggle parts of a shader.
use std::time::Duration;
use bevy::{
pbr::{MaterialPipeline, MaterialPipelineKey},
prelude::*,
reflect::{TypePath, TypeUuid},
render::{
mesh::MeshVertexBufferLayout,
render_resource::{
@thebluefish
thebluefish / tsync_serde_test.rs
Created May 11, 2023 17:07
Tests serializing tsync example types to and from strings using serde
use chrono::{NaiveDate, NaiveDateTime};
use serde::{Deserialize, Serialize};
use tsync::tsync;
fn main() {
let msg = serde_json::to_string(&Message::Response(Response {
id: "Foo".into(),
result: NaiveDate::from_ymd(2016, 7, 8).and_hms(9, 10, 11),
})).unwrap();
use bevy::prelude::*;
use bevy_inspector_egui::quick::WorldInspectorPlugin;
use std::{env, fs};
use std::path::Path;
fn main() {
App::new()
.add_plugin(DevAssetPlugin::default())
.add_plugins(DefaultPlugins)
.add_plugin(WorldInspectorPlugin::new())
@thebluefish
thebluefish / TitleBarElectron.vue
Created October 22, 2021 22:36
An Electron 11 titlebar demo using Vue, HTML, SCSS
<template>
<header class="titlebar">
<div class="spacer">
<div :class="maximized ? 'drag drag-max' : 'drag drag-min'"/>
</div>
<div class="system-bar">
<button class="sys-btn" @click.stop="onMinimize()">
<img src="/caption-buttons.svg#minimize">
</button>
<button class="sys-btn" @click.stop="onMaximize()">
@thebluefish
thebluefish / windows_hotplug.rs
Created May 25, 2021 19:22
first-draft windows hotplug support using subclass.
use bevy::prelude::*;
use bevy::{input::keyboard::KeyboardInput, prelude::*};
use bevy::winit::WinitWindows;
use winit::platform::windows::WindowExtWindows;
use bevy::window::WindowCreated;
use bevy::app::{Events, ManualEventReader};
use winapi::{
DEFINE_GUID,
ctypes::c_void,
shared::{
@thebluefish
thebluefish / bevy_ex_asset_loading
Created November 26, 2020 02:22
Demonstrates waiting for assets to load asynchronously
use bevy::{prelude::*, asset::LoadState};
fn main() {
App::build()
.add_resource(GameState::Loading)
.add_resource(PendingAssets(Vec::new()))
.add_plugins(DefaultPlugins)
.add_startup_system(load_some_assets.system())
.add_system(loading.system())
.add_system(loaded.system())