Skip to content

Instantly share code, notes, and snippets.

Avatar

Carter Anderson cart

View GitHub Profile
View move_player.rs
use bevy::prelude::*;
struct Player {
velocity: Vec3,
}
fn main() {
App::build()
.add_plugins(DefaultPlugins)
.add_startup_system(spawn_player.system())
View button.rs
// Anchors
.spawn(ButtonComponents {
node: Node::with_size(Anchors::CENTER, Size {
Dimension::Points(150.0),
Dimension::Points(70.0)
}),
material: button_materials.normal,
..Default::default()
})
.with_children(|parent| {
View stretch.rs
use bevy_ecs::{Changed, Entity, Query, Res, ResMut, With, Without};
use bevy_math::Vec2;
use bevy_render::renderer::RenderResources;
use bevy_transform::prelude::{Children, Parent, Transform};
use bevy_window::Windows;
use std::collections::HashMap;
use stretch::{number::Number, result::Layout, style::Style, Stretch};
#[derive(Debug, Clone, Default, RenderResources)]
pub struct Node {
View tracker.rs
use std::{fmt::Debug, ops::{Deref, DerefMut}};
pub struct Track<T> {
modified: bool,
value: T,
}
pub trait Tracker {
fn is_modified(&self) -> bool;
fn reset(&mut self);
View gist:3e77d6537e1a0979a69de5c6749b6bcb
Entity [
MyComponent,
Scale { x: 2.0, y: 2.0, z: 2.0 },
PropDemo {
value: "hello",
sequence: [0,1,2],
map: {field: 1.0, hello: "hi"},
nested: {field: [{test: 1.0}]}
},
// Children entities are nested
View gist:1b97ea56303726eff05fdac41168b9d1
PipelineLayout {
bind_groups: [
BindGroupDescriptor {
index: 0,
bindings: [
BindingDescriptor {
name: "Camera2d",
index: 0,
bind_type: Uniform {
dynamic: false,
@cart
cart / FXAA.tscn
Last active Nov 24, 2022
Godot Nvidia FXAA 3.11 Port
View FXAA.tscn
[gd_scene load_steps=3 format=2]
[sub_resource type="Shader" id=1]
code = "shader_type canvas_item;
// Godot Nvidia FXAA 3.11 Port
// Usage: Drop this in to any 3D scene for FXAA! This is a port of the \"PC High Quality Preset 39\". However the medium quality
// parameters are also included. For medium quality, just comment out sections \"PS 6\" and above and uncomment the \"med 13\" variables.
@cart
cart / gist:cc095f4950c40c1fe25169be5ee78247
Created Feb 1, 2018
A collection of C# Math extensions for Godot
View gist:cc095f4950c40c1fe25169be5ee78247
using Godot;
namespace HighHat.MathHelpers
{
public static class MathExtensions
{
// TODO: expose Godot's Transform::interpolate_with to scripting. This is just a C# port
public static Transform InterpolateWith(this Transform transform, Transform targetTransform, float percent, bool includeScale = true)
{
var rotation = transform.basis.Orthonormalized().ToQuat();
@cart
cart / NodeExtensions.cs
Created Feb 1, 2018
A collection of C# Node extensions for Godot
View NodeExtensions.cs
using Godot;
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace HighHat.Scene.Nodes
{
public static class NodeExtensions
{
private static Regex _nameRegex = new Regex("@*(?<Name>[\\w|\\d]+)@*.*");