Skip to content

Instantly share code, notes, and snippets.

View AtkinsSJ's full-sized avatar
🦡
That's the badger!

Sam Atkins AtkinsSJ

🦡
That's the badger!
View GitHub Profile
@AtkinsSJ
AtkinsSJ / Alternative, for ShaderToy.
Last active August 29, 2015 14:06
Basic shader that makes things dark and blueish. The Vertex shader is just a generic one. The fragment shader gets the lightness of the pixel at the right place on the texture, darkens it, and gives it a blue tint.
float lightDistance = 100.0;
void main(void)
{
vec2 uv = gl_FragCoord.xy / iResolution.xy;
uv.y = iResolution.y - uv.y;
vec4 tex = texture2D(iChannel0, uv);
// How far are we from the mouse?
float mouseDist = distance(gl_FragCoord.xy, iMouse.xy);
@AtkinsSJ
AtkinsSJ / night.fragment.glsl
Created September 18, 2014 15:07
Problematic shader code
#ifdef GL_ES
precision mediump float;
#endif
varying vec4 v_color;
varying vec2 v_texCoords;
uniform sampler2D u_texture;
uniform vec3 u_playerPosition;
uniform float u_playerLightRangeScaled;
@AtkinsSJ
AtkinsSJ / export_icons.bat
Last active August 29, 2015 14:27
Windows Batch File for generating drawable PNGs from SVG files using Inkscape.
setlocal EnableDelayedExpansion
@echo off
set sizes[m]=24
set sizes[h]=36
set sizes[xh]=48
set sizes[xxh]=72
set sizes[xxxh]=96
for %%f in (.\svg\*.svg) do (
Every time a block changes (through physics or user action):
Add the 6 adjacent block coordinates to physicsQueue
In a physics thread, or whatever:
Check physics on each block of physicsQueue
That's it. :P
Bytes 0 to 7 are 'SUPREME!' -> Or, probably, other game name abbreviations
Bytes 8 to 39 are the builder name
Bytes 40 to 71 are the world name
Byte 72 is the number of levels in the world
===== Level Segment =====
2 bytes, for level dimensions?
32 bytes for name
Null-teminated string for song
#!/usr/bin/env python
# import the pygame module, so you can use it
import pygame
from pygame.locals import *
#Main class
class Main:
scale = 1
basewidth = 320
@AtkinsSJ
AtkinsSJ / Emailer.class.php
Created March 25, 2012 16:30
A basic emailing class I wrote a while back, for sending html/plain emails
<?php
/***********************************************************************
* Emailer class
* -------------
* Copyright Samuel Atkins 2011
* -------------
* Simplifies sending of HTML and plain-text emails.
*
* Usage:
* send( $to : Email address to send to
/**
* Generates the css for a grid system and returns it as a string.
*/
function getGridSystemCSS(columns, columnWidth, gutterWidth) {
var totalWidth = columns * (columnWidth + gutterWidth),
fluidGutterWidth = percentageRoundedTo3DP(gutterWidth / totalWidth); // Get a number with up to 3 decimal places
var css =[".grid-wrapper {"
, " max-width: " + totalWidth + "px;"
, " margin-left: -" + fluidGutterWidth + "%;"
@AtkinsSJ
AtkinsSJ / gist:5302045
Created April 3, 2013 15:08
Copy and paste this into your web browser's javascript console and run it, while on http://www.onegameamonth.com/games in order to get a list of entries per month, in reverse order.
var months = []; $('.walloftext').children().each(function(index, el){ if ($(this).hasClass('center')) {months.push(0);} else if ($(this).hasClass('miniga')) { months[months.length-1]++; } }); console.log(months);
@AtkinsSJ
AtkinsSJ / SvgParser.java
Created April 6, 2013 18:57
This is a class I've written to grab data from svg files made in Inkscape. (Saved as Inkscape svg, not plain svg) Create an SvgParser, call fromFile() with a file handle to the svg file, and you'll be able to access layers by what you named then in Inkscape, using getLayer(name), then access paths from the Layer with getPath(id), or points with …
package uk.co.samatkins.racing;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.XmlReader;
import com.badlogic.gdx.utils.XmlReader.Element;