Skip to content

Instantly share code, notes, and snippets.

data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/javascript");</script>
@d48
d48 / guard-watch.js
Created May 24, 2013 22:58
guard watch command for any css, js, html files within the subdirectory that gets updated
guard 'livereload' do
# watch any of these files in this directory and under
watch(%r{^.+\.(css|js|html)})
end
@d48
d48 / require-params.js
Last active December 17, 2015 20:19
assign loaded dependencies to params in function callback
bls.utils().require( ['/path/to/handlebars.js', '/path/to/template.html'], function( hb, template1) {
// use handlebars via hb var
hb.compile(someTemplateVar, data);
// use template via template1 var
document.getElementById(templateHandle).innerHTML = template1;
} );
@d48
d48 / loadJS.js
Created June 19, 2013 16:59
js loader
BLS.unitTests.loadJS = function(strJS, cb) {
var objHead = document.getElementsByTagName('head')[0]
, oEmbed = document.createElement('script')
;
oEmbed.type = 'text/javascript';
oEmbed.src = strJS;
oEmbed.async = false; // force to load in order
// listener for when file is done loading
@d48
d48 / bash-description-json.bash
Created June 28, 2013 14:55
bash command to output name and description for list of package.json in 2 directories below
for pkg in `find . -d 2 -name package.json`; do cat $pkg | json name description; echo ""; done

The game we're building is a simple side-scrolling racing game. The player's car is static on the screen, only the background is moving. The enemies are planes whom the player must dodge using the up and down arrow keys. If the player hits a plane, he dies. One point is given each time a plane goes off screen without touching the player.

Sprites

Our game is composed of sprites. Each sprite has a position (x, y), velocity (speed) and one image, or more if animated.

Images are loaded from the DOM using their CSS selector (imagesSelector). We use ID selectors (#name) for single images and class selectors (.name) for animated sprites composed of several images.

See the images used in the game.

@d48
d48 / loud.coffee
Last active December 28, 2015 08:49
loudbot.coffee
# Description:
# Display a random tweet from loudbot if someone YELLS in chat
#
# Dependencies:
# "ntwitter" : "https://github.com/sebhildebrandt/ntwitter/tarball/master",
#
# Configuration:
# HUBOT_TWITTER_CONSUMER_KEY
# HUBOT_TWITTER_CONSUMER_SECRET
# HUBOT_TWITTER_ACCESS_TOKEN_KEY
@d48
d48 / DOMUtils.js
Created March 21, 2014 18:23
API for creating DOM elements with properties. Returns DOM element to append to document
var elInputName = DOMUtil.create({
type: 'input'
, subType: 'textField'
, placeholder: 'Type in your name'
, class: 'myModule--input-name'
, event: {
click: function() { console.log('clicked'); }
, hover: function() { console.log('i am hovered'); }
}
});
@d48
d48 / a-createBundles.js
Last active August 29, 2015 14:08
Creating bundles for culture files via Node.js
// get native file system object
var fs = require('fs')
// get a template
, template = fs.readFileSync('./template.txt', 'utf8')
// read files from a directory called '/cultures' for file names, specifically language tag, e.g., 'en-US' or 'fr-FR'
, filesInDir = fs.readdirSync('./cultures/')
// create file handle to output to
, stream = fs.createWriteStream('./bundles.txt')
@d48
d48 / changelog-sample.md
Created February 7, 2017 20:14
sample changelog

Change Log

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

[Unreleased]

Added

  • zh-CN and zh-TW translations from @tianshuo.
  • de translation from @mpbzh.