Skip to content

Instantly share code, notes, and snippets.

View loktar00's full-sized avatar
🏠
Working from home

Jason loktar00

🏠
Working from home
View GitHub Profile
@loktar00
loktar00 / index.html
Created September 9, 2012 01:58
Eyes that follow your cursor. He gets mad when you you make him cross eyed! I'm getting in the Halloween spirit a bit early this year.
<div id="hitarea">
<div id="a-1" class="hitbox"></div>
<div id="a-2" class="hitbox"></div>
<div id="a-3" class="hitbox"></div>
<div id="a-4" class="hitbox"></div>
<div id="a-5" class="hitbox"></div>
<div id="b-1" class="hitbox"></div>
<div id="b-2" class="hitbox"></div>
<div id="b-3" class="hitbox"></div>
<div id="b-4" class="hitbox"></div>
@loktar00
loktar00 / index.html
Created September 20, 2012 22:15
Looks like slimey germs :P
<canvas id="canvas"></canvas>
@loktar00
loktar00 / index.html
Created September 23, 2012 02:23
Love playing with these. For more check out http://somethinghitme.com/projects/cell/
<canvas id="canvas"></canvas>
@loktar00
loktar00 / gist:3794579
Created September 27, 2012 15:19
Get dimensions and position of element
function getOffsetRect(elem) {
var box = elem.getBoundingClientRect(),
body = document.body,
docElem = document.documentElement,
scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop,
scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft,
clientTop = docElem.clientTop || body.clientTop || 0,
clientLeft = docElem.clientLeft || body.clientLeft || 0,
top = box.top + scrollTop - clientTop,
left = box.left + scrollLeft - clientLeft,
@loktar00
loktar00 / gist:3837820
Created October 5, 2012 03:03
simple XMLHttpRequest
function post(url, data, callback){
var ajaxRequest = new XMLHttpRequest();
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4 || ajaxRequest.readyState == 200){
callback(ajaxRequest.responseText);
}
}
ajaxRequest.open("POST", url);
ajaxRequest.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
@loktar00
loktar00 / robot.js
Created December 3, 2012 17:47
Grunt
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
this.rotate = 1;
this.dist = 0;
this.lastAngle = 0;
};
Robot.prototype.onIdle = function(ev) {
@loktar00
loktar00 / robot.js
Created December 3, 2012 19:36
Rocky Balboa
var Robot = function(robot) {
this.rotate = 360;
this.dist = 0;
this.lastAngle = 0;
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.turn(this.rotate);
this.lastAngle = this.rotate;
@loktar00
loktar00 / index.html
Created December 30, 2012 21:58
A CodePen by Jason Brown. Messing around with the audio api - Spent way too long messing with this. Happy New year!
<div class="attribution">
<a href="https://soundcloud.com/term-and-conditions-mixes/new-year-dubstep-minimix">New Year Dubstep Minimix By Terms and Conditions</a>
</div><br/>
<canvas id="playCanvas"></canvas>
@loktar00
loktar00 / RainbowBright.js
Created January 3, 2013 17:22
Way overboard on a cool script posted by Rlemon
function r() {
return Math.floor(Math.random() * 255);
}
function lemon() {
var cycle = parseFloat(this.dataset.cycle);
if(isNaN(cycle)){
cycle = ~~(Math.random()*100);
}
@loktar00
loktar00 / gist:4675433
Created January 30, 2013 18:23
game loop
/**
* jGame.update()
*
* Main update loop for the game, updates all objects, and calls the renderer.
**/
update : function(){
var curTime = (new Date()).getTime(),
update = this.update;
this.deltaTime = curTime - this.lastTime;