Skip to content

Instantly share code, notes, and snippets.

View bennage's full-sized avatar
👟
please stay tuned

Christopher Bennage bennage

👟
please stay tuned
View GitHub Profile
@bennage
bennage / ezekiel.cs
Created July 27, 2011 05:15
a console app for Windows that monitors changes to a directory and restarts node.js for me
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
namespace ezekiel
{
class Program
@bennage
bennage / math.rb
Created September 29, 2011 03:57
Adah's First Ruby Script
# adah's first program
puts 'what is the number to divide?'
x=gets.to_i
puts 'what do you want to divide it by?'
y=gets.to_i
puts 'here is the answer.'
puts x/y
r=x%y
if r != 0 then
@bennage
bennage / NormalizeLineEndings.cs
Created March 16, 2012 22:43
quick and dirty for normalizing all the line endings in project (curse you autocrlf!)
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace NormalizeLineEndings
{
internal class Program
{
@bennage
bennage / github.spike.js
Created March 19, 2012 07:24
downloading the contents of a repo
var assert = require('assert');
var https = require('https');
var fs = require('fs');
var repo = '/login/repo-name/';
var output_path = './a/folder';
function https_get(options, success) {
return https.get(options, function(res) {
if (res.statusCode !== 200) {
@bennage
bennage / require.specs.js
Created June 19, 2012 04:37
specs for a _simple_ 'require' function; used for managing dependencies in WinJS app (using Jasmine)
describe('The require function (or service locator)', function () {
beforeEach(function () {
});
it('should exist', function () {
expect(require).toBeDefined();
});
it('should return the Windows object when passed "Windows"', function () {
@bennage
bennage / app.html
Created December 8, 2012 02:15
bootstrapping my game
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>sidera</title>
<link href="/css/default.css" rel="stylesheet" />
<script src="requestAnimationFrameShim.js"></script>
<script src="bootstrap.js"></script>
@bennage
bennage / startScreen.js
Last active December 10, 2015 02:58
basic logic for a start screen (the main menu) of my game
// `input` will be defined elsewhere, it's a means
// for us to capture the state of input from the player
var startScreen = (function(input) {
// the red component of rgb
var hue = 0;
// are we moving toward red or black?
var direction = 1;
var transitioning = false;
@bennage
bennage / mainGameScreen.js
Last active December 14, 2015 11:19
simple implementation of the main game screen, tracking a set of "enemy" units
var mainGameScreen = (function () {
// the set of entities we're updating and rendering
var entities = [];
// how many enemy ships do we want to start with
var numOfEnemyShips = 12;
// intitalize the screen, expected to be called
// once when transitioning to the screen
function start() {
@bennage
bennage / enemy.js
Last active December 14, 2015 12:08
an enemy ship for our simple game that creates and tracks a phantom target
// alias (and pre-compute) the angle of
// a full circle (360°, but in radians)
var fullCircle = Math.PI * 2;
// invoke this function to create an emeny ship entity
// to add to the main game screen
function makeEnemyShip(x, y) {
// position is set based upon the values
// provided to the function
@bennage
bennage / sfx.js
Created June 20, 2013 03:59
simple implementation of pooling audio elements
define(function() {
var pools = {};
var tags = {};
var manifest = {
'laser': ['sfx/laser.wav', 2],
'explosion': ['sfx/explosion.wav', 8]
};
function createTag(src, whenReady) {