Skip to content

Instantly share code, notes, and snippets.

View taybenlor's full-sized avatar

Ben Taylor taybenlor

View GitHub Profile
/**
* A class to parse colour values. Updated by Ben to support colour conversions.
* @author Stoyan Stefanov <[email protected]>
* @author Ben Taylor <[email protected]>
* @link http://www.phpied.com/rgb-color-parser-in-javascript/
* @license Use it if you like it
*/
function Colour(colour_string)
{
this.ok = false;
/**
* A class to parse colour values. Updated by Ben to support colour conversions.
* @author Stoyan Stefanov <[email protected]>
* @author Ben Taylor <[email protected]>
* @link http://www.phpied.com/rgb-color-parser-in-javascript/
* @license Use it if you like it
*/
function Colour(colour_string)
{
this.ok = false;
from pymt import *
from glob import glob
from random import randint
root = MTScatterPlane()
width = int(pymt_config.get('graphics', 'width'))
height = int(pymt_config.get('graphics', 'height'))
for fname in glob('pictures/*.jpg'):
x, y = randint(0,width), randint(0,height)
function getArgs(){
var url = window.location.href;
var qparts = url.split("?");
if (qparts.length == 1){
return {};
}
var query = qparts[1];
var vars = $A(query.split("&"));
var args = {}
<script>
function get_count(data){
$("lol").html(data.count);
}
</script>
<script src="http://urls.api.twitter.com/1/urls/count.json?url=http://google.com&callback=get_count">
@taybenlor
taybenlor / gist:1136267
Created August 10, 2011 06:53
Too Many Pixies Model
class Model
@id: ->
@_id = 1 unless @_id?
@_id += 1
@_id-1
constructor: ->
@id = Model.id()
@attributes = _([])
@taybenlor
taybenlor / gist:1136269
Created August 10, 2011 06:54
Too Many Pixies Enemy Model
class Enemy extends Model
constructor: (tile, type, health) ->
this.attr "health", {default: health}
this.attr "type", {default: type}
this.attr "attacking", {default: false}
this.attr "hit", {default: false}
this.attr "converting", {default: false}
this.attr "tile", {default: tile}
this.attr "destroyed", {default: false}
@taybenlor
taybenlor / gist:1136271
Created August 10, 2011 06:54
Too Many Pixies Enemy Controller
@enemy.listen "health", (newval) =>
@element.addClass('hit')
setTimeout(=> @element.removeClass('hit'), 100)
p = (new_val/@enemy.starting_health)
@element.addClass('damaged') if p < 0.66
@element.addClass('severely') if p < 0.33
@taybenlor
taybenlor / gist:1136274
Created August 10, 2011 06:56
Too Many Pixies Mushroom CSS
/*
* _____
* |_ _|____ __ _____ _ _ ___
* | |/ _ \ V V / -_) '_(_-<
* |_|\___/\_/\_/\___|_| /__/
*
*
*/
/* mushroom middle */
@taybenlor
taybenlor / gist:1136350
Created August 10, 2011 08:11
Too Many Pixies Game Loop
tick = =>
window.ticks = Date.now()
@game.update()
_(tick).defer()
tick()