Skip to content

Instantly share code, notes, and snippets.

@bsparks
bsparks / GameState.js
Created March 4, 2016 23:25
Phaser Boilerplate Tutorial Files
import RainbowText from 'objects/RainbowText';
import Star from 'objects/Star';
import Player from 'objects/Player';
import Level1 from 'objects/Level1';
class GameState extends Phaser.State {
preload() {
this.game.load.image('sky', 'assets/sky.png');
this.game.load.image('ground', 'assets/platform.png');
@bsparks
bsparks / battle.html
Last active June 14, 2016 16:47
one of the first js games i ever made
<html>
<head>
<title>Battle!</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
<script>
//TEMPLATE!
//------------------------------------------------------
//Function:
//Purpose:
//Input:
@bsparks
bsparks / gulpfile.js
Last active June 13, 2016 23:52
experimenting with template literals
let wrapper = `
function tpl(scope) {
var T = function() {
Object.assign(this, scope);
this.get = () => \`
<%=contents%>
\`;
};
@bsparks
bsparks / GameState.js
Created March 4, 2016 15:43
Phaser Tutorial shoved in the es6 boilerplate
import RainbowText from 'objects/RainbowText';
class GameState extends Phaser.State {
preload() {
this.game.load.image('sky', 'assets/sky.png');
this.game.load.image('ground', 'assets/platform.png');
this.game.load.image('star', 'assets/star.png');
this.game.load.spritesheet('dude', 'assets/dude.png', 32, 48);
}
var buggyAndroid = parseInt((/android (\d+)/.exec(window.navigator.userAgent.toLowerCase()) || [])[1], 10) < 4;
if (!history.pushState || buggyAndroid) {
if (window.location.hash) {
if(window.location.pathname !== '/') window.location.replace('/#!' + window.location.hash.substr(2)); //Hash and a path, just keep the hash (redirect)
} else {
window.location.replace('/#!' + window.location.pathname); //No hash, take path
}
}
//And then in app.config:
@bsparks
bsparks / starfield.js
Created April 9, 2013 16:11
ImpactJS Starfield
// starfield.js
ig.module(
'game.starfield'
)
.requires(
'impact.system',
'impact.background-map'
)
.defines(function() {
var colors = ['#fff', '#555', '#f8ceda'];
/*
Pig Latin interpreter
by Ben Buckman, July 20 2012
Rules:
- All words beginning with a consonant have their first letter moved to the end of word followed by 'ay'.
Example: Hello -> Ellohay
- All words beginning with a vowel have their first letter moved to the end moved to the word followed by 'hay'.
Example: Another -> Notherahay

Privacy Policy

What information do we collect?

This application does not collect any personal information.

Internet access is only used to retrieve ads from the web.

Contacting Us

@bsparks
bsparks / ShellCtxMenu.reg
Created February 12, 2013 15:27
windows registry hack to add 'open command prompt here'
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\cmd]
@="Open Command Prompt Here"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\cmd\command]
@="cmd.exe /k pushd %L"
@bsparks
bsparks / linkedList.js
Last active October 16, 2015 21:17
super badass es2015 linked list :)
'use strict';
class Node {
constructor(data) {
this.prev = this.next = null;
this.data = data;
}
}
class List {