Skip to content

Instantly share code, notes, and snippets.

View salmonmoose's full-sized avatar
🫎

Amelia Fletcher salmonmoose

🫎
View GitHub Profile
@salmonmoose
salmonmoose / bresenham3d.py
Created May 21, 2012 00:44
Generate unit locations along a 3D line
def bresenham(startPoint, endPoint):
startPoint = [int(startPoint[0]),int(startPoint[1]),int(startPoint[2])]
endPoint = [int(endPoint[0]),int(endPoint[1]),int(endPoint[2])]
steepXY = (abs(endPoint[1] - startPoint[1]) > abs(endPoint[0] - startPoint[0]))
if(steepXY):
startPoint[0], startPoint[1] = startPoint[1], startPoint[0]
endPoint[0], endPoint[1] = endPoint[1], endPoint[0]
import random
suits = [
'Hearts',
'Diamonds',
'Clubs',
'Spades'
]
values = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King']
@salmonmoose
salmonmoose / gist:3300245
Created August 9, 2012 01:45
Fragment Shader
void fshader(
in float3 l_texcoord0 : TEXCOORD0, //normals
in float4 l_texcoord1 : TEXCOORD1,
in float4 l_color : COLOR,
uniform sampler2D tex_0,
uniform sampler2D tex_1,
uniform sampler2D tex_2,
uniform sampler2D tex_3,
uniform sampler2D tex_4,
@salmonmoose
salmonmoose / gist:4146634
Created November 26, 2012 04:37
Build unique colours for objects automatically
$background_color = substr(md5($unique_id),0,6);
$r = hexdec(substr($background_color,0,2));
$g = hexdec(substr($background_color,2,2));
$b = hexdec(substr($background_color,4,2));
$l = ($r*0.2126)+($g*0.7152)+($b*0.0722);
$text_color = ($l >= 128)? '000000' : 'ffffff';
@salmonmoose
salmonmoose / gist:4439701
Created January 3, 2013 00:28
Current makefile
CC = gcc
CXX = g++
RM = rm -f
LDLIBS = \
-L/usr/X11R6/lib$(LIBSELECT) \
-L../libs/irrlicht-1.8.0/lib/Linux \
-L../libs/accidentalnoise/lib/Linux \
-lIrrlicht \
@salmonmoose
salmonmoose / gist:5946543
Created July 8, 2013 06:09
Block Dropper
dropBlocks: function() {
for(var y = this.mapsize.y -2; y >= 0; y --)
{
for(var x = 0; x < this.mapsize.x; x++)
{
if(this.map[x][y] != null) {
if(this.map[x][y+1] == null && this.map[x][y].pos.y == y * 64 + this.offset.y)
{
this.map[x][y+1] = this.map[x][y];
this.map[x][y] = null;
# Configure colors, if available.
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
c_reset='\[\e[0m\]'
c_user='\[\e[0;32m\]'
c_path='\[\e[1;34m\]'
c_git_clean='\[\e[0;37m\]'
c_git_staged='\[\e[0;32m\]'
c_git_unstaged='\[\e[0;31m\]'
else
c_reset=
@salmonmoose
salmonmoose / rc.lua
Last active January 1, 2016 17:39
AwesomeWM Config
-- default rc.lua for shifty
--
-- Standard awesome library
require("awful")
require("awful.autofocus")
-- Theme handling library
require("beautiful")
-- Notification library
require("naughty")
-- shifty - dynamic tagging library
@salmonmoose
salmonmoose / gist:1c570d99bc6508e6fa73
Created July 2, 2014 07:08
Basic Collectd python plugin for Transmission
import collectd
import random
import transmissionrpc
pending = 0
checking = 0
downloading = 0
seeding = 0
stopped = 0
/*
* OpenSimplex (Simplectic) Noise for 3D in Java
* (Preliminary Release)
*
* KdotJPG
*/
public class OpenSimplexNoise {
private static final double STRETCH_CONSTANT_3D = -1.0 / 6;