Skip to content

Instantly share code, notes, and snippets.

@oscarcs
oscarcs / ishiharatest.hx
Last active August 29, 2015 14:06
Testing color blind functions with HaxeFlixel / OpenFL and nxColor
var ishihara = new FlxSprite(0, 0, "assets/ishihara2.png");
for (x in 0...Std.int(ishihara.width))
{
for (y in 0...Std.int(ishihara.height))
{
var cur = ishihara.framePixels.getPixel(x, y);
var cs = StringTools.hex(cur, 6);
var r = Std.parseInt("0x" + cs.substr(0, 2));
var g = Std.parseInt("0x" + cs.substr(2, 2));
@oscarcs
oscarcs / sort.hx
Last active August 29, 2015 14:07
Depthsorting funtimes
private function getSort()
{
var sortval:Float = 0;
var curAngle = loop(((FlxG.camera.angle-90) * Math.PI) / 180);
var r = Math.sqrt(Math.pow(top.getGraphicMidpoint().x - player.x, 2) + Math.pow(top.getGraphicMidpoint().y - player.y, 2));
var phi = Math.atan2(top.getGraphicMidpoint().x - player.x, top.getGraphicMidpoint().y - player.y) + Math.PI;
var topAngle = curAngle;
var botAngle = loop(curAngle + Math.PI);
@oscarcs
oscarcs / TilemapGrid.hx
Created December 16, 2014 11:55
Manage a grid of FlxTilemaps
package ;
import flixel.FlxG;
import flixel.tile.FlxTilemap;
import flixel.util.FlxPoint;
/**
* Class for management of an array of tilemaps.
*/
class TilemapGrid
@oscarcs
oscarcs / autoTile.hx
Last active April 12, 2021 20:08
Haxe roguelike autotiling example
public static function borderAutoTile(xt:Int, yt:Int, context:ITileable, cur:RLTile, values:BorderValues):Int
{
var val:Int = 1;
var u:RLTile = context.read(xt, yt - 1);
var r:RLTile = context.read(xt + 1, yt);
var d:RLTile = context.read(xt, yt + 1);
var l:RLTile = context.read(xt - 1, yt);
//check whether the surrounding tiles are walls.
@oscarcs
oscarcs / HelloWorld.scala
Last active July 22, 2023 06:11
Scala & LWJGL Hello World
import org.lwjgl._
import org.lwjgl.glfw._
import org.lwjgl.opengl._
import org.lwjgl.glfw.Callbacks._
import org.lwjgl.glfw.GLFW._
import org.lwjgl.opengl.GL11._
import org.lwjgl.system.MemoryUtil._
object Main {
@oscarcs
oscarcs / install-haxe.sh
Last active November 22, 2016 10:34
Haxe install script for Ubuntu
#!/bin/sh
# Adapted from https://gist.github.com/jgranick/8cc40e2e0f277146725f
# Assumes Ubuntu system. Update HAXE_VERSION and NEKO_VERSION with up-to-date releases.
HAXE_VERSION=3.3.0-rc.1
NEKO_VERSION=2.1.0
if [ "$1" = "y" -o "$1" = "-y" ]; then
/**
* Attempts to add a Shape to a NestingShape object. If successful, a
* two-way link is established between the NestingShape and the newly-added
* Shape. Note that this method has package visibility.
* @param shape the shape to be added.
* @throws IllegalArgumentException if an attempt is made to add a Shape
* that will not fit within the bounds of the proposed NestingShape object.
*/
void add(Shape shape) throws IllegalArgumentException {
@oscarcs
oscarcs / userChrome.css
Created January 16, 2019 20:54
Prevent tab scrolling in Firefox with Chrome-style skinny tabs
.tabbrowser-tab {
min-width: initial !important;
}
.tab-content {
overflow: hidden !important;
}
function customJSONStringify(value) {
function writeJSON(value) {
switch (toType(value)) {
case "object":
return writeObject(value);
case "array":
return writeArray(value);
"use strict";
/**
* Create a new CustomDate object.
* @param {Number} year 4-digit year
* @param {Number} month 1-indexed month (1 = January, etc.)
* @param {Number} day Day of the month (1-31)
*/
let CustomDate = function(year, month, day) {
// Set the defaults: