Skip to content

Instantly share code, notes, and snippets.

View PrimaryFeather's full-sized avatar

Daniel Sperl PrimaryFeather

View GitHub Profile
@PrimaryFeather
PrimaryFeather / QuadSectionArc.as
Created November 4, 2022 10:52
Starling's 'QuadSection' extension modified so that it shows just a half-circle.
package starling.extensions
{
import flash.geom.Point;
import starling.display.Mesh;
import starling.rendering.IndexData;
import starling.rendering.VertexData;
import starling.textures.Texture;
public class QuadSectionArc extends Mesh
@PrimaryFeather
PrimaryFeather / CollisionDetectionSample.as
Created February 5, 2021 07:12
Sample (for Starling Framework) showing how to detect collisions between a complex and a simple object.
package starling
{
import flash.geom.Matrix;
import flash.geom.Point;
import starling.display.Canvas;
import starling.display.Sprite;
import starling.events.Touch;
import starling.events.TouchEvent;
import starling.events.TouchPhase;
@PrimaryFeather
PrimaryFeather / flox_dump_players.rb
Created August 1, 2019 12:12
Dumps all Flox players as JSON files to a folder.
#!/usr/bin/env ruby
require 'flox'
require 'fileutils'
GAME_ID = 'xxx'
GAME_KEY = 'yyy'
HERO_KEY = 'zzz'
OUT_FOLDER = 'flox-players'
STEP_SIZE = 50
@PrimaryFeather
PrimaryFeather / HelloTriangleColored.as
Created September 20, 2018 06:51
A very basic Stage3D example.
package stage3d
{
import com.adobe.utils.AGALMiniAssembler;
import flash.display.Sprite;
import flash.display3D.Context3D;
import flash.display3D.Context3DProgramType;
import flash.display3D.Context3DVertexBufferFormat;
import flash.display3D.IndexBuffer3D;
import flash.display3D.Program3D;
@PrimaryFeather
PrimaryFeather / CAFilter.as
Created April 27, 2018 08:45
Chromatic Aberration Filter for Starling
package starling.extensions
{
import starling.filters.FragmentFilter;
import starling.rendering.FilterEffect;
/**
* Chromatic Aberration
* USAGE:
* var filter:CAFilter = new CAFilter();
* filter.angle = 20;
@PrimaryFeather
PrimaryFeather / ZipLoader.as
Last active June 4, 2018 07:24
Makes Starling's AssetManager recognize and unzip zipped assets. Depends on FZip: http://codeazur.com.br/lab/fzip/
package starling.extensions
{
import deng.fzip.FZip;
import deng.fzip.FZipEvent;
import deng.fzip.FZipFile;
import flash.events.Event;
import flash.utils.ByteArray;
import starling.assets.DataLoader;
@PrimaryFeather
PrimaryFeather / minify_json.rb
Last active March 16, 2018 07:30
Small Ruby script that minifies (or un-minifies) JSON files.
#!/usr/bin/env ruby
require 'json'
script_name = File.basename(__FILE__)
prettify = false
if ARGV.count < 1
puts "Minifies JSON files."
puts ""
@PrimaryFeather
PrimaryFeather / CachingDataLoader.as
Last active August 7, 2018 08:29
A custom DataLoader extension that makes the asset manager cache remote files locally.
package starling.extensions
{
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
import flash.utils.ByteArray;
import starling.assets.DataLoader;
@PrimaryFeather
PrimaryFeather / ZipAssetFactory.as
Last active June 11, 2018 12:47
An example of how an AssetFactory for Starling's new AssetManager can process zip files.
package starling.assets
{
import deng.fzip.FZip;
import deng.fzip.FZipEvent;
import deng.fzip.FZipFile;
import flash.events.Event;
import flash.utils.ByteArray;
@PrimaryFeather
PrimaryFeather / QuadSection.as
Last active May 8, 2018 11:10
A Starling Mesh that displays a slice of a quad (just like a pie chart, but rectangular). Useful e.g. for a circular progress indicator.
package starling.extensions
{
import flash.geom.Point;
import starling.display.Mesh;
import starling.rendering.IndexData;
import starling.rendering.VertexData;
import starling.textures.Texture;
public class QuadSection extends Mesh