Skip to content

Instantly share code, notes, and snippets.

View jessefreeman's full-sized avatar

Jesse Freeman jessefreeman

View GitHub Profile
@jessefreeman
jessefreeman / gist:a087ab7e3373da8ed5e1
Last active August 29, 2015 14:08
FlappyJetroid Workshop
var SPEED = 200;
var GRAVITY = 900;
var JET = 420;
var OPENING = 200;
var SPAWN_RATE = 1.25;
var state = {
preload: function(){
this.load.image('wall', '/assets/wall.png');
@jessefreeman
jessefreeman / CameraFollow.cs
Created March 20, 2015 18:51
Simple Unity 2D Camera
using UnityEngine;
using System.Collections;
public class CameraFollow : MonoBehaviour {
public GameObject target;
public bool lockXAxis;
public bool lockYAxis;
public bool lockZAxis = true;
public bool useBounds = false;
using System;
using UnityEngine;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class GameObjectUtil
{
@jessefreeman
jessefreeman / ColorMap.as
Created December 16, 2010 03:22
Use this class to set up a simple color hit test based image. Simply create a png in Photoshop, add a color bar or key to the top of the file, and draw colored shapes which will be used as a bounds for the collision detection.
/*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
@jessefreeman
jessefreeman / TimeMethodExecutionUtil
Created January 27, 2011 15:46
Use this simple util to time how long it takes to execute a method or function. Supports returning a value and passing in multiple arguments.
/**
* The MIT License
*
* Copyright (c) 2009 @author jessefreeman
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@jessefreeman
jessefreeman / TextFileUtil.java
Created January 30, 2011 14:40
A simple util to help convert an InputStream into a String. Useful for parsing JSON files from the asset folder. Based on an example at http://thedevelopersinfo.com/2009/11/17/using-assets-in-android/
package com.gamecook.cigarsmuggler.utils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* User: Jesse Freeman
* Date: 1/30/11
* Time: 9:11 AM
@jessefreeman
jessefreeman / StackLayout
Created February 21, 2011 02:17
Simple stack layout to help align children vertically or horizontally.
/*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
@jessefreeman
jessefreeman / LineOfSight.as
Created March 3, 2011 00:55
A quick test to figure out line of sight in 2d array maps.
import flash.geom.Point;
//0 1 2 3 4
var map:Array = [["#","#","#","#","#"],//0
["#"," "," "," ","#"],//1
["#"," "," "," ","#"],//2
["#","#","#","#","#"],//3
["#"," ","#","#","#"]];//4
//0 1 2 3 4
@jessefreeman
jessefreeman / PaperSprite.as
Created April 16, 2011 16:15
Modified Soulwire's PaperSprite (http://bit.ly/fpRXEn) to do animated Flipping by calling flip().
/**
*
* uk.co.soulwire.display.PaperSprite
*
* @version 1.00 | Jan 11, 2011
* @author Justin Windle
*
**/
package uk.co.soulwire.display
{
@jessefreeman
jessefreeman / SkateOrFall.as
Created April 18, 2011 02:23
Quick test for getting the angle from the accelerometer.
package
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.AccelerometerEvent;
import flash.geom.Point;
import flash.sensors.Accelerometer;
import flash.text.TextField;