Skip to content

Instantly share code, notes, and snippets.

View JesterXL's full-sized avatar
🔊
writing

Jesse Warden JesterXL

🔊
writing
View GitHub Profile
@JesterXL
JesterXL / ExperienceBar.lua
Created November 7, 2011 19:34
Corona Lua RPG Experience Bar via Pathfinder rules
ExperienceBar = {}
function ExperienceBar:new(x, y, targetWidth, targetHeight)
local group = display.newGroup()
group.x = x
group.y = y
local grayBar = display.newRect(0, 0, targetWidth, targetHeight)
group:insert(grayBar)
grayBar:setFillColor(102, 102, 102, 200)
@JesterXL
JesterXL / Box.as
Created November 8, 2011 21:51
Robotlegs Mediator without a view reference
package
{
import flash.display.Graphics;
import flash.display.Sprite;
public class Box extends Sprite
{
public function Box()
{
super();
@JesterXL
JesterXL / console.as
Created February 27, 2012 17:06
Simple way to show trace statements in Flash and in the browser. Put in root. Go: console.log("Hello World!");
package
{
import flash.external.ExternalInterface;
public class console
{
public function console()
{
}
@JesterXL
JesterXL / VideoMangnifier.as
Created March 23, 2012 18:24
class used to magnify a portion of Strobe video
package com.thirdiris.viaasplayer.components
{
import com.bit101.components.Component;
import com.thirdiris.viaasplayer.events.view.VideoMagnifierEvent;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.BlendMode;
import flash.display.DisplayObjectContainer;
import flash.display.Graphics;
@JesterXL
JesterXL / showProps.lua
Created April 5, 2012 17:30
Reflect/iterate over tables in Lua for debug purposes
--[[
Iterates over tables in Lua to help you identify what they are.
Examples:
showProps(self)
showProps(_G)
]]--
function showProps(o)
@JesterXL
JesterXL / Backbone Error Handling Bad vs. Good
Created August 24, 2012 19:53
Shows how TO and how NOT to do Backbone Error handling.
/*
Bad
- Wrong function signature, no logging, no indication what went wrong, no indication where.
- Developers go WTF
- QA goes WTF
- PM's go WTF
- Firebug/Safari/Chrome tell you "404", but not on which file was asking for it, nor why.
*/
SomeBackboneCollection.prototype.onError = function(resp) {};
@JesterXL
JesterXL / JavaScript Class Module Privacy Example.html
Created December 1, 2012 01:13
Quick explanation of how to do classes + modules + privacy in JavaScript.
<html>
<head>
<title>JavaScript Classes</title>
</head>
<body>
<script src="libs/log4javascript/log4javascript_uncompressed.js"></script>
<script>
@JesterXL
JesterXL / EventDispatcher
Created May 18, 2013 13:36
The mx.utils.EventDispatcher class from ActionScript 2 that used the Decorator pattern to give objects event dispatching and listening capabilities.
//****************************************************************************
//Copyright (C) 2003 Macromedia, Inc. All Rights Reserved.
//The following is Sample Code and is subject to all restrictions on
//such code as contained in the End User License Agreement accompanying
//this product.
//****************************************************************************
/**
* base class for event listening and dispatching
*
@JesterXL
JesterXL / gist:5615023
Created May 20, 2013 19:59
Check memory usage in Corona SDK via Matthew Chapman and John Beebe
local monitorMem = function()
collectgarbage()
print( "MemUsage: " .. collectgarbage("count") )
local textMem = system.getInfo( "textureMemoryUsed" ) / 1000000
print( "TexMem: " .. textMem )
end
Runtime:addEventListener( "enterFrame", monitorMem )
@JesterXL
JesterXL / ropeJointvsDistanceJoint.lua
Last active December 18, 2015 08:09
Show's a Box2D rope joint vs. a distance joint in Corona SDK.
require "physics"
display.setStatusBar( display.HiddenStatusBar )
physics.setDrawMode("hybrid")
physics.start()
physics.setGravity(0, 9.8)
physics.setPositionIterations( 10 )
function getGrapplePoint()
local point = display.newRect(0, 0, 10, 10)
physics.addBody(point,"static", {density = 1, friction = .5, bounce = .1})