Skip to content

Instantly share code, notes, and snippets.

View gamedevsam's full-sized avatar

Samuel Batista gamedevsam

View GitHub Profile
@gamedevsam
gamedevsam / Events
Last active December 16, 2015 03:29
A super simple string based event system.
package ;
import flixel.FlxG;
import flixel.util.FlxPool;
import haxe.ds.ObjectMap;
class Events
{
public static function addHandler(object:Dynamic, event:String, handler:Dynamic -> Void, permanent:Bool = false)
{
@gamedevsam
gamedevsam / TomlConfig
Last active December 16, 2015 03:59
TomlConfig.hx - An assistant class to HaxeToml that provides an intuitive and type-safe approach to run-time data loading using Haxe Reflection. This class supports reloading of config files at run-time on cpp targets.
package ;
import haxe.Utf8;
import nme.Assets;
// requires haxetoml: https://github.com/raincole/haxetoml
import haxetoml.TomlParser;
#if cpp
import sys.io.File;
import sys.FileSystem;
#end
package ;
class DeepCopy
{
// http://haxe.org/forum/thread/3395#nabble-td2119917
public static function copy<T>( v:T ) : T
{
if (!Reflect.isObject(v)) // simple type
{
return v;
@gamedevsam
gamedevsam / FlxCollision.hx
Last active January 2, 2016 12:39
FlxCollision optimization
package flixel.util;
import flash.display.BitmapData;
import flash.display.BlendMode;
import flash.geom.ColorTransform;
import flash.geom.Matrix;
import flash.geom.Point;
import flash.geom.Rectangle;
import flixel.FlxCamera;
import flixel.FlxG;
@gamedevsam
gamedevsam / gist:8360381
Last active January 2, 2016 20:59 — forked from anonymous/gist:8359473
Fixing up some weirdness - need testing
mycolor = {0, 0, 0}
CAM_STIFFNESS = 1000.0
CAM_DAMPING = 100.0
CAM_MASS = 5.0
position = {0,0}
speed = {0,0}
target ={0,0}
@gamedevsam
gamedevsam / gist:9750193
Last active August 29, 2015 13:57
Performance optimization for FlxTypedGroup.add()
public function add(Object:T, Unsafe:Bool = false):T
{
if (Object == null)
{
FlxG.log.warn("Cannot add a `null` object to a FlxGroup.");
return null;
}
// Use this when you're certain this group won't have any null or duplicate entries. Use only when maximum performance is needed.
if(Unsafe == true)
@gamedevsam
gamedevsam / gist:9859351
Created March 29, 2014 18:15
Game Developer Blogs
<outline type="rss" text="Sean Hogan Game/Stuff/Devblog" title="Sean Hogan Game/Stuff/Devblog" xmlUrl="http://seagaia.wordpress.com/feed/" htmlUrl="http://seagaia.wordpress.com"/>
<outline type="rss" text="Krautscape Development Blog" title="Krautscape Development Blog" xmlUrl="http://blog.krautscape.net/rss" htmlUrl="http://blog.krautscape.net/"/>
<outline type="rss" text="Make Games" title="Make Games" xmlUrl="http://makegames.tumblr.com/rss" htmlUrl="http://makegames.tumblr.com/"/>
<outline type="rss" text="hermitgames blog" title="hermitgames blog" xmlUrl="http://www.hermitgames.com/feed.xml" htmlUrl="http://www.hermitgames.com/blog.php"/>
<outline type="rss" text="BIG ROBOT" title="BIG ROBOT" xmlUrl="http://www.big-robot.com/feed/" htmlUrl="http://www.big-robot.com"/>
<outline type="rss" text="Matt Tuttle" title="Matt Tuttle" xmlUrl="http://matttuttle.com/feed/" htmlUrl="http://matttuttle.com"/>
<outline type="rss" text="Joost's Dev Blog" title="Joost's Dev Blog" xmlUrl="http://joostdevblog.blogspot.com/
@gamedevsam
gamedevsam / gist:c5427b5c778191c7f7c7
Last active August 29, 2015 14:10
Learn Game Programming

Want to program your own video game?


#####This is what your game will look like when you finish the exercises in the book: alt text

@gamedevsam
gamedevsam / IScriptHandler.hx
Created December 16, 2014 16:18
sams-addons level scripting
package levels.scripting;
/**
* ...
* @author Samuel Batista
*/
interface IScriptHandler
{
/*
@gamedevsam
gamedevsam / Config.hx
Last active September 11, 2016 03:51
Haxe Toml Configs
package ;
import flixel.FlxG;
import flixel.addons.nape.FlxNapeState;
import toml.TomlConfig;
/**
* ...
* @author Sam Batista
*/