Skip to content

Instantly share code, notes, and snippets.

@videlais
videlais / gamepad.js
Created February 28, 2014 18:31
Gamepad axis 'moved' function for CocoonJS on the Ouya using a high-precision radial deadzone algorithm
Phaser.Plugin.CocoonJSOuyaGamepad.prototype.moved = function(pad, axisId) {
var movedAmount = 0;
var magitudeLeft = 0;
var magitudeRight = 0;
if (_gamepads[pad]) {
magitudeLeft = Math.sqrt((_gamepads[pad].axes[0] * _gamepads[pad].axes[0]) +
(_gamepads[pad].axes[1] * _gamepads[pad].axes[1]));
magitudeRight = Math.sqrt((_gamepads[pad].axes[2] * _gamepads[pad].axes[2]) +
(_gamepads[pad].axes[3] * _gamepads[pad].axes[3]));
if (axisId === "AXIS_0" && _gamepads[pad].axes[0] <= 1) {
@videlais
videlais / oneLinkCSS.twee
Created March 13, 2014 22:10
Twine: Targeting one link for CSS change
:: Start
Your story will display this passage first. Edit it by double clicking it.
[[Passage]]
:: Passage
[[PassageName]]
More text not affected any changes.
@videlais
videlais / fontHeight.js
Created March 16, 2014 20:01
determineFontHeight from Pixi.js
/* @license
* pixi.js - v1.5.1
* Copyright (c) 2012-2014, Mat Groves
* http://goodboydigital.com/
*
* pixi.js is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license.php
*
* http://stackoverflow.com/users/34441/ellisbben
* great solution to the problem!
@videlais
videlais / determineFontHeightInPixels.js
Created March 16, 2014 20:19
determineFontHeightInPixels -- proposed fix for Pixi.js
/*
* http://stackoverflow.com/posts/13730758/revisions
*
* @method determineFontHeightInPixels
* @param fontStyle {String}
* @private
*/
PIXI.Text.prototype.determineFontHeightInPixels = function(fontStyle)
{
var result = PIXI.Text.heightCache[fontStyle];
@videlais
videlais / deviceEvent.html
Last active August 29, 2015 14:05
Detecting Apache Cordova
<!DOCTYPE html>
<html>
<head>
<title>Device Ready Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
//
@videlais
videlais / detectNodeWebkit.js
Last active August 29, 2015 14:05
Node-Webkit Detection
var isNode = (typeof process !== "undefined" && typeof require !== "undefined");
var isNodeWebkit = false;
//Is this Node.js?
if(isNode) {
//If so, test for Node-Webkit
try {
isNodeWebkit = (typeof require('nw.gui') !== "undefined");
} catch(e) {
isNodeWebkit = false;
@videlais
videlais / Preloader.as
Last active December 25, 2015 11:29
ActionScript 3 Example 1 Code -- Preloader
package
{
/**
* ...
* @author Dan Cox
*/
import org.flixel.system.FlxPreloader;
public class Preloader extends FlxPreloader
@videlais
videlais / PlayState.as
Last active December 25, 2015 11:29
ActionScript 3 Example 1 Code -- PlayState.as
package
{
/**
* ...
* @author Dan Cox
*/
import org.flixel.*;
public class PlayState extends FlxState
@videlais
videlais / ExampleRPG.as
Created October 14, 2013 00:37
ActionScript 3 Example 1 Code -- ExampleRPG
package
{
/**
* ...
* @author Dan Cox
*/
import org.flixel.*;
[SWF(width="640",height="480",backgroundColor="#000000")]
[Frame(factoryClass="Preloader")]
@videlais
videlais / PlayState.as
Last active December 25, 2015 13:39
ActionScript 3 Example 2 PlayState Version 2
package
{
/**
* ...
* @author Dan Cox
*/
import org.flixel.*;
public class PlayState extends FlxState