Skip to content

Instantly share code, notes, and snippets.

View ashblue's full-sized avatar

Ash Blue ashblue

View GitHub Profile
/**
* Detect overlap between two square objects
* @param square1 {object} x, y, width, height
* @param square2 {object} x, y, width, height
* @returns {boolean}
*/
function getOverlap(square1, square2) {
return square1.x < square2.x + square2.width &&
square1.x + square1.width > square2.x &&
square1.y < square2.y + square2.height &&
/**
* Weltmeister - Multiple entity select and move
* @author Ash Blue (Twitter @ashbluewd)
* @src https://gist.github.com/ashblue/9901165
*
* Allows you to select and move multiple entities in Weltmeister with a single command
*
* Quick usage instructions
* - Select the entity layer
* - Hold down shift
@ashblue
ashblue / tween.js
Last active August 29, 2015 13:58
ImpactJS Tweening plugin (fast and minimal).
ig.module(
'plugins.tween'
).requires(
'impact.entity'
).defines( function() {
'use strict';
var _easing = {
linear: {
easeNone: function (k) {
@ashblue
ashblue / energy-bar.cs
Created July 7, 2014 11:36
Unity energy bar example
using UnityEngine;
using System.Collections;
public class PlayerHealth : MonoBehaviour {
Vector2 pos = new Vector2(10, 10);
Vector2 size = new Vector2(200, 16);
float barFill = 0.8f;
string barText = "Health";
@ashblue
ashblue / Tiler.cs
Created July 16, 2014 04:48
Unity background tiling script
using UnityEngine;
using System.Collections;
// Must be applied to an empty object wrapping a sprite image
public class Tiler : MonoBehaviour {
Hashtable tileCollection = new Hashtable(); // X and Y coordinates formatted as x0y0 relative to the starting tile
GameObject originTile;
public bool repeatX = true;
public bool repeatY = false;
using UnityEngine;
using System.Collections;
// Force inject a sprite renderer before initialization (if not present)
[RequireComponent(typeof(SpriteRenderer))]
// @TODO Warning, does not take into account parallaxed weight, needs to be added manually
// @NOTE Must have a parent container
public class TilerChild : MonoBehaviour {
public bool repeatX = false;
@ashblue
ashblue / 0_reuse_code.js
Created August 27, 2014 17:29
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#
# Offer Drawer Module
#
# @author
#
(($, window, document) ->
class offerDrawerModule
_data: undefined
_defaultId: '#offer-drawer'
@ashblue
ashblue / maps.html
Created September 16, 2014 22:59
GMaps test Aquent Bootstrap
<iframe width="600" height="450" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/search?q=https://www.google.com/maps/embed/v1/search?q=360%203rd%20Street%2C%20San%20Francisco%2C%20CA%2C%20United%20States&key=AIzaSyA9R4ONwGZtWSfenQvFXaaLwkCyHMq5o7k"></iframe>
@ashblue
ashblue / DialogueDbManager.cs
Created December 19, 2014 03:20
Add multiple databases at load time to the master Dialogue System Database.
using UnityEngine;
using System.Collections.Generic;
namespace PixelCrushers.DialogueSystem.Adnc {
public class DialogueDbManager : MonoBehaviour {
[Tooltip("Allows you to add multiple databases to the current Dialogue System. @IMPORTANT Make sure to run the ID assigner to prevent overwriting.")]
[SerializeField] List<DialogueDatabase> db;
// Use this for initialization
void Awake () {