Skip to content

Instantly share code, notes, and snippets.

using Microsoft.Xna.Framework;
using Nez;
using Nez.Sprites;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Vapor.Code.Utility;
@prime31
prime31 / gist:ab89f2d0b759dc11a315
Created December 10, 2015 18:38 — forked from anonymous/gist:8bb64b0556fecd13769f
Swept AABB Collisions C#
public static bool TestAABBSweep(Vector2 extents1, Vector2 centre1, Vector2 velocity1, Vector2 extents2, Vector2 centre2, Vector2 velocity2, out float t0, out float t1)
{
var aabb1 = new AABB(centre1, extents1);
var aabb2 = new AABB(centre2, extents2);
//Check if the boxes are currently overlapping
if (aabb1.Overlaps(aabb2))
{
t0 = t1 = 0;
return true;
@prime31
prime31 / ExampleUsage.cs
Last active October 24, 2022 09:51 — forked from MattRix/ObjectInspector.cs
Generic inspector class that lets you implement OnScene/InspectorGUI in your class file instead of in a separate custom editor. It also provides attributes for getting Vector3/Vector3[]/List<Vector3> editing capabilities right in the scene view and getting buttons for any methods in your class in the inspector.
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class ExampleUsage : MonoBehaviour
{
// this attribute will add handles for your Vector3s so that you can drag them around in the scene view
@prime31
prime31 / MiniJSON.cs
Created October 30, 2012 01:44 — forked from Borluse/MiniJSON.cs
Unity3D: MiniJSON Decodes and encodes simple JSON strings. Not intended for use with massive JSON strings, probably < 32k preferred. Handy for parsing JSON from inside Unity3d.
/*
* Copyright (c) 2012 Calvin Rien
*
* Based on the JSON parser by Patrick van Bergen
* http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html
*
* Simplified it so that it doesn't throw exceptions
* and can be used in Unity iPhone with maximum code stripping.
*
* Permission is hereby granted, free of charge, to any person obtaining