Skip to content

Instantly share code, notes, and snippets.

@ada-lovecraft
ada-lovecraft / gist:8918810
Created February 10, 2014 16:17
json to csv downloadl
class CSVRow
constructor: (bucket) ->
@day = moment(bucket.time).format('L')
@time = moment(bucket.time).format('LT')
@totalAmount = "$#{bucket.totalAmount}"
@averageAmount = "$#{bucket.averageAmount}"
@transactions = bucket.transactions
$scope.generateCSV = ->
$scope.csvArray = []
@ada-lovecraft
ada-lovecraft / gist:9413989
Created March 7, 2014 15:49
Basic Sprite Tween for Phaser 1.1.6
var targetX = sprite.x + 50;
game.add.tween(sprite).to({x: targetX}, 250, Phaser.Easing.Linear.None).start()
@ada-lovecraft
ada-lovecraft / gist:9414111
Last active August 29, 2015 13:57
$modal decorator to close all modals on $rootScope noauth message
torpedoApp.config(function($provide) {
$provide.decorator('$modal', function($delegate,$rootScope) {
var openFn = $delegate.open;
$delegate.open = function() {
console.debug('open!');
var regged = false;
var args = [].slice.call(arguments);
var modalInstance = openFn.apply(null, args);
modalInstance.opened.then(function(status) {
console.debug('open status:', status);
generateCop: function() {
var cop = enemyGroup.getFirstExists(false);
cop.reset(game.world.width-64, 500);
cop.revive();
cop.body.velocity.x = 1000;
copTimer = game.time.now + 1500;
}
enemyGroup = game.add.group();
enemyGroup.enableBody = true;
enemyGroup.physicsBodyType = Phaser.Physics.ARCADE;
enemyGroup.createMultiple(10,'police');
enemyGroup.setAll('outOfBoundsKill', true);
enemyGroup.setAll('body.gravity', 0);
(function() {
'use strict';
function Menu() {}
var map, ground,layer, player, background, jumpButton, copTimer, enemyGroup, playerCollisionGroup, groundCollisionGroup;
Menu.prototype = {
create: function() {
game.physics.startSystem(Phaser.Physics.P2JS);
game.physics.p2.setImpactEvents(true);
game.physics.p2.gravity.y = 500;
(function() {
function Menu() {}
var map,
ground,
layer,
player,
background,
jumpButton,
copTimer,
policeGroup,
@ada-lovecraft
ada-lovecraft / gist:9841545
Created March 28, 2014 19:47
Extend Sprite
'use strict';
var Block = function(x, y, size, color ) {
this.size = size;
this.color = color;
this.bmd = game.add.bitmapData(this.size, this.size);
this.createTexture();
Phaser.Sprite.call(this, game, x, y, this.bmd);
@ada-lovecraft
ada-lovecraft / Pipe.js
Created April 7, 2014 20:41
Pipe Prefabs
'use strict';
var nameCounter = 0;
var Pipe = function(game, x, y, frame) {
Phaser.Sprite.call(this, game, x, y, 'pipe', frame);
this.anchor.setTo(0.5, 0.5);
this.game.physics.arcade.enableBody(this);
this.body.allowGravity = false;
this.body.immovable = true;
this.name = 'pipe-' + nameCounter;
var sprite = game.add.sprite(x, y, 'spriteSheet');
sprite.animations.add('idle', [3]);
var spriteAnimation = sprite.animations.add('jump', [0,1,2,3,2,1]);
spriteAnimation.onComplete.add(animationStopped, this);
sprite.play('jump');
function animationStopped() {
sprite.play('idle')