Skip to content

Instantly share code, notes, and snippets.

View ashblue's full-sized avatar

Ash Blue ashblue

View GitHub Profile
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 / 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;
@ashblue
ashblue / loader.cs
Created July 11, 2014 22:14
Unity loader
using UnityEngine;
using System.Collections;
// @TODO While this is great for debug purposes, all of this data should be loaded a level higher in the actual game
public class SceneLoader : MonoBehaviour {
GameObject map;
void Awake () {
// Check if the MapData prefab already exists from DontDestroyOnLoad
// If it does keep on going, if it doesn't create a new one
@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 / 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) {
/**
* 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
/**
* 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 &&
@ashblue
ashblue / A-Pen-by-Ash-Blue.markdown
Created December 2, 2013 21:27
A Pen by Ash Blue.
@ashblue
ashblue / particle-generator.js
Created September 26, 2013 21:16
ImpactJS particle generator, requires a particle class passed to it in order to work.
ig.module(
'game.entities.particle-generator'
)
.requires(
'impact.entity'
)
.defines(function(){
'use strict';
// @TODO Must use pooling for individual particles
@ashblue
ashblue / sass-media-query.css.scss
Created August 20, 2013 21:08
SASS Media Queries done right
/**
Targets small screen sizes and below, hides CSS from all other sizes
@example
@include screen-small {
#main {
width: auto;
background: #000;
}
}