Skip to content

Instantly share code, notes, and snippets.

View Bradshaw's full-sized avatar
🚀
Lost in space

Gaeel Bradshaw-Rodriguez Bradshaw

🚀
Lost in space
View GitHub Profile
int d = 10;
int led = 13;
int t = 0;
unsigned long lastMicros;
unsigned long deltaMicros;
double timeStep;
double timeUntil;
@Bradshaw
Bradshaw / TweenUtils.cs
Created August 6, 2018 15:26
Start of a tween system
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public delegate float TweenFunc(float t);
public static class TweenUtils {
@Bradshaw
Bradshaw / Brainput.cs
Last active July 19, 2018 08:47
Just let met poll the joysticks plz Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class Brainput{
public static float GetAxis(int controller, int axis){
return Input.GetAxis("joystick " + controller + " analog " + axis);
}
public static bool GetButton(int controller, int button){
@Bradshaw
Bradshaw / AimTracker.cs
Created July 18, 2018 17:26
Little delegate example
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// This is what our events look like
public delegate void AimTrackerEvent(Vector3 point, int playerNumber);
public class AimTracker : MonoBehaviour {
// These are all the events
<events>
<spell>.onResolve(<spell>)
explode()
//removes 16 bytes from all entities within
//100 ms range
fireball()
//travels across the server and removes
//16 bytes from the first entity it touches
@Bradshaw
Bradshaw / Strings.cs
Last active April 13, 2018 09:23
Singleton example
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Strings : MonoBehaviour {
public TextAsset dataText;
Dictionary<string, string> data;
// Use this for initialization
@Bradshaw
Bradshaw / TrucMuche.cs
Last active April 13, 2018 07:35
Serialize/Deserialize example
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
public class TrucMuche : MonoBehaviour {
public string saveFile = "character.json";
public CharacterSheet character;
@Bradshaw
Bradshaw / HighlightIfVisible.cs
Created April 11, 2018 14:25
Quick demo of a "visibility detection" script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HighlightIfVisible : MonoBehaviour {
public Color visible;
public Color invisible;
// Use this for initialization
@Bradshaw
Bradshaw / EventThingy.cs
Created March 22, 2018 08:34
Example event trigger and event reaction
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Create an event type
public delegate void GenericEvent();
public class EventThingy : MonoBehaviour {
// Create an event
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum EaseType {
In,
Out,
InOut
}
public enum EaseFunc {