Skip to content

Instantly share code, notes, and snippets.

Avatar

Matt McFarland MattMcFarland

  • Software Engineer
  • Dayton, OH
View GitHub Profile
@MattMcFarland
MattMcFarland / InRadius.as
Created Mar 3, 2011
Snippet: Function checking if an object is within radius of another.
View InRadius.as
/**
* Check to see if an object is within radius of another.
* @param x1 object1
* @param y1 object1
* @param x2 object2
* @param y2 object2
* @param radius Size of the radius, which is usually
* @return returns true if object2 is within radius of object 1
* @example if (InRadius(player.x,player.y,enemy.x,enemy.y,100)) trace ("enemy within a 100 pixel radius of player");
*/
View gist:951341
/**
* Searches the map for tiles then adds them to the stage
* @param map
* @param l
* @return
*/
private static function scanMapByTileOnLayer(map:Map,l:DataTileLayer):Array
{
var newTiles:Array = new Array();
var tileIndex:int = 0;
View gist:951345
/**
* ...
* @author Matt McFarland
*/
internal class ObjectLayerArchitect
{
/**
* Turns loaded data into entities.
* @param map map class to load
View gist:961260
private static function drawPolygon(map:Map, rect:Rectangle):Vector.<Point>
{
var tileWidth:int = map._tileWidth;
var tileHeight:int = map._tileHeight;
var topRight:Point = tileToPixelCoords(map, new Point(rect.width,0));
var bottomRight:Point = tileToPixelCoords(map, rect.bottomRight);
var bottomLeft:Point = tileToPixelCoords(map, new Point(0,rect.bottom));
var polygon:Vector.<Point> = new Vector.<Point>();
View gist:964617
if (checkDomain(["flashgamelicense.com"]))
public function checkDomain (allowed:*):Boolean
{
var url:String = FP.stage.loaderInfo.url;
View dynamicBtn.as
package
{
import net.flashpunk.Entity;
import net.flashpunk.Sfx;
import net.flashpunk.tweens.misc.ColorTween;
import net.flashpunk.tweens.misc.VarTween;
import net.flashpunk.graphics.Image;
import flash.filters.GlowFilter;
import flash.display.BitmapData;
import flash.geom.Rectangle;
View LevelHandler.as
package campaign.Action
{
import adobe.utils.CustomActions;
import campaign.Action.Objects.Roid;
import campaign.Galaxy.galaxymap;
import com.bit101.components.NumericStepper;
import editor.edUI;
import flash.utils.ByteArray;
import net.flashpunk.Entity;
import flash.events.Event;
@MattMcFarland
MattMcFarland / dynamicBtn.as
Created May 15, 2011
Dynamic Button without editing Image.as
View dynamicBtn.as
package base
{
import net.flashpunk.Entity;
import net.flashpunk.Sfx;
import net.flashpunk.tweens.misc.ColorTween;
import net.flashpunk.tweens.misc.VarTween;
import net.flashpunk.graphics.Image;
import flash.filters.GlowFilter;
import flash.display.BitmapData;
import flash.geom.Rectangle;
View gist:983504
package campaign.Upgrade
{
import adobe.utils.CustomActions;
import campaign.btnTab;
import net.flashpunk.graphics.Image;
import net.flashpunk.graphics.Spritemap;
import net.flashpunk.graphics.Text;
import net.flashpunk.tweens.misc.VarTween;
import net.flashpunk.World;
import net.flashpunk.Entity;
View gist:983514
package campaign
{
import campaign.Galaxy.galaxymap;
import campaign.Tutorial.dummyWindow;
import campaign.Upgrade.upgradeMenu;
import net.flashpunk.Entity;
import net.flashpunk.graphics.Graphiclist;
import net.flashpunk.graphics.Image;
import net.flashpunk.graphics.Spritemap;
import net.flashpunk.FP;