Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Sperl PrimaryFeather

View GitHub Profile
@PrimaryFeather
PrimaryFeather / CollisionDetectionSample.as
Created Feb 5, 2021
Sample (for Starling Framework) showing how to detect collisions between a complex and a simple object.
View CollisionDetectionSample.as
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 Aug 1, 2019
Dumps all Flox players as JSON files to a folder.
View flox_dump_players.rb
#!/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 Sep 20, 2018
A very basic Stage3D example.
View HelloTriangleColored.as
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 Apr 27, 2018
Chromatic Aberration Filter for Starling
View CAFilter.as
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 Jun 4, 2018
Makes Starling's AssetManager recognize and unzip zipped assets. Depends on FZip: http://codeazur.com.br/lab/fzip/
View ZipLoader.as
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 Mar 16, 2018
Small Ruby script that minifies (or un-minifies) JSON files.
View minify_json.rb
#!/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 Aug 7, 2018
A custom DataLoader extension that makes the asset manager cache remote files locally.
View CachingDataLoader.as
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 Jun 11, 2018
An example of how an AssetFactory for Starling's new AssetManager can process zip files.
View ZipAssetFactory.as
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
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.
View QuadSection.as
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
@PrimaryFeather
PrimaryFeather / GodRayPlane.as
Last active Jan 15, 2021
A Starling DisplayObject that displays animated god-rays / sunbeams within a specific area.
View GodRayPlane.as
package starling.extensions
{
import flash.display.BitmapData;
import starling.animation.IAnimatable;
import starling.display.Quad;
import starling.textures.Texture;
import starling.utils.MathUtil;
/** A quad that efficiently renders a 2D light ray effect on its surface.