Skip to content

Instantly share code, notes, and snippets.

View MattMcFarland's full-sized avatar

Matt McFarland MattMcFarland

  • Software Engineer
  • Dayton, OH
View GitHub Profile
@MattMcFarland
MattMcFarland / InRadius.as
Created March 3, 2011 21:20
Snippet: Function checking if an object is within radius of another.
/**
* 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");
*/
/**
* 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;
/**
* ...
* @author Matt McFarland
*/
internal class ObjectLayerArchitect
{
/**
* Turns loaded data into entities.
* @param map map class to load
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>();
if (checkDomain(["flashgamelicense.com"]))
public function checkDomain (allowed:*):Boolean
{
var url:String = FP.stage.loaderInfo.url;
@MattMcFarland
MattMcFarland / dynamicBtn.as
Created May 11, 2011 17:05
Dynamic Buttons
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;
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 14:30
Dynamic Button without editing Image.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;
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;
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;