Skip to content

Instantly share code, notes, and snippets.

View dariusk's full-sized avatar

Darius Kazemi dariusk

View GitHub Profile
@dariusk
dariusk / gist:1019000
Created June 10, 2011 15:02
Explanation of tileCollision in Akihabara
/**
* Checks if the specified object is colliding with tiles in the map in an area defined by the object's colw and colh variables as well as the tolerance and approximation variables that are passed in through data. Only tiles in the map marked as solid are checked against. The alogrithm checks the
* @param {Object} th The object that is being checked against the tilemap.
* @param {Object} map This is the asci map that the tile map is generated from.
* @param {Object} tilemap This is the array of tile objects that it itterated over checking for collisions.
* @param {Object} defaulttile The default tile to be returned if nothing can be found. Null can be used here.
* @param {Object} data Passes is extra dat to the function. Can be set as null.
* <ul>
* <li>tolerance{Integer}: This is subtracted from the collision space to get the maximum collision area for the object. This defaults to 6.</li>
* <li>approximation{Integer}: This is the amount that the checked values are i
@dariusk
dariusk / charts.js
Created August 3, 2011 17:30
Sampling frame rate with Google Analytics
function drawVisualization() {
// Create and populate the data table.
var data = new google.visualization.DataTable();
var raw_data = [['Firefox', 54.7251732101617,38.5836297788,57.8144329896907],
['Chrome', 53.6122383252818, 52.2536231884058, 55.0701298701299]];
var years = ['Flame', 'Lightning', 'Gatling'];
data.addColumn('string', 'Year');
for (var i = 0; i < raw_data.length; ++i) {
@dariusk
dariusk / gist:1154923
Created August 18, 2011 19:22
Game Maker Script: Find Movement Range
/*
This code is modified from Mnementh's code at http://gmc.yoyogames.com/index.php?showtopic=368996
I did some bug fixes, and I modified it to allow you to pass in a hash of terrain modifier overrides.
So for example, if swamp usually has a cost of 3, but you're a hovercraft, you can pass in {swamp: 1}.
NOTE THAT THIS IS A FUNCTION THAT IS CALLED FROM INSIDE A UNIT WHEN CALCULATING MOVEMENT RANGE
It's important to keep in mind that what this is doing is updating values on each tile.
Every tile has this kind of data in it:
@dariusk
dariusk / canvas2Xscale.js
Created August 29, 2011 14:38
Artifact-free screen scaling for a canvas game, limited to 1X, 2X, 4X
// Adapted from Zachary Johnson's Commander Clone 0.2 screen scaling example http://www.zachstronaut.com/projects/commander-clone/0.2/game.html
// Modified to strictly choose 1X or 2X or 4X scaling as appopriate, so we don't end up with screwed up scaling artifacts.
// NOTE: uses jQuery for the DOM load event
$(function () {
fullScreenify();
window.addEventListener('resize', fullScreenify, false);
function fullScreenify() {
@dariusk
dariusk / bort.html
Created January 18, 2012 13:58
BoRT Embedding
<iframe src="http://www.tinysubversions.com/bort.html?month=January12" frameborder="0" width="600" height="20"></iframe>
@dariusk
dariusk / gist:1676917
Created January 25, 2012 15:56 — forked from saikat/gist:1084146
Stripe sample checkout form
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Stripe Sample Form</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquery.validate.min.js"></script>
<script type="text/javascript" src="https://js.stripe.com/v1/"></script>
<script type="text/javascript">
@dariusk
dariusk / gist:1719215
Created February 1, 2012 20:47
output of "nanoc compile"
SyntaxError: compile error
./Rules:9: odd number list for Hash
h[k] = { title: '', items: [] }
^
./Rules:9: syntax error, unexpected ':', expecting '}'
h[k] = { title: '', items: [] }
^
./Rules:94: odd number list for Hash
item[:author_info] = { title: item[:author], slug: author_slug }
^
@dariusk
dariusk / gist:1941142
Created February 29, 2012 14:14
Me going on about FSM's in #bbg
<Hotroot> Is anyone on?
<Hotroot> More specifically anyone who knows anything about writing bbg "frameworks" for the easy creation of similar games?
<dariusk> what do you mean by that? I've contributed to the Akihabara framework
<Hotroot> I was thinking about a mystery game where you would travel from room to room in X location, talk to witnesses, present evidence to them (ala Phoenix Wright) and ask them various questions.
<Hotroot> Their testimony could change based on presented evidence, etc.
<Hotroot> Considering how similar all the "levels" in a game like that would be, I think a framework would be the best way to go
* PotHix (~pothix@2804:218:0:2001:a6ba:dbff:fe05:6ef9) has joined #bbg
<Hotroot> It would use lots of OO. Like Janitor = new Witness() and then you assign the different dialog trees he presents, etc.
<dariusk> this may seem counterintuitive, but I would not be worried about the framework for the game itself so much as I'd be worried about building the UI
<Hotroot> The different "levels" woul
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dariusk
dariusk / beast.html
Created April 6, 2012 14:13
Source code produced by ink2canvas for SVG Beast http://buildnewgames.com/taming-the-svg-beast/
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Inkscape Output</title>
</head>
<body>
<canvas id='canvas' width='480' height='320'></canvas>
<script>
var ctx = document.getElementById("canvas").getContext("2d");