Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>title</title>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body>
<!-- page content -->
@troygilbert
troygilbert / gist:3286865
Created August 7, 2012 16:16
Rules for Social Games (i.e., How to Be Social, Not Sociopathic)

Don't be antagonistic. Lead with what the player wants, not with what is more viral. For example, when prompting the user to select friends for any kind of request, always suggest friends that are already playing the game. It is least likely that the player is interested in sending requests to non-players.

No direct solicitation. Don't task the user with spending their currency. Instead of tasking them with purchasing a specific item, task them with achieving something that may require them to purchase those specific items. Keep it goal-oriented, let the player find the solution.

Every click should do something interesting. Prefer click-do to click-select-do. The player will only achieve click-zen if each click is meaningful.

Social games need meaningful interaction between players. When I accept someone as a neighobr I'm agreeing to play a game with them, and they are agreeing to play a game with me. I should be able to take actions that cause meaningful changes to my neighbor's game state

@troygilbert
troygilbert / e4xbug.as
Created January 20, 2011 22:16
Weird bug with E4X syntax
var xml:XML = <root><child name="one"/></root>;
var name:String = "one";
var matches:XMLList = xml.child.(@name == name);
trace(matches.length()); // 0
var nameValue:String = name;
matches = xml.child.(@name == nameValue);
trace(matches.length()); // 1
@troygilbert
troygilbert / ClassWithPrivateInjection.as
Created September 23, 2010 04:00
Demonstrate private injection for DI
package
{
import private_injection;
class ClassWithPrivateInjection
{
include "inject.include.as";
private var mySecretWord:String;
@troygilbert
troygilbert / MyCustomControl.as
Created May 12, 2010 04:51
Throws null ref exception
package
{
public class MyCustomControl
{
protected var someDependency:Object;
[Bindable]
public function get someProperty():Object { return null; }
public function set someProperty(value:Object):void
{
@troygilbert
troygilbert / CharacterEquipsItem.as
Created April 29, 2010 20:47
Character Equips Item
/** This base class works for both players and enemies, as far as items are concerned. **/
public class Character
{
/** This is a list of items equiped on the character. **/
public var equipedItems:Array = [ ];
/** Equips an item on the character, unequiping it from its current owner. **/
public function equip(item:Item):void
{
if (item.owner) item.owner.unequip(item); // unequip item from its current owner
@troygilbert
troygilbert / ResourceLibrary.xml
Created April 18, 2010 16:44
ResourceLibrary.mxml
<!-- The root of the XML needs to support namespaces that map to packages. -->
<mb:ResourceLibrary
xmlns:mb="com.mockingbirdgames.document.*"
xmlns:tweaks="com.mockingbirdgames.document.tweaks.*"
xmlns:behaviors="com.playmockingbird.behaviors.*"
>
<!-- We use shorthand for setting the contents of a child element. -->
<!-- Instead of: <mb:SpriteCollection id="sprites"/> -->
<mb:sprites>
@troygilbert
troygilbert / AutoSizedWindow.as
Created April 15, 2010 04:25
AutoSizedWindow
package
{
import flash.display.NativeWindow;
import flash.geom.Point;
import mx.core.ScrollPolicy;
import mx.core.Window;
public class AutoSizedWindow extends Window
{
@troygilbert
troygilbert / InvalidationPattern.as
Created April 8, 2010 04:46
Invalidate Pattern example
package
{
import flash.display.Shape;
import flash.events.Event;
public class InvalidationPattern
{
protected const USE_DEFERRED_VALIDATION:Boolean = true;
protected var tickerShape:Shape;
@troygilbert
troygilbert / MyAppPreloader.as
Created April 3, 2010 04:58
MyAppPreloader.as
package
{
import flash.display.Graphics;
import flash.display.TextField;
public class MyAppPreloader extends Preloader
{
/** Text display of progress. **/
protected var tf:TextField;