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
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;
@AtkinsSJ
AtkinsSJ / AIDriver.java
Created May 16, 2013 20:25
For some reason, the Java code I'm working on crashes, as a class tries to find itself. Line 43 of AIDriver.java defines a RayCastCallback, and this for some reason causes a class loader to search for "uk.co.samatkins.racing.drivers.AIDriver$MoveCalculator$1", which I think is the RayCastCallback itself. Any ideas?
package uk.co.samatkins.racing.drivers;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Fixture;
import com.badlogic.gdx.physics.box2d.RayCastCallback;
import com.badlogic.gdx.physics.box2d.World;
import uk.co.samatkins.racing.Car;
import uk.co.samatkins.racing.Move;
@AtkinsSJ
AtkinsSJ / gist:5611633
Created May 20, 2013 11:04
Things that cause box2d to crash. Most of these are things you shouldn't do in your code anyway, but it'd be better if it gave an error rather than just crash with no explanation. >_<
  • Creating or destroying bodies and fixtures during a callback.
  • Casting a ray where the start and end points are the same position.
  • Creating a fixture with a PolygonShape set as a box with 0 width and height
@AtkinsSJ
AtkinsSJ / 1gam.php
Created May 31, 2013 16:10
Scraper for #1GAM games. Grabs the information from http://www.onegameamonth.com/gameslist and generates a csv file. Because of how the #1GAM site is set-up, this only gets the entries for the current month. Hopefully there will be an official API at some point.
<?php
error_reporting(E_ALL ^ E_NOTICE);
$url = 'http://www.onegameamonth.com/gameslist';
$games = array();
function addGame($gameDiv) {
$game = array();
$ga = $gameDiv->firstChild;