Skip to content

Instantly share code, notes, and snippets.

View jessefreeman's full-sized avatar

Jesse Freeman jessefreeman

View GitHub Profile
@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 / layers_to_sprite_sheet.js
Created March 15, 2011 01:15
This is a PS script to make Sprite Sheets out of layers. Modified from http://www.garagegames.com/community/blogs/view/11527
// Put this file in Program Files\Adobe\Photoshop\Presets\Scripts\
// In PhotoShop menu File > Automate > Scripts: layersToSprite.js
// Arrange layers into a sprite sheet.
if (documents.length > 0)
{
// --------------------------
docRef = activeDocument;
@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;
@jessefreeman
jessefreeman / player.js
Created July 10, 2011 13:50
Example of TileBased player movement for ImpactJS game framework.
ig.module(
'game.entities.player'
)
.requires(
'impact.entity'
)
.defines(function() {
EntityPlayer = ig.Entity.extend({
@jessefreeman
jessefreeman / DiceView.as
Created November 6, 2011 02:40
Simple dice class for use with Dungeons And Dice.
/**
* Created by IntelliJ IDEA.
* User: Jesse Freeman
*/
package com.gamecook.dungeonsanddice.views
{
import com.gamecook.dungeonsanddice.utils.ArrayUtil;
import com.gamecook.frogue.sprites.SpriteSheet;
import flash.display.Bitmap;