Skip to content

Instantly share code, notes, and snippets.

View Sunjammer's full-sized avatar

Andreas Rønning Sunjammer

  • Trondheim, Norway
View GitHub Profile
@Sunjammer
Sunjammer / FColor.swift
Last active January 10, 2016 17:53
Swift color util for cool friends
import UIKit
public class FColor{
public var a:CGFloat = 1.0;
public var r:CGFloat = 1.0;
public var g:CGFloat = 1.0;
public var b:CGFloat = 1.0;
init(r:CGFloat = 1.0, g:CGFloat = 1.0, b:CGFloat = 1.0, a:CGFloat = 1.0){
self.r = r;
@Sunjammer
Sunjammer / destiny.md
Last active August 29, 2015 14:06
Thoughts on Destiny

Destiny is a mysterious game.

It's been a long time since I experienced an arc like this. It's been an intricate rollercoaster. From the moment the game was announced, with its Marathon Infinity callback title, I was genuinely glad for Bungie regaining their freedom. Bungie are a studio I've followed closely ever since playing the Marathon demo on a Mac IIsi (at 25% resolution, interlaced, without floor or ceiling textures no less). The Marathon trilogy and its modding community defined much of my teens, my first encounters with the internet, and my first serious dabblings in game mods. We eagerly awaited Halo only to see it "stolen" by Microsoft, divorcing Bungie from their Mac gaming heritage. After seeing Bungie grind through several Halo games, straining their modest Iain Banks sci-fi fanboy lore far beyond any reasonable limit while simultaneously spending the time constructing a peerless ability to create seamless and immaculately tuned multiplayer games, the prospect of a Bungie "free" from Halo a

@Sunjammer
Sunjammer / BitmapToAscii.hx
Last active March 22, 2021 03:34
Naive bitmap to ascii converter
package;
/**
* Mostly stolen from http://www.codeproject.com/Articles/20435/Using-C-To-Generate-ASCII-Art-From-An-Image
* @author Andreas Rønning
*/
private typedef BMD = {
function getPixel(x:Int, y:Int):Int;
var width(default, never):Int;
var height(default, never):Int;
@Sunjammer
Sunjammer / Music.hx
Last active August 29, 2015 14:11
Very simple Flash/OpenFL music manager for Haxe games
package;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.net.URLRequest;
/**
* A simple Flash/OpenFL music manager with optional crossfading
* @author Andreas Rønning
*/
@Sunjammer
Sunjammer / Difficulty curve
Last active August 29, 2015 14:16
Difficulty curve generation
inline function shape(input:Float, drive:Float):Float{
var k:Float = 2.0 * drive / (1.0 - drive);
return (1.0 + k) * input / (1.0 + k * Math.abs(input));
}
inline function tri(a:Float, x:Float):Float {
x = x / (2.0*Math.PI);
x = x % 1.0;
if( x<0.0 ) x = 1.0+x;
if(x<a) x=x/a; else x=1.0-(x-a)/(1.0-a);
@Sunjammer
Sunjammer / Lissajous
Created March 2, 2015 15:05
Lissajous utils
public class Lissajous {
public static function lissajousKnot(t:Float, a:Int, b:Int, c:Int, ap:Float, bp:Float, cp:Float, out:{x:Float,y:Float,z:Float}) {
t *= 6.28;
out.x = Math.cos(a * t + ap);
out.y = Math.cos(b * t + bp);
out.z = Math.cos(c * t + cp);
}
public static function lissajousCurve(t:Float, a:Int, b:Int, out:{x:Float, y:Float}) {
t *= 6.28;
@Sunjammer
Sunjammer / Shortish.hx
Last active August 29, 2015 14:17
Shitty haxe short lambdas
package;
import haxe.macro.Context;
import haxe.macro.Expr;
import haxe.macro.Expr.Field;
import haxe.macro.Expr.FieldType;
import haxe.macro.Expr.Function;
import haxe.macro.MacroStringTools;
using StringTools;
/**
* ...
package;
import haxe.ds.Vector;
using StringTools;
using Std;
enum Value
{
Literal(v:Int);
Location(v:Int);
@Sunjammer
Sunjammer / a.hx
Created December 10, 2016 03:42
JS code generation bug?
//stack is an inline property performing array access
function popStack():Int
{
var v = memory[STACK_OFFSET + stack - 1];
stack--;
return v;
}
@Sunjammer
Sunjammer / Instruction.hx
Last active December 10, 2016 23:48
VM nonsense for LD
package vm;
enum Instruction
{
LDA(v:Value); //Load value into A
LDX(v:Value); //Load value into X
LDY(v:Value); //Load value into Y
STA(v:Value); //Store A at memory
STX(v:Value); //Store X at memory
STY(v:Value); //Store Y at memory