Skip to content

Instantly share code, notes, and snippets.

@ruby0x1
ruby0x1 / hash_fnv1a.h
Last active December 30, 2023 00:40
FNV1a c++11 constexpr compile time hash functions, 32 and 64 bit
#pragma once
#include <stdint.h>
//fnv1a 32 and 64 bit hash functions
// key is the data to hash, len is the size of the data (or how much of it to hash against)
// code license: public domain or equivalent
// post: https://notes.underscorediscovery.com/constexpr-fnv1a/
inline const uint32_t hash_32_fnv1a(const void* key, const uint32_t len) {
@ruby0x1
ruby0x1 / Runner.hx
Last active December 29, 2021 20:44
A simple Haxe class for easily running threads and calling functions on the primary thread.
package;
#if cpp
import cpp.vm.Thread;
import cpp.vm.Deque;
#elseif neko
import neko.vm.Thread;
import neko.vm.Deque;
#end
@ruby0x1
ruby0x1 / hxcpp_cache_example.txt
Last active June 5, 2016 17:57
hxcpp compile cache example on a clean rebuild
$ rm -rf bin/
$ flow run
flow / found custom config at /Users/sven/.flow.config.json
flow / 1.0.0-alpha.2 (node.js v0.12.7)
flow / target is mac ( arch 64 )
flow / haxe version 3.2.1
flow / build - snow.basic 1.0.0 for mac
flow / build - running haxe ...
@ruby0x1
ruby0x1 / AudioMain.hx
Last active November 29, 2015 18:57
AudioMain.hx
import snow.api.Debug.*;
import snow.types.Types;
import snow.modules.opengl.GL;
import snow.systems.audio.AudioSource;
import snow.systems.audio.AudioInstance;
import Oooh;
typedef UserConfig = {}
@ruby0x1
ruby0x1 / gist:dae2c19b4244ea9c4549
Created November 11, 2015 23:53
WebGL drawArrays 64k limit
Chrome Version 46.0.2490.80 (64-bit)
Frame 965 errors:
VM143:9918 ----------------------
VM143:9924 INVALID_OPERATION <= drawArrays(TRIANGLES, 0, 65760)
[GroupMarkerNotSet(crbug.com/242999)!:D0EE0516CE7F0000]GL ERROR :GL_INVALID_OPERATION : glDrawArrays: attempt to access out of range vertices in attribute 1
@ruby0x1
ruby0x1 / Main.hx
Last active April 19, 2016 02:14
Prevent the space key from scrolling the page with luxe
import luxe.Input;
class Main extends luxe.Game {
override function config(config:luxe.AppConfig) {
config.web.prevent_default_keys.push(Key.space);
return config;
@ruby0x1
ruby0x1 / custom_index.html
Last active May 13, 2016 03:04
livereload example
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="icon" href="favicon.png"/>
<meta charset="utf-8">
<style>
#app {
@ruby0x1
ruby0x1 / FPS.hx
Last active July 12, 2017 11:47 — forked from AndreiRudenko/Fps.hx
Simple FPS Text instance, modified from @RudenkoArt as an example for http://luxeengine.com
package;
import luxe.Text;
import luxe.Color;
import luxe.Vector;
import luxe.Log.*;
import luxe.options.TextOptions;
class FPS extends Text {
@ruby0x1
ruby0x1 / PlayerTeam.hx
Created May 13, 2015 21:28
Flag / Team component
package game;
import luxe.Vector;
import luxe.Sprite;
import luxe.Color;
import luxe.Component;
import phoenix.Texture;
class PlayerTeam extends Component {
@ruby0x1
ruby0x1 / Pool_example.hx
Last active August 29, 2015 14:20
luxe.structural.Pool example
//creation
var player_bullets : Pool<Sprite>;
player_bullets = new Pool<Sprite>(20,
function(index,total){
var _sprite = new Sprite({ pos: new Vector(-999,-999), visible:false });
var _projectile = _sprite.add( new Projectile({
bullet_type:'player'
}) );