Skip to content

Instantly share code, notes, and snippets.

View Olical's full-sized avatar
🧙‍♂️
(magic)

Oliver Caldwell Olical

🧙‍♂️
(magic)
View GitHub Profile
@Olical
Olical / Physics.js
Created July 26, 2011 21:21
A pre release of my JavaScript physics engine, I will release it when I am happy
/*
Physics MooTools plugin v1.0.0 pre release
Licenced under GPL v3 (see README.md)
Copyright 2011 - Oliver Caldwell (olivercaldwell.co.uk)
*/
var Physics={World:new Class({Implements:[Events,Options],options:{fps:16,width:500,height:500},initialize:function(e){e&&this.setOptions(e);this.interval=!1;this.clear=function(){var a=null,b=null;this.particles=[];this.positions=[];for(a=0;a<this.options.width;a+=1)for(b=0;b<this.options.height;b+=1)this.positions[a]=[],this.positions[a][b]=!1;return this};this.start=function(){this.interval===!1?(this.interval=setInterval(this.step,1E3/this.options.fps),this.fireEvent("start")):this.fireEvent("alreadyRunning");
return this}.bind(this);this.stop=function(){this.interval!==!1?(clearInterval(this.interval),this.interval=!1,this.fireEvent("stop")):this.fireEvent("notRunning");return this}.bind(this);this.moveParticle=function(a,b){this.positions[a.options.position.x][a.options.position.y]=!1;this.positions[b.x][b.y]=a;a.options.position=b;return this}.bind(this);thi
@Olical
Olical / round.js
Created August 22, 2011 14:05
Very fast rounding in JavaScript
Number.round = function() {
return (this + 0.5) << 0;
};
@Olical
Olical / progress.example.js
Created August 22, 2011 16:06
Progress bar class for MooTools
// Live example - http://jsfiddle.net/Wolfy87/KJtdB/
var bar = new Progress({
element: $('bar'),
progress: 20
});
setTimeout(function() {
bar.setProgress(45);
@Olical
Olical / button.html
Created August 26, 2011 15:58
Sleek CSS3 GitHub download button
<a href='https://github.com/USER/REPOSITORY/archives/master' class='download-button'>
Download
<span>Latest version from GitHub</span>
</a>
@Olical
Olical / Example.js
Created September 11, 2011 10:09
JavaScript Sound class
var mySound = new Sound('http://wolfy87.github.com/NyanTunnel/assets/audio/nyan-cat.ogg', function() {
this.play();
});
mySound.set('volume', 0.1);
var duration = mySound.get('duration');
@Olical
Olical / Example.js
Created September 14, 2011 10:58
Replace MarkDown links with HTML links
function htmlLinks(md) {
return md.replace(/\[(.*?)\]\((.*?)\)/ig, '<a href=\'$2\'>$1</a>');
}
htmlLinks('This is now [linked to Google](http://www.google.co.uk/).'); // This is now <a href='http://www.google.co.uk/'>linked to Google</a>.
@Olical
Olical / Documentation.md
Created September 22, 2011 12:07
Preloader.js - Preload all assets, ideally for a game, using MooTools

About

This class allows you to preload all of your images, sounds, videos, JSON, JavaScript and CSS files with one call. It provides you with progress reports and lets you know when everything is done.

It requires MooTools and MooTools More with the Assets and Request.JSONP boxes ticked. I have attached a copy of the required MooTools More version to this gist.

Example

You can find an example here on jsFiddle.

@Olical
Olical / PersistantObject.js
Created September 27, 2011 21:26
PersistantObject - A class for working with objects and localStorage. From this post: http://olivercaldwell.co.uk/?p=89
/**
* A persistant object class using localStorage
*
* Copyright Oliver Caldwell 2011 (olivercaldwell.co.uk)
* http://olivercaldwell.co.uk/?p=89
*/
function PersistantObject(key) {
// Store the key
this.setKey(key);
@Olical
Olical / LICENSE.txt
Created November 3, 2011 16:04 — forked from 140bytes/LICENSE.txt
PersistantObject - A class for working with objects and localStorage. From this post: http://olivercaldwell.co.uk/?p=89
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@Olical
Olical / grid.less
Created December 9, 2011 21:46
Examples for the more frameworks page - http://wolfy87.github.com/more/
// Load the more framework
@import 'more/more';
// Configure the grid
@grid-width: 1024;
@grid-columns: 12;
@grid-gutter-width: 25;