Section 1
//AdLoader (CPMStar.AdLoader)
package CPMStar {
import flash.display.*;
import flash.net.*;
import flash.system.*;
public class AdLoader {
private static var cpmstarLoader:Loader;
public static function LoadAd(_arg1:int, _arg2:int):DisplayObject{
var _local3:String;
Security.allowDomain("server.cpmstar.com");
_local3 = "http://server.cpmstar.com/adviewas3.swf";
cpmstarLoader = new Loader();
cpmstarLoader.load(new URLRequest(((((_local3 + "?poolid=") + _arg1) + "&subpoolid=") + _arg2)));
return (cpmstarLoader);
}
}
}//package CPMStar
Section 2
//everythingHolder_5 (dropple_notdoppler_fla.everythingHolder_5)
package dropple_notdoppler_fla {
import flash.display.*;
public dynamic class everythingHolder_5 extends MovieClip {
public function everythingHolder_5(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package dropple_notdoppler_fla
Section 3
//introFlash_43 (dropple_notdoppler_fla.introFlash_43)
package dropple_notdoppler_fla {
import flash.display.*;
public dynamic class introFlash_43 extends MovieClip {
public function introFlash_43(){
addFrameScript(5, frame6);
}
function frame6(){
stop();
}
}
}//package dropple_notdoppler_fla
Section 4
//MainTimeline (dropple_notdoppler_fla.MainTimeline)
package dropple_notdoppler_fla {
import flash.geom.*;
import flash.display.*;
import flash.events.*;
import mochi.*;
import CPMStar.*;
import flash.text.*;
import flash.media.*;
import flash.net.*;
import flash.utils.*;
import flash.system.*;
import flash.ui.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.printing.*;
import flash.xml.*;
public dynamic class MainTimeline extends MovieClip {
public const SPONSORURL:URLRequest;
public var loaderBar:LoaderBar;
public var ad:DisplayObject;
public var readyToContinue:Boolean;
public var sponsorLoaderLink:SponsorLoaderLink;
public var playDroppleButton:SimpleButton;
public var adBox:CPMStarAdBox;
public var isKongregate:Boolean;
public var droppleGame:DroppleGame;
public var CPMStarSubPoolID:int;
public var CPMStarPoolID:int;
public var adTimer:Timer;
public var domName;
public function MainTimeline(){
SPONSORURL = new URLRequest("http://www.notdoppler.com");
super();
addFrameScript(0, frame1, 2, frame3);
}
public function loading(_arg1:Event){
var _local2:*;
var _local3:*;
var _local4:*;
_local2 = stage.loaderInfo.bytesTotal;
_local3 = stage.loaderInfo.bytesLoaded;
_local4 = Math.round(((_local3 * 100) / _local2));
if (adTimer.currentCount < _local4){
loaderBar.gotoAndStop(adTimer.currentCount);
} else {
loaderBar.gotoAndStop(_local4);
};
if ((((_local3 >= _local2)) && (readyToContinue))){
adBox.sponsorLinkInAd.visible = false;
loaderBar.visible = false;
removeEventListener(Event.ENTER_FRAME, loading);
adTimer.stop();
if (!isKongregate){
playDroppleButton.x = 112;
playDroppleButton.y = 402;
addChild(playDroppleButton);
playDroppleButton.addEventListener(MouseEvent.CLICK, playButtonClicked);
} else {
continueGame();
};
};
}
public function continueGame(){
sponsorLoaderLink.removeEventListener(MouseEvent.CLICK, sponsorLoaderLinkClicked);
adBox.sponsorLinkInAd.removeEventListener(MouseEvent.CLICK, sponsorLoaderLinkClicked);
removeChild(adBox);
play();
}
function frame3(){
stop();
droppleGame = new DroppleGame();
addChild(droppleGame);
droppleGame.showSponsorIntro();
}
function frame1(){
stop();
MochiServices.connect("6131e28443f417fe", root);
MochiBot.track(this, "19190dc2");
domName = loaderInfo.loaderURL.toUpperCase();
isKongregate = true;
if (domName.indexOf("KONGREGATE.COM") == -1){
isKongregate = false;
};
adTimer = new Timer(25, 100);
readyToContinue = false;
playDroppleButton = new PlayDroppleButton();
if (isKongregate){
adBox.visible = false;
readyToContinue = true;
};
sponsorLoaderLink.addEventListener(MouseEvent.CLICK, sponsorLoaderLinkClicked);
adTimer.addEventListener(TimerEvent.TIMER_COMPLETE, timerDone);
adTimer.start();
CPMStarPoolID = 1377;
CPMStarSubPoolID = 101;
if (!isKongregate){
ad = AdLoader.LoadAd(CPMStarPoolID, CPMStarSubPoolID);
ad.opaqueBackground = 0;
adBox.addChild(ad);
};
adBox.sponsorLinkInAd.addEventListener(MouseEvent.CLICK, sponsorLoaderLinkClicked);
addEventListener(Event.ENTER_FRAME, loading);
}
public function timerDone(_arg1:TimerEvent){
readyToContinue = true;
}
public function playButtonClicked(_arg1:MouseEvent){
playDroppleButton.removeEventListener(MouseEvent.CLICK, playButtonClicked);
removeChild(playDroppleButton);
continueGame();
}
public function sponsorLoaderLinkClicked(_arg1:MouseEvent){
navigateToURL(SPONSORURL, "_blank");
}
}
}//package dropple_notdoppler_fla
Section 5
//MochiScores (mochi.MochiScores)
package mochi {
import flash.display.*;
import flash.text.*;
public class MochiScores {
private static var boardID:String;
public static var onErrorHandler:Object;
public static var onCloseHandler:Object;
public static function showLeaderboard(_arg1:Object=null):void{
var options = _arg1;
if (options != null){
if (options.clip != null){
if ((options.clip is Sprite)){
MochiServices.setContainer(options.clip);
};
delete options.clip;
} else {
MochiServices.setContainer();
};
MochiServices.stayOnTop();
if (options.name != null){
if ((options.name is TextField)){
if (options.name.text.length > 0){
options.name = options.name.text;
};
};
};
if (options.score != null){
if ((options.score is TextField)){
if (options.score.text.length > 0){
options.score = options.score.text;
};
};
};
if (options.onDisplay != null){
options.onDisplay();
} else {
if (MochiServices.clip != null){
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
};
} else {
options = {};
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.stop();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onDisplay.");
};
};
if (options.onClose != null){
onCloseHandler = options.onClose;
} else {
onCloseHandler = function ():void{
if ((MochiServices.clip is MovieClip)){
MochiServices.clip.play();
} else {
trace("Warning: Container is not a MovieClip, cannot call default onClose.");
};
};
};
if (options.onError != null){
onErrorHandler = options.onError;
} else {
onErrorHandler = null;
};
if (options.boardID == null){
if (MochiScores.boardID != null){
options.boardID = MochiScores.boardID;
};
};
MochiServices.send("scores_showLeaderboard", {options:options}, null, onClose);
}
public static function closeLeaderboard():void{
MochiServices.send("scores_closeLeaderboard");
}
public static function getPlayerInfo(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_getPlayerInfo", null, _arg1, _arg2);
}
public static function requestList(_arg1:Object, _arg2:Object=null):void{
MochiServices.send("scores_requestList", null, _arg1, _arg2);
}
public static function scoresArrayToObjects(_arg1:Object):Object{
var _local2:Object;
var _local3:Number;
var _local4:Number;
var _local5:Object;
var _local6:Object;
var _local7:String;
var _local8:String;
_local2 = {};
for (_local7 in _arg1) {
if (typeof(_arg1[_local7]) == "object"){
if (((!((_arg1[_local7].cols == null))) && (!((_arg1[_local7].rows == null))))){
_local2[_local7] = [];
_local5 = _arg1[_local7];
_local4 = 0;
while (_local4 < _local5.rows.length) {
_local6 = {};
_local3 = 0;
while (_local3 < _local5.cols.length) {
_local6[_local5.cols[_local3]] = _local5.rows[_local4][_local3];
_local3++;
};
_local2[_local7].push(_local6);
_local4++;
};
} else {
_local2[_local7] = {};
for (_local8 in _arg1[_local7]) {
_local2[_local7][_local8] = _arg1[_local7][_local8];
};
};
} else {
_local2[_local7] = _arg1[_local7];
};
};
return (_local2);
}
public static function submit(_arg1:Number, _arg2:String, _arg3:Object=null, _arg4:Object=null):void{
MochiServices.send("scores_submit", {score:_arg1, name:_arg2}, _arg3, _arg4);
}
public static function onClose(_arg1:Object=null):void{
if (_arg1 != null){
if (_arg1.error != null){
if (_arg1.error == true){
if (onErrorHandler != null){
if (_arg1.errorCode == null){
_arg1.errorCode = "IOError";
};
onErrorHandler(_arg1.errorCode);
MochiServices.doClose();
return;
};
};
};
};
onCloseHandler();
MochiServices.doClose();
}
public static function setBoardID(_arg1:String):void{
MochiScores.boardID = _arg1;
MochiServices.send("scores_setBoardID", {boardID:_arg1});
}
}
}//package mochi
Section 6
//MochiServices (mochi.MochiServices)
package mochi {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.utils.*;
import flash.system.*;
public class MochiServices {
private static var _container:Object;
private static var _connected:Boolean = false;
private static var _swfVersion:String;
private static var _sendChannel:LocalConnection;
private static var _rcvChannelName:String;
private static var _gatewayURL:String = "http://www.mochiads.com/static/lib/services/services.swf";
private static var _clip:MovieClip;
private static var _loader:Loader;
private static var _id:String;
private static var _listenChannel:LocalConnection;
private static var _timer:Timer;
private static var _sendChannelName:String;
private static var _startTime:Number;
private static var _connecting:Boolean = false;
public static var onError:Object;
private static var _listenChannelName:String = "__mochiservices";
private static var _rcvChannel:LocalConnection;
public static function isNetworkAvailable():Boolean{
return (!((Security.sandboxType == "localWithFile")));
}
public static function send(_arg1:String, _arg2:Object=null, _arg3:Object=null, _arg4:Object=null):void{
if (_connected){
_sendChannel.send(_sendChannelName, "onReceive", {methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
} else {
if ((((_clip == null)) || (!(_connecting)))){
onError("NotConnected");
handleError(_arg2, _arg3, _arg4);
flush(true);
return;
};
_clip._queue.push({methodName:_arg1, args:_arg2, callbackID:_clip._nextcallbackID});
};
if (_clip != null){
if (((!((_clip._callbacks == null))) && (!((_clip._nextcallbackID == null))))){
_clip._callbacks[_clip._nextcallbackID] = {callbackObject:_arg3, callbackMethod:_arg4};
_clip._nextcallbackID++;
};
};
}
public static function get connected():Boolean{
return (_connected);
}
private static function flush(_arg1:Boolean):void{
var _local2:Object;
var _local3:Object;
if (_clip != null){
if (_clip._queue != null){
while (_clip._queue.length > 0) {
_local2 = _clip._queue.shift();
_local3 = null;
if (_local2 != null){
if (_local2.callbackID != null){
_local3 = _clip._callbacks[_local2.callbackID];
};
delete _clip._callbacks[_local2.callbackID];
if (((_arg1) && (!((_local3 == null))))){
handleError(_local2.args, _local3.callbackObject, _local3.callbackMethod);
};
};
};
};
};
}
private static function init(_arg1:String, _arg2:Object):void{
_id = _arg1;
if (_arg2 != null){
_container = _arg2;
loadCommunicator(_arg1, _container);
};
}
public static function get childClip():Object{
return (_clip);
}
public static function get id():String{
return (_id);
}
public static function stayOnTop():void{
_container.addEventListener(Event.ENTER_FRAME, MochiServices.bringToTop, false, 0, true);
if (_clip != null){
_clip.visible = true;
};
}
public static function getVersion():String{
return ("1.31");
}
public static function disconnect():void{
if (((_connected) || (_connecting))){
if (_clip != null){
if (_clip.parent != null){
if ((_clip.parent is Sprite)){
Sprite(_clip.parent).removeChild(_clip);
_clip = null;
};
};
};
_connecting = (_connected = false);
flush(true);
try {
_listenChannel.close();
_rcvChannel.close();
} catch(error:Error) {
};
};
if (_timer != null){
try {
_timer.stop();
} catch(error:Error) {
};
};
}
public static function allowDomains(_arg1:String):String{
var _local2:String;
Security.allowDomain("*");
Security.allowInsecureDomain("*");
if (_arg1.indexOf("http://") != -1){
_local2 = _arg1.split("/")[2].split(":")[0];
Security.allowDomain(_local2);
Security.allowInsecureDomain(_local2);
};
return (_local2);
}
public static function doClose():void{
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
if (_clip.parent != null){
Sprite(_clip.parent).removeChild(_clip);
};
}
public static function setContainer(_arg1:Object=null, _arg2:Boolean=true):void{
if (_arg1 != null){
if ((_arg1 is Sprite)){
_container = _arg1;
};
};
if (_arg2){
if ((_container is Sprite)){
Sprite(_container).addChild(_clip);
};
};
}
private static function onStatus(_arg1:StatusEvent):void{
switch (_arg1.level){
case "error":
_connected = false;
_listenChannel.connect(_listenChannelName);
break;
};
}
private static function initComChannels():void{
if (!_connected){
_sendChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"handshakeDone"});
_sendChannel.send(_sendChannelName, "onReceive", {methodName:"registerGame", id:_id, clip:_container, version:getVersion()});
_rcvChannel.addEventListener(StatusEvent.STATUS, MochiServices.onStatus);
_clip.onReceive = function (_arg1:Object):void{
var cb:String;
var cblst:Object;
var method:*;
var methodName:String;
var obj:Object;
var pkg = _arg1;
cb = pkg.callbackID;
cblst = this.client._callbacks[cb];
if (!cblst){
return;
};
method = cblst.callbackMethod;
methodName = "";
obj = cblst.callbackObject;
if (((obj) && ((typeof(method) == "string")))){
methodName = method;
if (obj[method] != null){
method = obj[method];
} else {
trace((("Error: Method " + method) + " does not exist."));
};
};
if (method != undefined){
try {
method.apply(obj, pkg.args);
} catch(error:Error) {
trace(((("Error invoking callback method '" + methodName) + "': ") + error.toString()));
};
} else {
if (obj != null){
try {
obj(pkg.args);
} catch(error:Error) {
trace(("Error invoking method on object: " + error.toString()));
};
};
};
delete this.client._callbacks[cb];
};
_clip.onError = function ():void{
MochiServices.onError("IOError");
};
_rcvChannel.connect(_rcvChannelName);
trace("connected!");
_connecting = false;
_connected = true;
_listenChannel.close();
while (_clip._queue.length > 0) {
_sendChannel.send(_sendChannelName, "onReceive", _clip._queue.shift());
};
};
}
private static function listen():void{
_listenChannel = new LocalConnection();
_listenChannel.client = _clip;
_clip.handshake = function (_arg1:Object):void{
MochiServices.comChannelName = _arg1.newChannel;
};
_listenChannel.allowDomain("*", "localhost");
_listenChannel.allowInsecureDomain("*", "localhost");
_listenChannel.connect(_listenChannelName);
trace("Waiting for MochiAds services to connect...");
}
private static function handleError(_arg1:Object, _arg2:Object, _arg3:Object):void{
var args = _arg1;
var callbackObject = _arg2;
var callbackMethod = _arg3;
if (args != null){
if (args.onError != null){
args.onError.apply(null, ["NotConnected"]);
};
};
if (callbackMethod != null){
args = {};
args.error = true;
args.errorCode = "NotConnected";
if (((!((callbackObject == null))) && ((callbackMethod is String)))){
try {
var _local5 = callbackObject;
_local5[callbackMethod](args);
} catch(error:Error) {
};
} else {
if (callbackMethod != null){
try {
callbackMethod.apply(args);
} catch(error:Error) {
};
};
};
};
}
public static function get clip():Object{
return (_container);
}
public static function set comChannelName(_arg1:String):void{
if (_arg1 != null){
if (_arg1.length > 3){
_sendChannelName = (_arg1 + "_fromgame");
_rcvChannelName = _arg1;
initComChannels();
};
};
}
private static function loadCommunicator(_arg1:String, _arg2:Object):MovieClip{
var clipname:String;
var f:Function;
var req:URLRequest;
var id = _arg1;
var clip = _arg2;
clipname = ("_mochiservices_com_" + id);
if (_clip != null){
return (_clip);
};
if (!MochiServices.isNetworkAvailable()){
return (null);
};
MochiServices.allowDomains(_gatewayURL);
_clip = createEmptyMovieClip(clip, clipname, 10336, false);
_loader = new Loader();
_timer = new Timer(1000, 0);
_startTime = getTimer();
_timer.addEventListener(TimerEvent.TIMER, connectWait);
_timer.start();
f = function (_arg1:Object):void{
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, f);
req = new URLRequest(_gatewayURL);
_loader.load(req);
_clip.addChild(_loader);
_clip._mochiservices_com = _loader;
_sendChannel = new LocalConnection();
_clip._queue = [];
_rcvChannel = new LocalConnection();
_rcvChannel.allowDomain("*", "localhost");
_rcvChannel.allowInsecureDomain("*", "localhost");
_rcvChannel.client = _clip;
_clip._nextcallbackID = 0;
_clip._callbacks = {};
listen();
return (_clip);
}
public static function bringToTop(_arg1:Event):void{
var e = _arg1;
if (MochiServices.clip != null){
if (MochiServices.childClip != null){
try {
if (MochiServices.clip.numChildren > 1){
MochiServices.clip.setChildIndex(MochiServices.childClip, (MochiServices.clip.numChildren - 1));
};
} catch(errorObject:Error) {
trace("Warning: Depth sort error.");
_container.removeEventListener(Event.ENTER_FRAME, MochiServices.bringToTop);
};
};
};
}
public static function connect(_arg1:String, _arg2:Object, _arg3:Object=null):void{
var id = _arg1;
var clip = _arg2;
var onError = _arg3;
if ((clip is DisplayObject)){
if (((!(_connected)) && ((_clip == null)))){
trace("MochiServices Connecting...");
_connecting = true;
init(id, clip);
};
} else {
trace("Error, MochiServices requires a Sprite, Movieclip or instance of the stage.");
};
if (onError != null){
MochiServices.onError = onError;
} else {
if (MochiServices.onError == null){
MochiServices.onError = function (_arg1:String):void{
trace(_arg1);
};
};
};
}
public static function createEmptyMovieClip(_arg1:Object, _arg2:String, _arg3:Number, _arg4:Boolean=true):MovieClip{
var mc:MovieClip;
var parent = _arg1;
var name = _arg2;
var depth = _arg3;
var doAdd = _arg4;
mc = new MovieClip();
if (doAdd){
if (((false) && (depth))){
parent.addChildAt(mc, depth);
} else {
parent.addChild(mc);
};
};
try {
parent[name] = mc;
} catch(e:Error) {
throw (new Error("MochiServices requires a clip that is an instance of a dynamic class. If your class extends Sprite or MovieClip, you must make it dynamic."));
};
mc["_name"] = name;
return (mc);
}
public static function connectWait(_arg1:TimerEvent):void{
if ((getTimer() - _startTime) > 10000){
if (!_connected){
_clip._mochiad_ctr_failed = true;
trace("MochiServices could not load.");
MochiServices.disconnect();
MochiServices.onError("IOError");
};
_timer.stop();
};
}
}
}//package mochi
Section 7
//AbstractCollection (org.cove.ape.AbstractCollection)
package org.cove.ape {
import flash.display.*;
import flash.utils.*;
public class AbstractCollection {
private var _sprite:Sprite;
private var _isParented:Boolean;
private var _particles:Array;
private var _constraints:Array;
public function AbstractCollection(){
if (getQualifiedClassName(this) == "org.cove.ape::AbstractCollection"){
throw (new ArgumentError("AbstractCollection can't be instantiated directly"));
};
_isParented = false;
_particles = new Array();
_constraints = new Array();
}
public function getAll():Array{
return (particles.concat(constraints));
}
function checkCollisionsVsCollection(_arg1:AbstractCollection):void{
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:AbstractParticle;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:AbstractParticle;
var _local10:SpringConstraint;
var _local11:SpringConstraint;
var _local12:int;
_local2 = _particles.length;
_local3 = 0;
while (_local3 < _local2) {
_local5 = _particles[_local3];
if ((((_local5 == null)) || (!(_local5.collidable)))){
} else {
_local6 = _arg1.particles.length;
_local7 = 0;
while (_local7 < _local6) {
_local9 = _arg1.particles[_local7];
if (((!((_local9 == null))) && (_local9.collidable))){
CollisionDetector.test(_local5, _local9);
};
_local7++;
};
_local8 = _arg1.constraints.length;
_local7 = 0;
while (_local7 < _local8) {
_local10 = _arg1.constraints[_local7];
if (((((!((_local10 == null))) && (_local10.collidable))) && (!(_local10.isConnectedTo(_local5))))){
_local10.scp.updatePosition();
CollisionDetector.test(_local5, _local10.scp);
};
_local7++;
};
};
_local3++;
};
_local4 = _constraints.length;
_local3 = 0;
while (_local3 < _local4) {
_local11 = _constraints[_local3];
if ((((_local11 == null)) || (!(_local11.collidable)))){
} else {
_local6 = _arg1.particles.length;
_local12 = 0;
while (_local12 < _local6) {
_local9 = _arg1.particles[_local12];
if (((((!((_local9 == null))) && (_local9.collidable))) && (!(_local11.isConnectedTo(_local9))))){
_local11.scp.updatePosition();
CollisionDetector.test(_local9, _local11.scp);
};
_local12++;
};
};
_local3++;
};
}
public function get sprite():Sprite{
if (_sprite != null){
return (_sprite);
};
if (APEngine.container == null){
throw (new Error("The container property of the APEngine class has not been set"));
};
_sprite = new Sprite();
APEngine.container.addChild(_sprite);
return (_sprite);
}
function checkInternalCollisions():void{
var _local1:int;
var _local2:int;
var _local3:AbstractParticle;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:AbstractParticle;
var _local8:SpringConstraint;
_local1 = _particles.length;
_local2 = 0;
while (_local2 < _local1) {
_local3 = _particles[_local2];
if ((((_local3 == null)) || (!(_local3.collidable)))){
} else {
_local4 = (_local2 + 1);
while (_local4 < _local1) {
_local7 = _particles[_local4];
if (((!((_local7 == null))) && (_local7.collidable))){
CollisionDetector.test(_local3, _local7);
};
_local4++;
};
_local5 = _constraints.length;
_local6 = 0;
while (_local6 < _local5) {
_local8 = _constraints[_local6];
if (((((!((_local8 == null))) && (_local8.collidable))) && (!(_local8.isConnectedTo(_local3))))){
_local8.scp.updatePosition();
CollisionDetector.test(_local3, _local8.scp);
};
_local6++;
};
};
_local2++;
};
}
public function addParticle(_arg1:AbstractParticle):void{
particles.push(_arg1);
if (isParented){
_arg1.init();
};
}
public function removeConstraint(_arg1:AbstractConstraint):void{
var _local2:int;
_local2 = constraints.indexOf(_arg1);
if (_local2 == -1){
return;
};
constraints.splice(_local2, 1);
_arg1.cleanup();
}
function get isParented():Boolean{
return (_isParented);
}
public function init():void{
var _local1:int;
_local1 = 0;
while (_local1 < particles.length) {
particles[_local1].init();
_local1++;
};
_local1 = 0;
while (_local1 < constraints.length) {
constraints[_local1].init();
_local1++;
};
}
function satisfyConstraints():void{
var _local1:int;
var _local2:int;
var _local3:AbstractConstraint;
_local1 = _constraints.length;
_local2 = 0;
while (_local2 < _local1) {
_local3 = _constraints[_local2];
_local3.resolve();
_local2++;
};
}
public function paint():void{
var _local1:AbstractParticle;
var _local2:int;
var _local3:int;
var _local4:SpringConstraint;
_local2 = _particles.length;
_local3 = 0;
while (_local3 < _local2) {
_local1 = _particles[_local3];
if (((!(_local1.fixed)) || (_local1.alwaysRepaint))){
_local1.paint();
};
_local3++;
};
_local2 = _constraints.length;
_local3 = 0;
while (_local3 < _local2) {
_local4 = _constraints[_local3];
if (((!(_local4.fixed)) || (_local4.alwaysRepaint))){
_local4.paint();
};
_local3++;
};
}
public function addConstraint(_arg1:AbstractConstraint):void{
constraints.push(_arg1);
if (isParented){
_arg1.init();
};
}
function set isParented(_arg1:Boolean):void{
_isParented = _arg1;
}
public function removeParticle(_arg1:AbstractParticle):void{
var _local2:int;
_local2 = particles.indexOf(_arg1);
if (_local2 == -1){
return;
};
particles.splice(_local2, 1);
_arg1.cleanup();
}
public function cleanup():void{
var _local1:int;
_local1 = 0;
while (_local1 < particles.length) {
particles[_local1].cleanup();
_local1++;
};
_local1 = 0;
while (_local1 < constraints.length) {
constraints[_local1].cleanup();
_local1++;
};
}
public function get particles():Array{
return (_particles);
}
function integrate(_arg1:Number):void{
var _local2:int;
var _local3:int;
var _local4:AbstractParticle;
_local2 = _particles.length;
_local3 = 0;
while (_local3 < _local2) {
_local4 = _particles[_local3];
_local4.update(_arg1);
_local3++;
};
}
public function get constraints():Array{
return (_constraints);
}
}
}//package org.cove.ape
Section 8
//AbstractConstraint (org.cove.ape.AbstractConstraint)
package org.cove.ape {
import flash.utils.*;
public class AbstractConstraint extends AbstractItem {
private var _stiffness:Number;
public function AbstractConstraint(_arg1:Number){
if (getQualifiedClassName(this) == "org.cove.ape::AbstractConstraint"){
throw (new ArgumentError("AbstractConstraint can't be instantiated directly"));
};
this.stiffness = _arg1;
setStyle();
}
public function set stiffness(_arg1:Number):void{
_stiffness = _arg1;
}
public function get stiffness():Number{
return (_stiffness);
}
public function resolve():void{
}
}
}//package org.cove.ape
Section 9
//AbstractItem (org.cove.ape.AbstractItem)
package org.cove.ape {
import flash.display.*;
import flash.events.*;
public class AbstractItem extends EventDispatcher {
private var itemPos1:int;// = 0
private var itemPos2:int;// = 0
var displayObjectOffset:Vector;
public var displayObject:DisplayObject;
var fillColor:uint;
var fillAlpha:Number;
private var _visible:Boolean;
private var _solid:Boolean;
var displayObjectRotation:Number;
var lineColor:uint;
var lineAlpha:Number;
var lineThickness:Number;
private var _sprite:Sprite;
private var _alwaysRepaint:Boolean;
public function AbstractItem(){
itemPos1 = 0;
itemPos2 = 0;
super();
_solid = true;
_visible = true;
_alwaysRepaint = false;
}
public function setFill(_arg1:uint=0xFFFFFF, _arg2:Number=1):void{
fillColor = _arg1;
fillAlpha = _arg2;
}
public function init():void{
}
public function cleanup():void{
var _local1:int;
sprite.graphics.clear();
_local1 = 0;
while (_local1 < sprite.numChildren) {
sprite.removeChildAt(_local1);
_local1++;
};
}
public function get solid():Boolean{
return (_solid);
}
public function set itemPosition2(_arg1:int){
itemPos2 = _arg1;
}
public function set itemPosition1(_arg1:int){
itemPos1 = _arg1;
}
public function get sprite():Sprite{
if (_sprite != null){
return (_sprite);
};
if (APEngine.container == null){
throw (new Error("The container property of the APEngine class has not been set"));
};
_sprite = new Sprite();
APEngine.container.addChild(_sprite);
return (_sprite);
}
public function get itemPosition1(){
return (itemPos1);
}
public function get itemPosition2(){
return (itemPos2);
}
public function set solid(_arg1:Boolean):void{
_solid = _arg1;
}
public function paint():void{
}
public function set visible(_arg1:Boolean):void{
_visible = _arg1;
sprite.visible = _arg1;
}
public function setStyle(_arg1:Number=0, _arg2:uint=0, _arg3:Number=1, _arg4:uint=0xFFFFFF, _arg5:Number=1):void{
setLine(_arg1, _arg2, _arg3);
setFill(_arg4, _arg5);
}
public function get visible():Boolean{
return (_visible);
}
public function setLine(_arg1:Number=0, _arg2:uint=0, _arg3:Number=1):void{
lineThickness = _arg1;
lineColor = _arg2;
lineAlpha = _arg3;
}
final public function set alwaysRepaint(_arg1:Boolean):void{
_alwaysRepaint = _arg1;
}
final public function get alwaysRepaint():Boolean{
return (_alwaysRepaint);
}
}
}//package org.cove.ape
Section 10
//AbstractParticle (org.cove.ape.AbstractParticle)
package org.cove.ape {
import flash.display.*;
import flash.utils.*;
public class AbstractParticle extends AbstractItem {
private var forceList:Array;
var curr:Vector;
var prev:Vector;
private var collision:Collision;
private var _invMass:Number;
private var _friction:Number;
private var firstCollision:Boolean;
private var _multisample:int;
var samp:Vector;
private var _center:Vector;
private var _fixed:Boolean;
private var _collidable:Boolean;
private var _kfr:Number;
var interval:Interval;
private var _mass:Number;
private var temp:Vector;
private var forces:Vector;
public function AbstractParticle(_arg1:Number, _arg2:Number, _arg3:Boolean, _arg4:Number, _arg5:Number, _arg6:Number){
if (getQualifiedClassName(this) == "org.cove.ape::AbstractParticle"){
throw (new ArgumentError("AbstractParticle can't be instantiated directly"));
};
interval = new Interval(0, 0);
curr = new Vector(_arg1, _arg2);
prev = new Vector(_arg1, _arg2);
samp = new Vector();
temp = new Vector();
fixed = _arg3;
forces = new Vector();
forceList = new Array();
collision = new Collision(new Vector(), new Vector());
collidable = true;
firstCollision = false;
this.mass = _arg4;
this.elasticity = _arg5;
this.friction = _arg6;
setStyle();
_center = new Vector();
_multisample = 0;
}
public function get px():Number{
return (curr.x);
}
public function get py():Number{
return (curr.y);
}
public function set py(_arg1:Number):void{
curr.y = _arg1;
prev.y = _arg1;
}
function getComponents(_arg1:Vector):Collision{
var _local2:Vector;
var _local3:Number;
_local2 = velocity;
_local3 = _arg1.dot(_local2);
collision.vn = _arg1.mult(_local3);
collision.vt = _local2.minus(collision.vn);
return (collision);
}
public function set px(_arg1:Number):void{
curr.x = _arg1;
prev.x = _arg1;
}
public function setDisplay(_arg1:DisplayObject, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0):void{
displayObject = _arg1;
displayObjectRotation = _arg4;
displayObjectOffset = new Vector(_arg2, _arg3);
}
public function get multisample():int{
return (_multisample);
}
public function get position():Vector{
return (new Vector(curr.x, curr.y));
}
public function set multisample(_arg1:int):void{
_multisample = _arg1;
}
public function set position(_arg1:Vector):void{
curr.copy(_arg1);
prev.copy(_arg1);
}
public function get center():Vector{
_center.setTo(px, py);
return (_center);
}
function testParticleEvents(_arg1:AbstractParticle):void{
if (hasEventListener(CollisionEvent.COLLIDE)){
dispatchEvent(new CollisionEvent(CollisionEvent.COLLIDE, false, false, _arg1));
};
if (((hasEventListener(CollisionEvent.FIRST_COLLIDE)) && (!(firstCollision)))){
firstCollision = true;
dispatchEvent(new CollisionEvent(CollisionEvent.FIRST_COLLIDE, false, false, _arg1));
};
}
public function set elasticity(_arg1:Number):void{
_kfr = _arg1;
}
public function get fixed():Boolean{
return (_fixed);
}
function get invMass():Number{
return ((fixed) ? 0 : _invMass);
}
public function resetFirstCollision():void{
firstCollision = false;
}
function initDisplay():void{
displayObject.x = displayObjectOffset.x;
displayObject.y = displayObjectOffset.y;
displayObject.rotation = displayObjectRotation;
sprite.addChild(displayObject);
}
private function clearForces():void{
forceList.length = 0;
forces.setTo(0, 0);
}
function resolveCollision(_arg1:Vector, _arg2:Vector, _arg3:Vector, _arg4:Number, _arg5:int, _arg6:AbstractParticle):void{
testParticleEvents(_arg6);
if (((((fixed) || (!(solid)))) || (!(_arg6.solid)))){
return;
};
curr.copy(samp);
curr.plusEquals(_arg1);
velocity = _arg2;
}
public function get elasticity():Number{
return (_kfr);
}
public function set velocity(_arg1:Vector):void{
prev = curr.minus(_arg1);
}
public function set collidable(_arg1:Boolean):void{
_collidable = _arg1;
}
public function update(_arg1:Number):void{
var _local2:Vector;
if (fixed){
return;
};
accumulateForces();
temp.copy(curr);
_local2 = velocity.plus(forces.multEquals(_arg1));
curr.plusEquals(_local2.multEquals(APEngine.damping));
prev.copy(temp);
clearForces();
}
public function addForce(_arg1:IForce):void{
forceList.push(_arg1);
}
public function get velocity():Vector{
return (curr.minus(prev));
}
public function get collidable():Boolean{
return (_collidable);
}
public function set mass(_arg1:Number):void{
if (_arg1 <= 0){
throw (new ArgumentError("mass may not be set <= 0"));
};
_mass = _arg1;
_invMass = (1 / _mass);
}
public function set fixed(_arg1:Boolean):void{
_fixed = _arg1;
}
private function accumulateForces():void{
var _local1:IForce;
var _local2:int;
var _local3:int;
var _local4:Array;
_local2 = forceList.length;
_local3 = 0;
while (_local3 < _local2) {
_local1 = forceList[_local3];
forces.plusEquals(_local1.getValue(_invMass));
_local3++;
};
_local4 = APEngine.forces;
_local2 = _local4.length;
_local3 = 0;
while (_local3 < _local2) {
_local1 = _local4[_local3];
forces.plusEquals(_local1.getValue(_invMass));
_local3++;
};
}
public function get mass():Number{
return (_mass);
}
public function get friction():Number{
return (_friction);
}
public function set friction(_arg1:Number):void{
if ((((_arg1 < 0)) || ((_arg1 > 1)))){
throw (new ArgumentError("Legal friction must be >= 0 and <=1"));
};
_friction = _arg1;
}
}
}//package org.cove.ape
Section 11
//APEngine (org.cove.ape.APEngine)
package org.cove.ape {
import flash.display.*;
public final class APEngine {
private static var _damping:Number;
private static var _container:DisplayObjectContainer;
private static var _constraintCollisionCycles:int;
private static var groups:Array;
static var forces:Array;
private static var _constraintCycles:int;
private static var timeStep:Number;
private static var numGroups:int;
public static function get container():DisplayObjectContainer{
return (_container);
}
public static function get constraintCollisionCycles():int{
return (_constraintCollisionCycles);
}
public static function removeForce(_arg1:IForce):void{
var _local2:int;
_local2 = forces.indexOf(_arg1);
if (_local2 == -1){
return;
};
forces.splice(_local2, 1);
}
public static function set damping(_arg1:Number):void{
_damping = _arg1;
}
public static function step():void{
var _local1:int;
var _local2:int;
integrate();
_local1 = 0;
while (_local1 < _constraintCycles) {
satisfyConstraints();
_local1++;
};
_local2 = 0;
while (_local2 < _constraintCollisionCycles) {
satisfyConstraints();
checkCollisions();
_local2++;
};
}
public static function get constraintCycles():int{
return (_constraintCycles);
}
public static function set constraintCollisionCycles(_arg1:int):void{
_constraintCollisionCycles = _arg1;
}
public static function init(_arg1:Number=0.25):void{
timeStep = (_arg1 * _arg1);
numGroups = 0;
groups = new Array();
forces = new Array();
_damping = 1;
_constraintCycles = 0;
_constraintCollisionCycles = 1;
}
public static function addForce(_arg1:IForce):void{
forces.push(_arg1);
}
public static function get damping():Number{
return (_damping);
}
public static function set constraintCycles(_arg1:int):void{
_constraintCycles = _arg1;
}
public static function addGroup(_arg1:Group):void{
groups.push(_arg1);
_arg1.isParented = true;
numGroups++;
_arg1.init();
}
public static function set container(_arg1:DisplayObjectContainer):void{
_container = _arg1;
}
public static function paint():void{
var _local1:int;
var _local2:Group;
_local1 = 0;
while (_local1 < numGroups) {
_local2 = groups[_local1];
_local2.paint();
_local1++;
};
}
public static function removeGroup(_arg1:Group):void{
var _local2:int;
_local2 = groups.indexOf(_arg1);
if (_local2 == -1){
return;
};
groups.splice(_local2, 1);
_arg1.isParented = false;
numGroups--;
_arg1.cleanup();
}
private static function satisfyConstraints():void{
var _local1:int;
var _local2:Group;
_local1 = 0;
while (_local1 < numGroups) {
_local2 = groups[_local1];
_local2.satisfyConstraints();
_local1++;
};
}
public static function removeAllForce():void{
forces = new Array();
}
private static function checkCollisions():void{
var _local1:int;
var _local2:Group;
_local1 = 0;
while (_local1 < numGroups) {
_local2 = groups[_local1];
_local2.checkCollisions();
_local1++;
};
}
private static function integrate():void{
var _local1:int;
var _local2:Group;
_local1 = 0;
while (_local1 < numGroups) {
_local2 = groups[_local1];
_local2.integrate(timeStep);
_local1++;
};
}
}
}//package org.cove.ape
Section 12
//CircleParticle (org.cove.ape.CircleParticle)
package org.cove.ape {
public class CircleParticle extends AbstractParticle {
private var _radius:Number;
public function CircleParticle(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Boolean=false, _arg5:Number=1, _arg6:Number=0.3, _arg7:Number=0){
super(_arg1, _arg2, _arg4, _arg5, _arg6, _arg7);
_radius = _arg3;
}
function getProjection(_arg1:Vector):Interval{
var _local2:Number;
_local2 = samp.dot(_arg1);
interval.min = (_local2 - _radius);
interval.max = (_local2 + _radius);
return (interval);
}
override public function init():void{
cleanup();
if (displayObject != null){
initDisplay();
} else {
sprite.graphics.clear();
sprite.graphics.lineStyle(lineThickness, lineColor, lineAlpha);
sprite.graphics.beginFill(fillColor, fillAlpha);
sprite.graphics.drawCircle(0, 0, radius);
sprite.graphics.endFill();
};
paint();
}
public function get radius():Number{
return (_radius);
}
function getIntervalY():Interval{
interval.min = (samp.y - _radius);
interval.max = (samp.y + _radius);
return (interval);
}
public function set radius(_arg1:Number):void{
_radius = _arg1;
}
override public function paint():void{
sprite.x = curr.x;
sprite.y = curr.y;
}
function getIntervalX():Interval{
interval.min = (samp.x - _radius);
interval.max = (samp.x + _radius);
return (interval);
}
}
}//package org.cove.ape
Section 13
//Collision (org.cove.ape.Collision)
package org.cove.ape {
import org.cove.ape.*;
final class Collision {
var vn:Vector;
var vt:Vector;
function Collision(_arg1:Vector, _arg2:Vector){
this.vn = _arg1;
this.vt = _arg2;
}
}
}//package org.cove.ape
Section 14
//CollisionDetector (org.cove.ape.CollisionDetector)
package org.cove.ape {
import org.cove.ape.*;
final class CollisionDetector {
private static var collNormal:Vector;
private static var cpa:AbstractParticle;
private static var cpb:AbstractParticle;
private static var collDepth:Number;
private static function testIntervals(_arg1:Interval, _arg2:Interval):Number{
var _local3:Number;
var _local4:Number;
if (_arg1.max < _arg2.min){
return (0);
};
if (_arg2.max < _arg1.min){
return (0);
};
_local3 = (_arg2.max - _arg1.min);
_local4 = (_arg2.min - _arg1.max);
return (((Math.abs(_local3))<Math.abs(_local4)) ? _local3 : _local4);
}
private static function testOBBvsOBB(_arg1:RectangleParticle, _arg2:RectangleParticle):Boolean{
var _local3:int;
var _local4:Vector;
var _local5:Number;
var _local6:Vector;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Boolean;
collDepth = Number.POSITIVE_INFINITY;
_local3 = 0;
while (_local3 < 2) {
_local4 = _arg1.axes[_local3];
_local5 = testIntervals(_arg1.getProjection(_local4), _arg2.getProjection(_local4));
if (_local5 == 0){
return (false);
};
_local6 = _arg2.axes[_local3];
_local7 = testIntervals(_arg1.getProjection(_local6), _arg2.getProjection(_local6));
if (_local7 == 0){
return (false);
};
_local8 = Math.abs(_local5);
_local9 = Math.abs(_local7);
if ((((_local8 < Math.abs(collDepth))) || ((_local9 < Math.abs(collDepth))))){
_local10 = (_local8 < _local9);
collNormal = (_local10) ? _local4 : _local6;
collDepth = (_local10) ? _local5 : _local7;
};
_local3++;
};
cpa = _arg1;
cpb = _arg2;
return (true);
}
private static function testTypes(_arg1:AbstractParticle, _arg2:AbstractParticle):Boolean{
if ((((_arg1 is RectangleParticle)) && ((_arg2 is RectangleParticle)))){
return (testOBBvsOBB((_arg1 as RectangleParticle), (_arg2 as RectangleParticle)));
};
if ((((_arg1 is CircleParticle)) && ((_arg2 is CircleParticle)))){
return (testCirclevsCircle((_arg1 as CircleParticle), (_arg2 as CircleParticle)));
};
if ((((_arg1 is RectangleParticle)) && ((_arg2 is CircleParticle)))){
return (testOBBvsCircle((_arg1 as RectangleParticle), (_arg2 as CircleParticle)));
};
if ((((_arg1 is CircleParticle)) && ((_arg2 is RectangleParticle)))){
return (testOBBvsCircle((_arg2 as RectangleParticle), (_arg1 as CircleParticle)));
};
return (false);
}
private static function sampVsNorm(_arg1:AbstractParticle, _arg2:AbstractParticle):void{
var _local3:Number;
var _local4:Number;
var _local5:int;
if (normVsNorm(_arg1, _arg2)){
return;
};
_local3 = (1 / (_arg1.multisample + 1));
_local4 = _local3;
_local5 = 0;
while (_local5 <= _arg1.multisample) {
_arg1.samp.setTo((_arg1.prev.x + (_local4 * (_arg1.curr.x - _arg1.prev.x))), (_arg1.prev.y + (_local4 * (_arg1.curr.y - _arg1.prev.y))));
if (testTypes(_arg1, _arg2)){
CollisionResolver.resolve(cpa, cpb, collNormal, collDepth);
return;
};
_local4 = (_local4 + _local3);
_local5++;
};
}
private static function testCirclevsCircle(_arg1:CircleParticle, _arg2:CircleParticle):Boolean{
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local3 = testIntervals(_arg1.getIntervalX(), _arg2.getIntervalX());
if (_local3 == 0){
return (false);
};
_local4 = testIntervals(_arg1.getIntervalY(), _arg2.getIntervalY());
if (_local4 == 0){
return (false);
};
collNormal = _arg1.samp.minus(_arg2.samp);
_local5 = collNormal.magnitude();
collDepth = ((_arg1.radius + _arg2.radius) - _local5);
if (collDepth > 0){
collNormal.divEquals(_local5);
cpa = _arg1;
cpb = _arg2;
return (true);
};
return (false);
}
static function test(_arg1:AbstractParticle, _arg2:AbstractParticle):void{
if (((_arg1.fixed) && (_arg2.fixed))){
return;
};
if ((((_arg1.multisample == 0)) && ((_arg2.multisample == 0)))){
normVsNorm(_arg1, _arg2);
} else {
if ((((_arg1.multisample > 0)) && ((_arg2.multisample == 0)))){
sampVsNorm(_arg1, _arg2);
} else {
if ((((_arg2.multisample > 0)) && ((_arg1.multisample == 0)))){
sampVsNorm(_arg2, _arg1);
} else {
if (_arg1.multisample == _arg2.multisample){
sampVsSamp(_arg1, _arg2);
} else {
normVsNorm(_arg1, _arg2);
};
};
};
};
}
private static function testOBBvsCircle(_arg1:RectangleParticle, _arg2:CircleParticle):Boolean{
var _local3:Array;
var _local4:int;
var _local5:Number;
var _local6:Vector;
var _local7:Number;
var _local8:Vector;
var _local9:Number;
collDepth = Number.POSITIVE_INFINITY;
_local3 = new Array(2);
_local4 = 0;
while (_local4 < 2) {
_local6 = _arg1.axes[_local4];
_local7 = testIntervals(_arg1.getProjection(_local6), _arg2.getProjection(_local6));
if (_local7 == 0){
return (false);
};
if (Math.abs(_local7) < Math.abs(collDepth)){
collNormal = _local6;
collDepth = _local7;
};
_local3[_local4] = _local7;
_local4++;
};
_local5 = _arg2.radius;
if ((((Math.abs(_local3[0]) < _local5)) && ((Math.abs(_local3[1]) < _local5)))){
_local8 = closestVertexOnOBB(_arg2.samp, _arg1);
collNormal = _local8.minus(_arg2.samp);
_local9 = collNormal.magnitude();
collDepth = (_local5 - _local9);
if (collDepth > 0){
collNormal.divEquals(_local9);
} else {
return (false);
};
};
cpa = _arg1;
cpb = _arg2;
return (true);
}
private static function closestVertexOnOBB(_arg1:Vector, _arg2:RectangleParticle):Vector{
var _local3:Vector;
var _local4:Vector;
var _local5:int;
var _local6:Number;
_local3 = _arg1.minus(_arg2.samp);
_local4 = new Vector(_arg2.samp.x, _arg2.samp.y);
_local5 = 0;
while (_local5 < 2) {
_local6 = _local3.dot(_arg2.axes[_local5]);
if (_local6 >= 0){
_local6 = _arg2.extents[_local5];
} else {
if (_local6 < 0){
_local6 = -(_arg2.extents[_local5]);
};
};
_local4.plusEquals(_arg2.axes[_local5].mult(_local6));
_local5++;
};
return (_local4);
}
private static function normVsNorm(_arg1:AbstractParticle, _arg2:AbstractParticle):Boolean{
_arg1.samp.copy(_arg1.curr);
_arg2.samp.copy(_arg2.curr);
if (testTypes(_arg1, _arg2)){
CollisionResolver.resolve(cpa, cpb, collNormal, collDepth);
return (true);
};
return (false);
}
private static function sampVsSamp(_arg1:AbstractParticle, _arg2:AbstractParticle):void{
var _local3:Number;
var _local4:Number;
var _local5:int;
if (normVsNorm(_arg1, _arg2)){
return;
};
_local3 = (1 / (_arg1.multisample + 1));
_local4 = _local3;
_local5 = 0;
while (_local5 <= _arg1.multisample) {
_arg1.samp.setTo((_arg1.prev.x + (_local4 * (_arg1.curr.x - _arg1.prev.x))), (_arg1.prev.y + (_local4 * (_arg1.curr.y - _arg1.prev.y))));
_arg2.samp.setTo((_arg2.prev.x + (_local4 * (_arg2.curr.x - _arg2.prev.x))), (_arg2.prev.y + (_local4 * (_arg2.curr.y - _arg2.prev.y))));
if (testTypes(_arg1, _arg2)){
CollisionResolver.resolve(cpa, cpb, collNormal, collDepth);
return;
};
_local4 = (_local4 + _local3);
_local5++;
};
}
}
}//package org.cove.ape
Section 15
//CollisionEvent (org.cove.ape.CollisionEvent)
package org.cove.ape {
import flash.events.*;
public class CollisionEvent extends Event {
private var _collidingItem:AbstractItem;
public static const COLLIDE:String = "collide";
public static const FIRST_COLLIDE:String = "firstCollide";
public function CollisionEvent(_arg1:String, _arg2:Boolean=false, _arg3:Boolean=false, _arg4:AbstractItem=null){
super(_arg1, _arg2, _arg3);
_collidingItem = _arg4;
}
public function get collidingItem():AbstractItem{
var _local1:SpringConstraintParticle;
if ((_collidingItem is SpringConstraintParticle)){
_local1 = (_collidingItem as SpringConstraintParticle);
return (_local1.parent);
};
return (_collidingItem);
}
}
}//package org.cove.ape
Section 16
//CollisionResolver (org.cove.ape.CollisionResolver)
package org.cove.ape {
import org.cove.ape.*;
final class CollisionResolver {
static function resolve(_arg1:AbstractParticle, _arg2:AbstractParticle, _arg3:Vector, _arg4:Number):void{
var _local5:Vector;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Collision;
var _local10:Collision;
var _local11:Vector;
var _local12:Vector;
var _local13:Vector;
var _local14:Vector;
_local5 = _arg3.mult(_arg4);
_local6 = (_arg1.elasticity + _arg2.elasticity);
_local7 = (_arg1.invMass + _arg2.invMass);
_local8 = MathUtil.clamp((1 - (_arg1.friction + _arg2.friction)), 0, 1);
_local9 = _arg1.getComponents(_arg3);
_local10 = _arg2.getComponents(_arg3);
_local11 = _local10.vn.mult(((_local6 + 1) * _arg1.invMass)).plus(_local9.vn.mult((_arg2.invMass - (_local6 * _arg1.invMass)))).divEquals(_local7);
_local12 = _local9.vn.mult(((_local6 + 1) * _arg2.invMass)).plus(_local10.vn.mult((_arg1.invMass - (_local6 * _arg2.invMass)))).divEquals(_local7);
_local9.vt.multEquals(_local8);
_local10.vt.multEquals(_local8);
_local13 = _local5.mult((_arg1.invMass / _local7));
_local14 = _local5.mult((-(_arg2.invMass) / _local7));
_local11.plusEquals(_local9.vt);
_local12.plusEquals(_local10.vt);
_arg1.resolveCollision(_local13, _local11, _arg3, _arg4, -1, _arg2);
_arg2.resolveCollision(_local14, _local12, _arg3, _arg4, 1, _arg1);
}
}
}//package org.cove.ape
Section 17
//Composite (org.cove.ape.Composite)
package org.cove.ape {
public class Composite extends AbstractCollection {
private var delta:Vector;
public function Composite(){
delta = new Vector();
}
private function getRelativeAngle(_arg1:Vector, _arg2:Vector):Number{
delta.setTo((_arg2.x - _arg1.x), (_arg2.y - _arg1.y));
return (Math.atan2(delta.y, delta.x));
}
public function rotateByRadian(_arg1:Number, _arg2:Vector):void{
var _local3:AbstractParticle;
var _local4:Array;
var _local5:int;
var _local6:int;
var _local7:Number;
var _local8:Number;
_local4 = particles;
_local5 = _local4.length;
_local6 = 0;
while (_local6 < _local5) {
_local3 = _local4[_local6];
_local7 = _local3.center.distance(_arg2);
_local8 = (getRelativeAngle(_arg2, _local3.center) + _arg1);
_local3.px = ((Math.cos(_local8) * _local7) + _arg2.x);
_local3.py = ((Math.sin(_local8) * _local7) + _arg2.y);
_local6++;
};
}
public function rotateByAngle(_arg1:Number, _arg2:Vector):void{
var _local3:Number;
_local3 = (_arg1 * MathUtil.PI_OVER_ONE_EIGHTY);
rotateByRadian(_local3, _arg2);
}
public function set fixed(_arg1:Boolean):void{
var _local2:int;
_local2 = 0;
while (_local2 < particles.length) {
particles[_local2].fixed = _arg1;
_local2++;
};
}
public function get fixed():Boolean{
var _local1:int;
_local1 = 0;
while (_local1 < particles.length) {
if (!particles[_local1].fixed){
return (false);
};
_local1++;
};
return (true);
}
}
}//package org.cove.ape
Section 18
//Group (org.cove.ape.Group)
package org.cove.ape {
public class Group extends AbstractCollection {
private var _collideInternal:Boolean;
private var _composites:Array;
private var _collisionList:Array;
public function Group(_arg1:Boolean=false){
_composites = new Array();
_collisionList = new Array();
this.collideInternal = _arg1;
}
function checkCollisions():void{
var _local1:int;
var _local2:int;
var _local3:Group;
if (collideInternal){
checkCollisionGroupInternal();
};
_local1 = collisionList.length;
_local2 = 0;
while (_local2 < _local1) {
_local3 = collisionList[_local2];
if (_local3 == null){
} else {
checkCollisionVsGroup(_local3);
};
_local2++;
};
}
public function get composites():Array{
return (_composites);
}
override public function init():void{
var _local1:int;
super.init();
_local1 = 0;
while (_local1 < composites.length) {
composites[_local1].init();
_local1++;
};
}
public function removeCollidable(_arg1:Group):void{
var _local2:int;
_local2 = collisionList.indexOf(_arg1);
if (_local2 == -1){
return;
};
collisionList.splice(_local2, 1);
}
private function checkCollisionVsGroup(_arg1:Group):void{
var _local2:Composite;
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:Composite;
var _local7:int;
checkCollisionsVsCollection(_arg1);
_local3 = _composites.length;
_local4 = _arg1.composites.length;
_local5 = 0;
while (_local5 < _local3) {
_local6 = _composites[_local5];
if (_local6 == null){
} else {
_local6.checkCollisionsVsCollection(_arg1);
_local7 = 0;
while (_local7 < _local4) {
_local2 = _arg1.composites[_local7];
if (_local2 == null){
} else {
_local6.checkCollisionsVsCollection(_local2);
};
_local7++;
};
};
_local5++;
};
_local7 = 0;
while (_local7 < _local4) {
_local2 = _arg1.composites[_local7];
if (_local2 == null){
} else {
checkCollisionsVsCollection(_local2);
};
_local7++;
};
}
override function satisfyConstraints():void{
var _local1:int;
var _local2:int;
var _local3:Composite;
super.satisfyConstraints();
_local1 = _composites.length;
_local2 = 0;
while (_local2 < _local1) {
_local3 = _composites[_local2];
_local3.satisfyConstraints();
_local2++;
};
}
public function get collideInternal():Boolean{
return (_collideInternal);
}
public function addCollidableList(_arg1:Array):void{
var _local2:int;
var _local3:Group;
_local2 = 0;
while (_local2 < _arg1.length) {
_local3 = _arg1[_local2];
collisionList.push(_local3);
_local2++;
};
}
public function removeComposite(_arg1:Composite):void{
var _local2:int;
_local2 = composites.indexOf(_arg1);
if (_local2 == -1){
return;
};
composites.splice(_local2, 1);
_arg1.isParented = false;
_arg1.cleanup();
}
override public function cleanup():void{
var _local1:int;
super.cleanup();
_local1 = 0;
while (_local1 < composites.length) {
composites[_local1].cleanup();
_local1++;
};
}
override public function paint():void{
var _local1:int;
var _local2:int;
var _local3:Composite;
super.paint();
_local1 = _composites.length;
_local2 = 0;
while (_local2 < _local1) {
_local3 = _composites[_local2];
_local3.paint();
_local2++;
};
}
public function addCollidable(_arg1:Group):void{
collisionList.push(_arg1);
}
override public function getAll():Array{
return (particles.concat(constraints).concat(composites));
}
public function get collisionList():Array{
return (_collisionList);
}
override function integrate(_arg1:Number):void{
var _local2:int;
var _local3:int;
var _local4:Composite;
super.integrate(_arg1);
_local2 = _composites.length;
_local3 = 0;
while (_local3 < _local2) {
_local4 = _composites[_local3];
_local4.integrate(_arg1);
_local3++;
};
}
public function addComposite(_arg1:Composite):void{
composites.push(_arg1);
_arg1.isParented = true;
if (isParented){
_arg1.init();
};
}
private function checkCollisionGroupInternal():void{
var _local1:int;
var _local2:int;
var _local3:Composite;
var _local4:int;
var _local5:Composite;
checkInternalCollisions();
_local1 = _composites.length;
_local2 = 0;
while (_local2 < _local1) {
_local3 = _composites[_local2];
if (_local3 == null){
} else {
_local3.checkCollisionsVsCollection(this);
_local4 = (_local2 + 1);
while (_local4 < _local1) {
_local5 = _composites[_local4];
if (_local5 != null){
_local3.checkCollisionsVsCollection(_local5);
};
_local4++;
};
};
_local2++;
};
}
public function set collideInternal(_arg1:Boolean):void{
_collideInternal = _arg1;
}
}
}//package org.cove.ape
Section 19
//IForce (org.cove.ape.IForce)
package org.cove.ape {
public interface IForce {
function getValue(_arg1:Number):Vector;
}
}//package org.cove.ape
Section 20
//Interval (org.cove.ape.Interval)
package org.cove.ape {
final class Interval {
var min:Number;
var max:Number;
function Interval(_arg1:Number, _arg2:Number){
this.min = _arg1;
this.max = _arg2;
}
function toString():String{
return (((min + " : ") + max));
}
}
}//package org.cove.ape
Section 21
//MathUtil (org.cove.ape.MathUtil)
package org.cove.ape {
final class MathUtil {
static var ONE_EIGHTY_OVER_PI:Number = 57.2957795130823;
static var PI_OVER_ONE_EIGHTY:Number = 0.0174532925199433;
static function clamp(_arg1:Number, _arg2:Number, _arg3:Number):Number{
if (_arg1 < _arg2){
return (_arg2);
};
if (_arg1 > _arg3){
return (_arg3);
};
return (_arg1);
}
static function sign(_arg1:Number):int{
if (_arg1 < 0){
return (-1);
};
return (1);
}
}
}//package org.cove.ape
Section 22
//RectangleParticle (org.cove.ape.RectangleParticle)
package org.cove.ape {
public class RectangleParticle extends AbstractParticle {
private var _axes:Array;
private var _extents:Array;
private var _radian:Number;
public function RectangleParticle(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0, _arg6:Boolean=false, _arg7:Number=1, _arg8:Number=0.3, _arg9:Number=0){
super(_arg1, _arg2, _arg6, _arg7, _arg8, _arg9);
_extents = new Array((_arg3 / 2), (_arg4 / 2));
_axes = new Array(new Vector(0, 0), new Vector(0, 0));
radian = _arg5;
}
override public function init():void{
var _local1:Number;
var _local2:Number;
cleanup();
if (displayObject != null){
initDisplay();
} else {
_local1 = (extents[0] * 2);
_local2 = (extents[1] * 2);
sprite.graphics.clear();
sprite.graphics.lineStyle(lineThickness, lineColor, lineAlpha);
sprite.graphics.beginFill(fillColor, fillAlpha);
sprite.graphics.drawRect((-(_local1) / 2), (-(_local2) / 2), _local1, _local2);
sprite.graphics.endFill();
};
paint();
}
public function get radian():Number{
return (_radian);
}
function get axes():Array{
return (_axes);
}
public function get height():Number{
return ((_extents[1] * 2));
}
function getProjection(_arg1:Vector):Interval{
var _local2:Number;
var _local3:Number;
_local2 = ((extents[0] * Math.abs(_arg1.dot(axes[0]))) + (extents[1] * Math.abs(_arg1.dot(axes[1]))));
_local3 = samp.dot(_arg1);
interval.min = (_local3 - _local2);
interval.max = (_local3 + _local2);
return (interval);
}
public function set radian(_arg1:Number):void{
_radian = _arg1;
setAxes(_arg1);
}
public function set height(_arg1:Number):void{
_extents[1] = (_arg1 / 2);
}
override public function paint():void{
sprite.x = curr.x;
sprite.y = curr.y;
sprite.rotation = angle;
}
function get extents():Array{
return (_extents);
}
public function set width(_arg1:Number):void{
_extents[0] = (_arg1 / 2);
}
private function setAxes(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
_local2 = Math.sin(_arg1);
_local3 = Math.cos(_arg1);
axes[0].x = _local3;
axes[0].y = _local2;
axes[1].x = -(_local2);
axes[1].y = _local3;
}
public function set angle(_arg1:Number):void{
radian = (_arg1 * MathUtil.PI_OVER_ONE_EIGHTY);
}
public function get width():Number{
return ((_extents[0] * 2));
}
public function get angle():Number{
return ((radian * MathUtil.ONE_EIGHTY_OVER_PI));
}
}
}//package org.cove.ape
Section 23
//SpringConstraint (org.cove.ape.SpringConstraint)
package org.cove.ape {
import flash.display.*;
public class SpringConstraint extends AbstractConstraint {
private var _collidable:Boolean;
private var p1:AbstractParticle;
private var p2:AbstractParticle;
private var _scp:SpringConstraintParticle;
private var _restLength:Number;
public function SpringConstraint(_arg1:AbstractParticle, _arg2:AbstractParticle, _arg3:Number=0.5, _arg4:Boolean=false, _arg5:Number=1, _arg6:Number=1, _arg7:Boolean=false){
super(_arg3);
this.p1 = _arg1;
this.p2 = _arg2;
checkParticlesLocation();
_restLength = currLength;
setCollidable(_arg4, _arg5, _arg6, _arg7);
}
public function get fixed():Boolean{
return (((p1.fixed) && (p2.fixed)));
}
public function set rectScale(_arg1:Number):void{
if (scp == null){
return;
};
scp.rectScale = _arg1;
}
override public function init():void{
cleanup();
if (collidable){
scp.init();
} else {
if (displayObject != null){
initDisplay();
};
};
paint();
}
function initDisplay():void{
if (collidable){
scp.initDisplay();
} else {
displayObject.x = displayObjectOffset.x;
displayObject.y = displayObjectOffset.y;
displayObject.rotation = displayObjectRotation;
sprite.addChild(displayObject);
};
}
public function isConnectedTo(_arg1:AbstractParticle):Boolean{
return ((((_arg1 == p1)) || ((_arg1 == p2))));
}
function get scp():SpringConstraintParticle{
return (_scp);
}
public function setDisplay(_arg1:DisplayObject, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0):void{
if (collidable){
scp.setDisplay(_arg1, _arg2, _arg3, _arg4);
} else {
displayObject = _arg1;
displayObjectRotation = _arg4;
displayObjectOffset = new Vector(_arg2, _arg3);
};
}
private function checkParticlesLocation():void{
if ((((p1.curr.x == p2.curr.x)) && ((p1.curr.y == p2.curr.y)))){
p2.curr.x = (p2.curr.x + 0.0001);
};
}
public function get radian():Number{
var _local1:Vector;
_local1 = delta;
return (Math.atan2(_local1.y, _local1.x));
}
public function get rectHeight():Number{
return (scp.rectHeight);
}
public function set restLength(_arg1:Number):void{
if (_arg1 <= 0){
throw (new ArgumentError("restLength must be greater than 0"));
};
_restLength = _arg1;
}
public function get currLength():Number{
return (p1.curr.distance(p2.curr));
}
public function get fixedEndLimit():Number{
return (scp.fixedEndLimit);
}
function get delta():Vector{
return (p1.curr.minus(p2.curr));
}
public function get angle():Number{
return ((radian * MathUtil.ONE_EIGHTY_OVER_PI));
}
public function get center():Vector{
return (p1.curr.plus(p2.curr).divEquals(2));
}
public function setCollidable(_arg1:Boolean, _arg2:Number, _arg3:Number, _arg4:Boolean=false):void{
_collidable = _arg1;
_scp = null;
if (_collidable){
_scp = new SpringConstraintParticle(p1, p2, this, _arg2, _arg3, _arg4);
};
}
override public function paint():void{
var _local1:Vector;
if (collidable){
scp.paint();
} else {
if (displayObject != null){
_local1 = center;
sprite.x = _local1.x;
sprite.y = _local1.y;
sprite.rotation = angle;
} else {
sprite.graphics.clear();
sprite.graphics.lineStyle(lineThickness, lineColor, lineAlpha);
sprite.graphics.moveTo(p1.px, p1.py);
sprite.graphics.lineTo(p2.px, p2.py);
};
};
}
public function get rectScale():Number{
return (scp.rectScale);
}
public function get restLength():Number{
return (_restLength);
}
override public function resolve():void{
var _local1:Number;
var _local2:Number;
var _local3:Vector;
if (((p1.fixed) && (p2.fixed))){
return;
};
_local1 = currLength;
_local2 = ((_local1 - restLength) / (_local1 * (p1.invMass + p2.invMass)));
_local3 = delta.mult((_local2 * stiffness));
p1.curr.minusEquals(_local3.mult(p1.invMass));
p2.curr.plusEquals(_local3.mult(p2.invMass));
}
public function set rectHeight(_arg1:Number):void{
if (scp == null){
return;
};
scp.rectHeight = _arg1;
}
public function get collidable():Boolean{
return (_collidable);
}
public function set fixedEndLimit(_arg1:Number):void{
if (scp == null){
return;
};
scp.fixedEndLimit = _arg1;
}
}
}//package org.cove.ape
Section 24
//SpringConstraintParticle (org.cove.ape.SpringConstraintParticle)
package org.cove.ape {
import flash.display.*;
import org.cove.ape.*;
class SpringConstraintParticle extends RectangleParticle {
private var _fixedEndLimit:Number;
private var rca:Vector;
private var rcb:Vector;
private var _rectScale:Number;
private var s:Number;
var parent:SpringConstraint;
private var scaleToLength:Boolean;
private var p1:AbstractParticle;
private var p2:AbstractParticle;
private var lambda:Vector;
private var avgVelocity:Vector;
private var _rectHeight:Number;
function SpringConstraintParticle(_arg1:AbstractParticle, _arg2:AbstractParticle, _arg3:SpringConstraint, _arg4:Number, _arg5:Number, _arg6:Boolean){
super(0, 0, 0, 0, 0, false);
this.p1 = _arg1;
this.p2 = _arg2;
lambda = new Vector(0, 0);
avgVelocity = new Vector(0, 0);
parent = _arg3;
this.rectScale = _arg5;
this.rectHeight = _arg4;
this.scaleToLength = _arg6;
fixedEndLimit = 0;
rca = new Vector();
rcb = new Vector();
}
override public function get mass():Number{
return (((p1.mass + p2.mass) / 2));
}
private function setCorners(_arg1:RectangleParticle, _arg2:int):void{
var _local3:Number;
var _local4:Number;
var _local5:Array;
var _local6:Array;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
_local3 = _arg1.curr.x;
_local4 = _arg1.curr.y;
_local5 = _arg1.axes;
_local6 = _arg1.extents;
_local7 = (_local5[0].x * _local6[0]);
_local8 = (_local5[0].y * _local6[0]);
_local9 = (_local5[1].x * _local6[1]);
_local10 = (_local5[1].y * _local6[1]);
_local11 = (_local7 - _local9);
_local12 = (_local8 - _local10);
_local13 = (_local7 + _local9);
_local14 = (_local8 + _local10);
if (_arg2 == 0){
rca.x = (_local3 - _local13);
rca.y = (_local4 - _local14);
rcb.x = (_local3 + _local11);
rcb.y = (_local4 + _local12);
} else {
if (_arg2 == 1){
rca.x = (_local3 + _local11);
rca.y = (_local4 + _local12);
rcb.x = (_local3 + _local13);
rcb.y = (_local4 + _local14);
} else {
if (_arg2 == 2){
rca.x = (_local3 + _local13);
rca.y = (_local4 + _local14);
rcb.x = (_local3 - _local11);
rcb.y = (_local4 - _local12);
} else {
if (_arg2 == 3){
rca.x = (_local3 - _local11);
rca.y = (_local4 - _local12);
rcb.x = (_local3 - _local13);
rcb.y = (_local4 - _local14);
};
};
};
};
}
override public function init():void{
var _local1:Sprite;
var _local2:Number;
var _local3:Number;
if (displayObject != null){
initDisplay();
} else {
_local1 = new Sprite();
parent.sprite.addChild(_local1);
_local1.name = "inner";
_local2 = (parent.currLength * rectScale);
_local3 = rectHeight;
_local1.graphics.clear();
_local1.graphics.lineStyle(parent.lineThickness, parent.lineColor, parent.lineAlpha);
_local1.graphics.beginFill(parent.fillColor, parent.fillAlpha);
_local1.graphics.drawRect((-(_local2) / 2), (-(_local3) / 2), _local2, _local3);
_local1.graphics.endFill();
};
paint();
}
function updatePosition():void{
var _local1:Vector;
_local1 = parent.center;
curr.setTo(_local1.x, _local1.y);
width = (scaleToLength) ? (parent.currLength * rectScale) : (parent.restLength * rectScale);
height = rectHeight;
radian = parent.radian;
}
private function closestPtSegmentSegment():Number{
var _local1:Vector;
var _local2:Vector;
var _local3:Vector;
var _local4:Vector;
var _local5:Vector;
var _local6:Vector;
var _local7:Vector;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Vector;
var _local16:Vector;
var _local17:Vector;
_local1 = p1.curr;
_local2 = p2.curr;
_local3 = rca;
_local4 = rcb;
_local5 = _local2.minus(_local1);
_local6 = _local4.minus(_local3);
_local7 = _local1.minus(_local3);
_local9 = _local5.dot(_local5);
_local10 = _local6.dot(_local6);
_local11 = _local6.dot(_local7);
_local12 = _local5.dot(_local7);
_local13 = _local5.dot(_local6);
_local14 = ((_local9 * _local10) - (_local13 * _local13));
if (_local14 != 0){
s = MathUtil.clamp((((_local13 * _local11) - (_local12 * _local10)) / _local14), 0, 1);
} else {
s = 0.5;
};
_local8 = (((_local13 * s) + _local11) / _local10);
if (_local8 < 0){
_local8 = 0;
s = MathUtil.clamp((-(_local12) / _local9), 0, 1);
} else {
if (_local8 > 0){
_local8 = 1;
s = MathUtil.clamp(((_local13 - _local12) / _local9), 0, 1);
};
};
_local15 = _local1.plus(_local5.mult(s));
_local16 = _local3.plus(_local6.mult(_local8));
_local17 = _local15.minus(_local16);
return (_local15.minus(_local16).dot(_local17));
}
function get rectHeight():Number{
return (_rectHeight);
}
function get fixedEndLimit():Number{
return (_fixedEndLimit);
}
private function closestParamPoint(_arg1:Vector):Number{
var _local2:Vector;
var _local3:Number;
_local2 = p2.curr.minus(p1.curr);
_local3 = (_local2.dot(_arg1.minus(p1.curr)) / _local2.dot(_local2));
return (MathUtil.clamp(_local3, 0, 1));
}
override public function paint():void{
var _local1:Vector;
var _local2:Sprite;
_local1 = parent.center;
_local2 = parent.sprite;
if (scaleToLength){
_local2.getChildByName("inner").width = (parent.currLength * rectScale);
} else {
if (displayObject != null){
_local2.getChildByName("inner").width = (parent.restLength * rectScale);
};
};
_local2.x = _local1.x;
_local2.y = _local1.y;
_local2.rotation = parent.angle;
}
private function getContactPointParam(_arg1:AbstractParticle):Number{
var _local2:Number;
var _local3:Number;
var _local4:Array;
var _local5:Number;
var _local6:int;
var _local7:Number;
if ((_arg1 is CircleParticle)){
_local2 = closestParamPoint(_arg1.curr);
} else {
if ((_arg1 is RectangleParticle)){
_local4 = new Array(4);
_local5 = Number.POSITIVE_INFINITY;
_local6 = 0;
while (_local6 < 4) {
setCorners((_arg1 as RectangleParticle), _local6);
_local7 = closestPtSegmentSegment();
if (_local7 < _local5){
_local5 = _local7;
_local3 = _local6;
_local4[_local6] = s;
};
_local6++;
};
_local2 = _local4[_local3];
};
};
return (_local2);
}
function set fixedEndLimit(_arg1:Number):void{
_fixedEndLimit = _arg1;
}
function set rectHeight(_arg1:Number):void{
_rectHeight = _arg1;
}
override public function get fixed():Boolean{
return (parent.fixed);
}
override function get invMass():Number{
if (((p1.fixed) && (p2.fixed))){
return (0);
};
return ((1 / ((p1.mass + p2.mass) / 2)));
}
override function initDisplay():void{
var _local1:Sprite;
displayObject.x = displayObjectOffset.x;
displayObject.y = displayObjectOffset.y;
displayObject.rotation = displayObjectRotation;
_local1 = new Sprite();
_local1.name = "inner";
_local1.addChild(displayObject);
parent.sprite.addChild(_local1);
}
function set rectScale(_arg1:Number):void{
_rectScale = _arg1;
}
override function resolveCollision(_arg1:Vector, _arg2:Vector, _arg3:Vector, _arg4:Number, _arg5:int, _arg6:AbstractParticle):void{
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:AbstractParticle;
testParticleEvents(_arg6);
if (((fixed) || (!(_arg6.solid)))){
return;
};
_local7 = getContactPointParam(_arg6);
_local8 = (1 - _local7);
_local9 = _local7;
if (p1.fixed){
if (_local9 <= fixedEndLimit){
return;
};
lambda.setTo((_arg1.x / _local9), (_arg1.y / _local9));
p2.curr.plusEquals(lambda);
p2.velocity = _arg2;
} else {
if (p2.fixed){
if (_local8 <= fixedEndLimit){
return;
};
lambda.setTo((_arg1.x / _local8), (_arg1.y / _local8));
p1.curr.plusEquals(lambda);
p1.velocity = _arg2;
} else {
_local10 = ((_local8 * _local8) + (_local9 * _local9));
if (_local10 == 0){
return;
};
lambda.setTo((_arg1.x / _local10), (_arg1.y / _local10));
p1.curr.plusEquals(lambda.mult(_local8));
p2.curr.plusEquals(lambda.mult(_local9));
if (_local7 == 0.5){
p1.velocity = _arg2;
p2.velocity = _arg2;
} else {
_local11 = ((_local7)<0.5) ? p1 : p2;
_local11.velocity = _arg2;
};
};
};
}
override public function get elasticity():Number{
return (((p1.elasticity + p2.elasticity) / 2));
}
function get rectScale():Number{
return (_rectScale);
}
override public function get velocity():Vector{
var _local1:Vector;
var _local2:Vector;
_local1 = p1.velocity;
_local2 = p2.velocity;
avgVelocity.setTo(((_local1.x + _local2.x) / 2), ((_local1.y + _local2.y) / 2));
return (avgVelocity);
}
override public function get friction():Number{
return (((p1.friction + p2.friction) / 2));
}
}
}//package org.cove.ape
Section 25
//Vector (org.cove.ape.Vector)
package org.cove.ape {
public class Vector {
public var x:Number;
public var y:Number;
public function Vector(_arg1:Number=0, _arg2:Number=0){
x = _arg1;
y = _arg2;
}
public function cross(_arg1:Vector):Number{
return (((x * _arg1.y) - (y * _arg1.x)));
}
public function magnitude():Number{
return (Math.sqrt(((x * x) + (y * y))));
}
public function divEquals(_arg1:Number):Vector{
if (_arg1 == 0){
_arg1 = 0.0001;
};
x = (x / _arg1);
y = (y / _arg1);
return (this);
}
public function times(_arg1:Vector):Vector{
return (new Vector((x * _arg1.x), (y * _arg1.y)));
}
public function plusEquals(_arg1:Vector):Vector{
x = (x + _arg1.x);
y = (y + _arg1.y);
return (this);
}
public function dot(_arg1:Vector):Number{
return (((x * _arg1.x) + (y * _arg1.y)));
}
public function normalizeEquals():Vector{
var _local1:Number;
_local1 = magnitude();
if (_local1 == 0){
_local1 = 0.0001;
};
return (multEquals((1 / _local1)));
}
public function normalize():Vector{
var _local1:Number;
_local1 = magnitude();
if (_local1 == 0){
_local1 = 0.0001;
};
return (mult((1 / _local1)));
}
public function copy(_arg1:Vector):void{
x = _arg1.x;
y = _arg1.y;
}
public function minusEquals(_arg1:Vector):Vector{
x = (x - _arg1.x);
y = (y - _arg1.y);
return (this);
}
public function minus(_arg1:Vector):Vector{
return (new Vector((x - _arg1.x), (y - _arg1.y)));
}
public function plus(_arg1:Vector):Vector{
return (new Vector((x + _arg1.x), (y + _arg1.y)));
}
public function toString():String{
return (((x + " : ") + y));
}
public function distance(_arg1:Vector):Number{
var _local2:Vector;
_local2 = this.minus(_arg1);
return (_local2.magnitude());
}
public function setTo(_arg1:Number, _arg2:Number):void{
x = _arg1;
y = _arg2;
}
public function multEquals(_arg1:Number):Vector{
x = (x * _arg1);
y = (y * _arg1);
return (this);
}
public function mult(_arg1:Number):Vector{
return (new Vector((x * _arg1), (y * _arg1)));
}
}
}//package org.cove.ape
Section 26
//VectorForce (org.cove.ape.VectorForce)
package org.cove.ape {
public class VectorForce implements IForce {
private var fvx:Number;
private var fvy:Number;
private var value:Vector;
private var scaleMass:Boolean;
public function VectorForce(_arg1:Boolean, _arg2:Number, _arg3:Number){
fvx = _arg2;
fvy = _arg3;
scaleMass = _arg1;
value = new Vector(_arg2, _arg3);
}
public function set vx(_arg1:Number):void{
fvx = _arg1;
value.x = _arg1;
}
public function set vy(_arg1:Number):void{
fvy = _arg1;
value.y = _arg1;
}
public function set useMass(_arg1:Boolean):void{
scaleMass = _arg1;
}
public function getValue(_arg1:Number):Vector{
if (scaleMass){
value.setTo((fvx * _arg1), (fvy * _arg1));
};
return (value);
}
}
}//package org.cove.ape
Section 27
//AdSponsorLink (AdSponsorLink)
package {
import flash.display.*;
public dynamic class AdSponsorLink extends SimpleButton {
}
}//package
Section 28
//ArialRoundedMTBold_EMBED (ArialRoundedMTBold_EMBED)
package {
import flash.text.*;
public dynamic class ArialRoundedMTBold_EMBED extends Font {
}
}//package
Section 29
//BallBounceSound (BallBounceSound)
package {
import flash.media.*;
public dynamic class BallBounceSound extends Sound {
}
}//package
Section 30
//BallGraphic (BallGraphic)
package {
import flash.display.*;
public dynamic class BallGraphic extends MovieClip {
}
}//package
Section 31
//BallHighBounceSound (BallHighBounceSound)
package {
import flash.media.*;
public dynamic class BallHighBounceSound extends Sound {
}
}//package
Section 32
//BounceBrick (BounceBrick)
package {
import flash.display.*;
public dynamic class BounceBrick extends MovieClip {
public function BounceBrick(){
addFrameScript(0, frame1, 22, frame23);
}
function frame1(){
stop();
}
function frame23(){
stop();
dispatchEvent(new ClipDoneEvent(ClipDoneEvent.CLIPDONE));
}
}
}//package
Section 33
//BouncePad (BouncePad)
package {
import org.cove.ape.*;
public class BouncePad extends RectangleParticle {
public function BouncePad(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0, _arg6:Boolean=false, _arg7:Number=1, _arg8:Number=0.3, _arg9:Number=0){
super(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9);
}
}
}//package
Section 34
//BreakBrick (BreakBrick)
package {
import flash.display.*;
public dynamic class BreakBrick extends MovieClip {
public function BreakBrick(){
addFrameScript(0, frame1, 22, frame23);
}
function frame1(){
stop();
}
function frame23(){
stop();
dispatchEvent(new ClipDoneEvent(ClipDoneEvent.CLIPDONE));
}
}
}//package
Section 35
//Brick (Brick)
package {
import org.cove.ape.*;
public class Brick extends RectangleParticle {
private const BRICKMOVESPEED:Number = 2;
public var breakNum:int;// = 2
private var isMoving:Boolean;// = false
private var brickType:int;// = 0
private var dest:int;// = 0
private var isAlive:Boolean;// = true
private var bPadAdjust:Number;// = 0
public var bouncePad:BouncePad;
public function Brick(_arg1:int, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number=0, _arg7:Boolean=false, _arg8:Number=1, _arg9:Number=0.3, _arg10:Number=0){
brickType = 0;
isAlive = true;
dest = 0;
bPadAdjust = 0;
isMoving = false;
breakNum = 2;
super(_arg2, _arg3, _arg4, _arg5, _arg6, _arg7, _arg8, _arg9, _arg10);
brickType = _arg1;
bPadAdjust = (_arg5 / 2);
bouncePad = new BouncePad(_arg2, (_arg3 - bPadAdjust), (_arg4 - 1), 1, _arg6, _arg7, _arg8, _arg9, _arg10);
bouncePad.setStyle(0, 0, 0, 0, 0);
}
public function moveDown(){
if ((py + BRICKMOVESPEED) >= dest){
sprite.y = dest;
py = dest;
bouncePad.py = (dest - bPadAdjust);
isMoving = false;
} else {
py = (py + BRICKMOVESPEED);
sprite.y = (sprite.y + BRICKMOVESPEED);
bouncePad.py = (bouncePad.py + BRICKMOVESPEED);
};
}
public function set destination(_arg1:int){
dest = _arg1;
}
public function get destination(){
return (dest);
}
public function get typeOfBrick(){
return (brickType);
}
public function set typeOfBrick(_arg1:int){
brickType = _arg1;
}
public function get moving(){
return (isMoving);
}
public function set moving(_arg1:Boolean){
isMoving = _arg1;
}
public function blowUp(){
}
}
}//package
Section 36
//BrickBreakSound (BrickBreakSound)
package {
import flash.media.*;
public dynamic class BrickBreakSound extends Sound {
}
}//package
Section 37
//BrickCrackSound (BrickCrackSound)
package {
import flash.media.*;
public dynamic class BrickCrackSound extends Sound {
}
}//package
Section 38
//BrickDropSound (BrickDropSound)
package {
import flash.media.*;
public dynamic class BrickDropSound extends Sound {
}
}//package
Section 39
//ClipCollision (ClipCollision)
package {
import flash.geom.*;
import flash.display.*;
public class ClipCollision {
private function getAlphaMap(_arg1:DisplayObject, _arg2:Rectangle, _arg3:uint, _arg4:Rectangle, _arg5:Number, _arg6:Number):BitmapData{
var _local7:BitmapData;
var _local8:Matrix;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:BitmapData;
_local7 = new BitmapData(_arg2.width, _arg2.height, true, 0);
_local8 = new Matrix();
_local9 = (_arg5 - _arg4.x);
_local10 = (_arg6 - _arg4.y);
_local11 = ((_arg4.x + _local9) - _arg2.x);
_local12 = ((_arg4.y + _local10) - _arg2.y);
_local8.translate(_local11, _local12);
_local7.draw(_arg1, _local8);
_local13 = new BitmapData(_arg2.width, _arg2.height, false, 0);
_local13.copyChannel(_local7, _local7.rect, new Point(0, 0), BitmapDataChannel.ALPHA, _arg3);
return (_local13);
}
public function isColliding(_arg1:DisplayObject, _arg2:DisplayObject, _arg3:Number, _arg4:Number, _arg5:Number=0):Boolean{
var _local6:Rectangle;
_local6 = getCollision(_arg1, _arg2, _arg3, _arg4, _arg5);
if (((!((_local6 == null))) && ((_local6.size.length > 0)))){
return (true);
};
return (false);
}
public function getCollisionPoint(_arg1:DisplayObject, _arg2:DisplayObject, _arg3:Number=0):Point{
var _local4:Point;
var _local5:Rectangle;
var _local6:Number;
var _local7:Number;
_local5 = getCollision(_arg1, _arg2, 0, 0, _arg3);
if (((!((_local5 == null))) && ((_local5.size.length > 0)))){
_local6 = ((_local5.left + _local5.right) / 2);
_local7 = ((_local5.top + _local5.bottom) / 2);
_local4 = new Point(_local6, _local7);
};
return (_local4);
}
public function getCollision(_arg1:DisplayObject, _arg2:DisplayObject, _arg3:Number, _arg4:Number, _arg5:Number=0):Rectangle{
var _local6:Rectangle;
var _local7:DisplayObjectContainer;
var _local8:DisplayObjectContainer;
var _local9:Rectangle;
var _local10:Rectangle;
var _local11:Boolean;
var _local12:Rectangle;
var _local13:BitmapData;
var _local14:BitmapData;
var _local15:uint;
var _local16:Number;
_local7 = _arg1.parent;
_local8 = _arg2.parent;
_local9 = _arg1.getBounds(_local7);
_local10 = _arg2.getBounds(_local8);
_local10.x = (_arg3 - 9);
_local10.y = (_arg4 - 9);
_local11 = _local9.intersects(_local10);
if (_local11){
_local12 = _local9.union(_local10);
_local13 = getAlphaMap(_arg1, _local12, BitmapDataChannel.RED, _local9, _arg1.x, _arg1.y);
_local14 = getAlphaMap(_arg2, _local12, BitmapDataChannel.GREEN, _local10, _arg3, _arg4);
_local13.draw(_local14, new Matrix(), new ColorTransform(), BlendMode.LIGHTEN);
if (_arg5 > 1){
_arg5 = 1;
};
if (_arg5 < 0){
_arg5 = 0;
};
if (_arg5 == 0){
_local15 = 65792;
} else {
_local16 = Math.round((_arg5 * 0xFF));
_local15 = (((_local16 << 16) | (_local16 << 8)) | 0);
};
_local6 = _local13.getColorBoundsRect(_local15, _local15);
_local13.getColorBoundsRect(_local15, _local15).x = (_local6.x + _local12.x);
_local6.y = (_local6.y + _local12.y);
return (_local6);
};
return (_local6);
}
}
}//package
Section 40
//ClipDoneEvent (ClipDoneEvent)
package {
import flash.events.*;
public class ClipDoneEvent extends Event {
public static const CLIPDONE:String = "clipdone";
public function ClipDoneEvent(_arg1:String){
super(_arg1, true);
}
override public function clone():Event{
return (new ClipDoneEvent(type));
}
}
}//package
Section 41
//CoinClip (CoinClip)
package {
import flash.display.*;
public dynamic class CoinClip extends MovieClip {
public function CoinClip(){
addFrameScript(0, frame1, 21, frame22);
}
function frame1(){
stop();
}
function frame22(){
stop();
dispatchEvent(new ClipDoneEvent(ClipDoneEvent.CLIPDONE));
}
}
}//package
Section 42
//CoinCollectSound (CoinCollectSound)
package {
import flash.media.*;
public dynamic class CoinCollectSound extends Sound {
}
}//package
Section 43
//CongratsMusic (CongratsMusic)
package {
import flash.media.*;
public dynamic class CongratsMusic extends Sound {
}
}//package
Section 44
//CongratsScreen (CongratsScreen)
package {
import flash.display.*;
public dynamic class CongratsScreen extends MovieClip {
}
}//package
Section 45
//CPMStarAdBox (CPMStarAdBox)
package {
import flash.display.*;
public dynamic class CPMStarAdBox extends MovieClip {
public var sponsorLinkInAd:AdSponsorLink;
}
}//package
Section 46
//CreditsTag (CreditsTag)
package {
import flash.display.*;
public dynamic class CreditsTag extends MovieClip {
}
}//package
Section 47
//CrumbleBrick (CrumbleBrick)
package {
import flash.display.*;
public dynamic class CrumbleBrick extends MovieClip {
public function CrumbleBrick(){
addFrameScript(0, frame1, 1, frame2, 23, frame24);
}
function frame1(){
stop();
}
function frame24(){
stop();
dispatchEvent(new ClipDoneEvent(ClipDoneEvent.CLIPDONE));
}
function frame2(){
stop();
}
}
}//package
Section 48
//Drop1Brick (Drop1Brick)
package {
import flash.display.*;
public dynamic class Drop1Brick extends MovieClip {
public function Drop1Brick(){
addFrameScript(0, frame1, 22, frame23);
}
function frame1(){
stop();
}
function frame23(){
stop();
dispatchEvent(new ClipDoneEvent(ClipDoneEvent.CLIPDONE));
}
}
}//package
Section 49
//Drop2Brick (Drop2Brick)
package {
import flash.display.*;
public dynamic class Drop2Brick extends MovieClip {
public function Drop2Brick(){
addFrameScript(0, frame1, 22, frame23);
}
function frame1(){
stop();
}
function frame23(){
stop();
dispatchEvent(new ClipDoneEvent(ClipDoneEvent.CLIPDONE));
}
}
}//package
Section 50
//Drop3Brick (Drop3Brick)
package {
import flash.display.*;
public dynamic class Drop3Brick extends MovieClip {
public function Drop3Brick(){
addFrameScript(0, frame1, 22, frame23);
}
function frame1(){
stop();
}
function frame23(){
stop();
dispatchEvent(new ClipDoneEvent(ClipDoneEvent.CLIPDONE));
}
}
}//package
Section 51
//DroppleGame (DroppleGame)
package {
import flash.display.*;
import flash.events.*;
import mochi.*;
import flash.text.*;
import flash.media.*;
import flash.net.*;
import flash.utils.*;
public class DroppleGame extends Sprite {
private const STATE_INGAME:int = 40;
private const SINISTERSEAURL:URLRequest;
private const STATE_SUBMITTEDHIGHSCORES:int = 80;
private const STATE_SUBMITTED:int = 70;
private const STATE_HIGHSCORES:int = 35;
private const STATE_NOTSTARTED:int = 0;
private const STATE_BACKTOTITLE:int = 50;
private const STATE_LOGOINTRO:int = 10;
private const NOTDOPPLERURL:URLRequest;
private const STATE_GOTOHIGHSCORES:int = 30;
private const STATE_CONGRATS:int = 60;
private const STATE_TITLESCREEN:int = 20;
private var resumePrevGame:Boolean;// = false
private var submittedName:String;
private var fadeTimer:Timer;
private var transitionScene:TransitionClip;
private var submittedScore;
private var congratsMusic:CongratsMusic;
private var resumeLSO:SharedObject;
private var transitionDone:Boolean;// = true
private var currentScore:int;// = 0
private var fxButton:FxButton;
private var titleMusic:TitleMusic;
private var titleScr:TitleScreen;
private var finalScore:TextField;
private var musicTransform:SoundTransform;
private var loseSound:LoseSound;
private var levelScreen:Level;
private var notDopplerIntro:SponsorIntro;
private var introMusic:IntroMusic;
private var musicChannel:SoundChannel;
private var playFx:Boolean;// = true
private var submitScoreButton:SubmitScoreButton;
private var gameMusic:GameMusic;
private var playMusic:Boolean;// = true
private var logoIntro:SinisterSeaIntro;
public var currentLevel:int;// = 0
private var nameDisplay:TextField;
private var submitScoreField:TextField;
private var gameState:int;// = 0
private var musicButton:MusicButton;
private var congratsScreen:CongratsScreen;
private var currentTime:Number;// = 0
private var submitScoreFormat:TextFormat;
public function DroppleGame(){
SINISTERSEAURL = new URLRequest("http://www.sinistersea.com");
NOTDOPPLERURL = new URLRequest("http://www.notdoppler.com");
titleScr = new TitleScreen();
logoIntro = new SinisterSeaIntro();
notDopplerIntro = new SponsorIntro();
transitionScene = new TransitionClip();
congratsScreen = new CongratsScreen();
submitScoreFormat = new TextFormat();
submitScoreField = new TextField();
finalScore = new TextField();
nameDisplay = new TextField();
submitScoreButton = new SubmitScoreButton();
currentLevel = 0;
transitionDone = true;
currentScore = 0;
currentTime = 0;
musicButton = new MusicButton();
fxButton = new FxButton();
playMusic = true;
playFx = true;
musicChannel = new SoundChannel();
musicTransform = new SoundTransform();
fadeTimer = new Timer(100, 0);
introMusic = new IntroMusic();
titleMusic = new TitleMusic();
gameMusic = new GameMusic();
congratsMusic = new CongratsMusic();
loseSound = new LoseSound();
resumeLSO = SharedObject.getLocal("droppleResume");
resumePrevGame = false;
gameState = STATE_NOTSTARTED;
super();
transitionScene.mouseEnabled = false;
transitionScene.mouseChildren = false;
logoIntro.useHandCursor = true;
logoIntro.buttonMode = true;
musicButton.buttonMode = true;
musicButton.useHandCursor = true;
fxButton.buttonMode = true;
fxButton.useHandCursor = true;
}
private function sponsorIntroDone(_arg1:ClipDoneEvent){
notDopplerIntro.removeEventListener(ClipDoneEvent.CLIPDONE, sponsorIntroDone);
notDopplerIntro.removeEventListener(MouseEvent.CLICK, notDopplerClicked);
removeChild(notDopplerIntro);
startGame();
}
private function showScoresFromClick(_arg1:MouseEvent){
titleScr.startGameBtn.removeEventListener(MouseEvent.CLICK, launchStartTransitionFromClick);
titleScr.highScoresBtn.removeEventListener(MouseEvent.CLICK, showScoresFromClick);
titleScr.resumeTitleBtn.removeEventListener(MouseEvent.CLICK, resumeTitleClicked);
titleScr.deInit();
currentLevel = 1;
currentScore = 0;
currentTime = 0;
gameState = STATE_GOTOHIGHSCORES;
startTransition();
}
private function musicChangeBackToTitle(){
stopMusic();
startTransition();
}
private function launchTransitionFromClipDone(_arg1:ClipDoneEvent){
startTransition();
}
private function fadeTimerFired(_arg1:TimerEvent){
musicTransform.volume = (musicTransform.volume - 0.1);
musicChannel.soundTransform = musicTransform;
if (musicTransform.volume <= 0){
musicTransform.volume = 0;
fadeTimer.stop();
fadeTimer.reset();
musicChannel.stop();
};
}
private function clearCurrentLevel(){
saveResumeData();
levelScreen.removeEventListener(LevelEvent.LEVELWON, wonLevel);
levelScreen.removeEventListener(LevelEvent.EXITLEVEL, exitLevel);
levelScreen.removeEventListener(LevelEvent.RESETLEVEL, resetLevel);
levelScreen.clearLevel();
removeChild(levelScreen);
levelScreen = null;
}
private function wonLevel(_arg1:LevelEvent){
currentLevel++;
currentTime = 0;
currentScore = levelScreen.levelScore;
if (currentLevel > 50){
gameState = STATE_CONGRATS;
stopMusic();
};
startTransition();
}
private function endTransition(_arg1:ClipDoneEvent){
if (gameState == STATE_TITLESCREEN){
titleScr.startIntro();
};
transitionDone = true;
transitionScene.removeEventListener(ClipDoneEvent.CLIPDONE, endTransition);
removeChild(transitionScene);
}
private function prepareLevel(){
levelScreen = new Level(currentScore, currentTime, playFx, currentLevel);
levelScreen.x = 0;
levelScreen.y = 0;
addChildAt(levelScreen, 0);
levelScreen.init();
levelScreen.addEventListener(LevelEvent.LEVELWON, wonLevel);
levelScreen.addEventListener(LevelEvent.EXITLEVEL, exitLevel);
levelScreen.addEventListener(LevelEvent.RESETLEVEL, resetLevel);
levelScreen.listenForStart();
}
private function clearSubmit(){
removeChild(finalScore);
removeChild(nameDisplay);
removeChild(submitScoreField);
removeChild(submitScoreButton);
removeChild(congratsScreen);
}
private function fxToggle(_arg1:MouseEvent){
if (playFx){
fxButton.gotoAndStop("overOff");
} else {
fxButton.gotoAndStop("over");
};
playFx = !(playFx);
if (titleScr != null){
titleScr.playFx = playFx;
};
if (levelScreen != null){
levelScreen.fxStatus = playFx;
stage.focus = levelScreen;
};
}
private function saveResumeData(){
resumeLSO.data.savedLevel = currentLevel;
resumeLSO.data.savedScore = currentScore;
resumeLSO.data.savedTime = currentTime;
try {
resumeLSO.flush();
} catch(e:Error) {
};
}
private function startMusic(){
if (playMusic){
fadeTimer.stop();
fadeTimer.reset();
musicChannel.stop();
if (gameState <= 20){
musicChannel = titleMusic.play(0, int.MAX_VALUE);
} else {
if ((((gameState > 20)) && ((gameState < 60)))){
musicChannel = gameMusic.play(0, int.MAX_VALUE);
} else {
if (gameState >= 60){
musicChannel = congratsMusic.play(0, int.MAX_VALUE);
};
};
};
musicTransform.volume = 1;
musicChannel.soundTransform = musicTransform;
};
}
private function changeButtonState(_arg1:MouseEvent){
if (_arg1.target.currentLabel == "up"){
_arg1.target.gotoAndStop("over");
} else {
if (_arg1.target.currentLabel == "upOff"){
_arg1.target.gotoAndStop("overOff");
} else {
if (_arg1.target.currentLabel == "over"){
_arg1.target.gotoAndStop("up");
} else {
if (_arg1.target.currentLabel == "overOff"){
_arg1.target.gotoAndStop("upOff");
};
};
};
};
}
private function exitLevel(_arg1:LevelEvent){
gameState = STATE_BACKTOTITLE;
startTransition();
}
private function sinisterSeaClicked(_arg1:MouseEvent){
navigateToURL(SINISTERSEAURL, "_blank");
}
public function showSponsorIntro(){
stage.stageFocusRect = false;
gameState = STATE_LOGOINTRO;
notDopplerIntro.x = 0;
notDopplerIntro.y = 0;
addChild(notDopplerIntro);
notDopplerIntro.addEventListener(ClipDoneEvent.CLIPDONE, sponsorIntroDone);
notDopplerIntro.addEventListener(MouseEvent.CLICK, notDopplerClicked);
notDopplerIntro.play();
}
private function launchStartTransitionFromClick(_arg1:MouseEvent){
startTransition();
}
private function stopMusic(){
if (playMusic){
fadeTimer.start();
};
}
private function loadState(_arg1:ClipDoneEvent){
var e = _arg1;
switch (gameState){
case STATE_LOGOINTRO:
gameState = STATE_TITLESCREEN;
titleScr.x = 0;
titleScr.y = 0;
addChildAt(titleScr, 0);
logoIntro.removeEventListener(ClipDoneEvent.CLIPDONE, launchTransitionFromClipDone);
logoIntro.removeEventListener(MouseEvent.CLICK, sinisterSeaClicked);
removeChild(logoIntro);
titleScr.init();
titleScr.startGameBtn.addEventListener(MouseEvent.CLICK, launchStartTransitionFromClick);
titleScr.highScoresBtn.addEventListener(MouseEvent.CLICK, showScoresFromClick);
titleScr.resumeTitleBtn.addEventListener(MouseEvent.CLICK, resumeTitleClicked);
musicButton.x = 420;
musicButton.y = 9;
addChild(musicButton);
fxButton.x = 390;
fxButton.y = 9;
addChild(fxButton);
musicButton.addEventListener(MouseEvent.CLICK, musicToggle);
musicButton.addEventListener(MouseEvent.MOUSE_OVER, changeButtonState);
musicButton.addEventListener(MouseEvent.MOUSE_OUT, changeButtonState);
fxButton.addEventListener(MouseEvent.CLICK, fxToggle);
fxButton.addEventListener(MouseEvent.MOUSE_OVER, changeButtonState);
fxButton.addEventListener(MouseEvent.MOUSE_OUT, changeButtonState);
startMusic();
break;
case STATE_TITLESCREEN:
gameState = STATE_INGAME;
prepareLevel();
removeChild(titleScr);
startMusic();
break;
case STATE_INGAME:
clearCurrentLevel();
prepareLevel();
break;
case STATE_CONGRATS:
clearCurrentLevel();
showCongrats();
startMusic();
break;
case STATE_SUBMITTED:
clearSubmit();
MochiScores.showLeaderboard({boardID:"1be551f3a9c271e5", score:submittedScore, name:submittedName, onClose:function ():void{
musicChangeBackToTitle();
}});
submittedName = "";
submittedScore = 0;
gameState = STATE_SUBMITTEDHIGHSCORES;
break;
case STATE_HIGHSCORES:
gameState = STATE_TITLESCREEN;
titleScr.x = 0;
titleScr.y = 0;
addChildAt(titleScr, 0);
titleScr.init();
titleScr.startGameBtn.addEventListener(MouseEvent.CLICK, launchStartTransitionFromClick);
titleScr.highScoresBtn.addEventListener(MouseEvent.CLICK, showScoresFromClick);
titleScr.resumeTitleBtn.addEventListener(MouseEvent.CLICK, resumeTitleClicked);
break;
case STATE_SUBMITTEDHIGHSCORES:
gameState = STATE_TITLESCREEN;
titleScr.x = 0;
titleScr.y = 0;
addChildAt(titleScr, 0);
titleScr.init();
titleScr.startGameBtn.addEventListener(MouseEvent.CLICK, launchStartTransitionFromClick);
titleScr.highScoresBtn.addEventListener(MouseEvent.CLICK, showScoresFromClick);
titleScr.resumeTitleBtn.addEventListener(MouseEvent.CLICK, resumeTitleClicked);
startMusic();
break;
case STATE_GOTOHIGHSCORES:
removeChild(titleScr);
showScores();
break;
case STATE_BACKTOTITLE:
clearCurrentLevel();
gameState = STATE_TITLESCREEN;
titleScr.x = 0;
titleScr.y = 0;
addChildAt(titleScr, 0);
titleScr.init();
titleScr.startGameBtn.addEventListener(MouseEvent.CLICK, launchStartTransitionFromClick);
titleScr.highScoresBtn.addEventListener(MouseEvent.CLICK, showScoresFromClick);
titleScr.resumeTitleBtn.addEventListener(MouseEvent.CLICK, resumeTitleClicked);
startMusic();
break;
};
transitionScene.removeEventListener(ClipDoneEvent.CLIPDONE, loadState);
transitionScene.addEventListener(ClipDoneEvent.CLIPDONE, endTransition);
setChildIndex(transitionScene, (numChildren - 1));
transitionScene.gotoAndPlay("endFade");
}
public function startTransition(){
switch (gameState){
case STATE_LOGOINTRO:
break;
case STATE_TITLESCREEN:
titleScr.startGameBtn.removeEventListener(MouseEvent.CLICK, launchStartTransitionFromClick);
titleScr.highScoresBtn.removeEventListener(MouseEvent.CLICK, showScoresFromClick);
titleScr.resumeTitleBtn.removeEventListener(MouseEvent.CLICK, resumeTitleClicked);
titleScr.deInit();
currentLevel = 1;
currentScore = 0;
currentTime = 0;
if (resumePrevGame){
currentLevel = resumeLSO.data.savedLevel;
currentScore = resumeLSO.data.savedScore;
currentTime = resumeLSO.data.savedTime;
};
stopMusic();
break;
case STATE_BACKTOTITLE:
stopMusic();
break;
};
resumePrevGame = false;
transitionScene.x = 0;
transitionScene.y = 0;
if (!transitionDone){
transitionScene.removeEventListener(ClipDoneEvent.CLIPDONE, endTransition);
} else {
addChild(transitionScene);
};
transitionScene.addEventListener(ClipDoneEvent.CLIPDONE, loadState);
transitionScene.gotoAndPlay("startFade");
transitionDone = false;
}
private function submitScore(_arg1:MouseEvent){
submitScoreButton.removeEventListener(MouseEvent.CLICK, submitScore);
stage.focus = this;
submittedName = submitScoreField.text;
submittedScore = currentScore;
submitScoreField.text = "";
gameState = STATE_SUBMITTED;
startTransition();
}
public function startGame(){
logoIntro.gotoAndStop(1);
logoIntro.x = -69;
logoIntro.y = 15;
addChild(logoIntro);
logoIntro.addEventListener(ClipDoneEvent.CLIPDONE, launchTransitionFromClipDone);
logoIntro.addEventListener(MouseEvent.CLICK, sinisterSeaClicked);
fadeTimer.addEventListener(TimerEvent.TIMER, fadeTimerFired);
logoIntro.play();
introMusic.play();
}
private function resumeTitleClicked(_arg1:MouseEvent){
if (resumeLSO.data.previouslyViewed){
resumePrevGame = true;
startTransition();
} else {
resumeLSO.data.previouslyViewed = true;
resumeLSO.data.savedLevel = 1;
resumeLSO.data.savedScore = 0;
resumeLSO.data.savedTime = 0;
startTransition();
};
}
private function resetLevel(_arg1:LevelEvent){
if (playFx){
loseSound.play();
};
currentTime = levelScreen.levelTime;
clearCurrentLevel();
prepareLevel();
}
private function showScores(){
gameState = STATE_HIGHSCORES;
MochiScores.showLeaderboard({boardID:"1be551f3a9c271e5", onClose:function ():void{
startTransition();
}});
}
private function notDopplerClicked(_arg1:MouseEvent){
navigateToURL(NOTDOPPLERURL, "_blank");
}
private function showCongrats(){
resumeLSO.data.previouslyViewed = true;
resumeLSO.data.savedLevel = 1;
resumeLSO.data.savedScore = 0;
resumeLSO.data.savedTime = 0;
submitScoreFormat.font = new Prototype_EMBED().fontName;
submitScoreFormat.color = 0x996600;
submitScoreFormat.size = 16;
submitScoreFormat.align = "left";
finalScore.x = 184;
finalScore.y = 354;
finalScore.width = 200;
finalScore.height = 60;
finalScore.embedFonts = true;
finalScore.selectable = false;
finalScore.htmlText = ("Final Score: " + String(currentScore));
finalScore.setTextFormat(submitScoreFormat);
addChildAt(finalScore, 0);
nameDisplay.x = 184;
nameDisplay.y = 385;
nameDisplay.width = 200;
nameDisplay.height = 60;
nameDisplay.embedFonts = true;
nameDisplay.selectable = false;
nameDisplay.htmlText = "Name: ";
nameDisplay.setTextFormat(submitScoreFormat);
addChildAt(nameDisplay, 0);
submitScoreField.type = TextFieldType.INPUT;
submitScoreField.embedFonts = true;
submitScoreField.border = true;
submitScoreField.borderColor = 0x996600;
submitScoreField.background = false;
submitScoreField.width = 115;
submitScoreField.height = 22;
submitScoreField.restrict = "a-zA-Z0-9";
submitScoreField.maxChars = 8;
submitScoreField.defaultTextFormat = submitScoreFormat;
submitScoreField.setTextFormat(submitScoreFormat);
submitScoreField.x = 239;
submitScoreField.y = 385;
submitScoreButton.x = 360;
submitScoreButton.y = 385;
addChildAt(submitScoreButton, 0);
addChildAt(congratsScreen, 0);
submitScoreButton.addEventListener(MouseEvent.CLICK, submitScore);
addChild(submitScoreField);
stage.focus = submitScoreField;
}
private function musicToggle(_arg1:MouseEvent){
if (playMusic){
stopMusic();
playMusic = false;
musicButton.gotoAndStop("overOff");
} else {
playMusic = true;
startMusic();
musicButton.gotoAndStop("over");
};
if (levelScreen != null){
stage.focus = levelScreen;
};
}
}
}//package
Section 52
//DroppleIntro (DroppleIntro)
package {
import flash.display.*;
import flash.events.*;
public dynamic class DroppleIntro extends MovieClip {
public var replayIntro:ReplayIntro;
public function DroppleIntro(){
addFrameScript(0, frame1, 879, frame880);
}
public function replayIntroMovie(_arg1:MouseEvent){
replayIntro.removeEventListener(MouseEvent.CLICK, replayIntroMovie);
gotoAndPlay(2);
}
function frame1(){
stop();
}
function frame880(){
stop();
replayIntro.addEventListener(MouseEvent.CLICK, replayIntroMovie);
}
}
}//package
Section 53
//ExitBackdrop (ExitBackdrop)
package {
import flash.display.*;
public dynamic class ExitBackdrop extends MovieClip {
}
}//package
Section 54
//ExitButton (ExitButton)
package {
import flash.display.*;
public dynamic class ExitButton extends SimpleButton {
}
}//package
Section 55
//FxButton (FxButton)
package {
import flash.display.*;
public dynamic class FxButton extends MovieClip {
public function FxButton(){
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4);
}
function frame3(){
stop();
}
function frame1(){
stop();
}
function frame4(){
stop();
}
function frame2(){
stop();
}
}
}//package
Section 56
//GameLogo (GameLogo)
package {
import flash.display.*;
public dynamic class GameLogo extends MovieClip {
}
}//package
Section 57
//GameMusic (GameMusic)
package {
import flash.media.*;
public dynamic class GameMusic extends Sound {
}
}//package
Section 58
//HighScoresButton (HighScoresButton)
package {
import flash.display.*;
public dynamic class HighScoresButton extends SimpleButton {
}
}//package
Section 59
//IntroMusic (IntroMusic)
package {
import flash.media.*;
public dynamic class IntroMusic extends Sound {
}
}//package
Section 60
//LeftWallGraphic (LeftWallGraphic)
package {
import flash.display.*;
public dynamic class LeftWallGraphic extends MovieClip {
}
}//package
Section 61
//Level (Level)
package {
import flash.display.*;
import org.cove.ape.*;
import flash.events.*;
import flash.text.*;
import flash.net.*;
import flash.ui.*;
public class Level extends Sprite {
private const BALLFRICTION:Number = 0;
private const BRICKFRICTION:Number = 0;
private const WALLWIDTH:Number = 40;
private const GRIDWIDTH:int = 40;
private const BRICKWIDTH:Number = 40;
private const PLAYMOREURL:URLRequest;
private const DROP3BRICKTYPE:int = 3;
private const BALLYSTART:int = 50;
private const BRICKHEIGHT:Number = 20;
private const SCREENHEIGHT:int = 480;
private const BRICKROTATION:Number = 0;
private const BRICKMASS:Number = 1;
private const SCREENWIDTH:int = 480;
private const WALLFRICTION:Number = 0;
private const CRUMBLEBRICKTYPE:int = 6;
private const WALLBOUNCE:Number = 0;
private const BREAKBRICKTYPE:int = 5;
private const NUMGRIDSX:int = 12;
private const NUMGRIDSY:int = 24;
private const DROP2BRICKTYPE:int = 2;
private const BALLBOUNCE:Number = 0.7;
private const WALLROTATION:Number = 0;
private const BOUNCEBRICKTYPE:int = 4;
private const BALLRADIUS:Number = 9;
private const COINTYPE:int = 9;
private const JUMPFORCE:Number = -11;
private const EXTRAJUMPFORCE:Number = -18;
private const WALLHEIGHT:Number = 2000;
private const BALLMASS:Number = 1;
private const BALLXSTART:int = 60;
private const WALLMASS:Number = 1;
private const NORMALBRICKTYPE:int = 7;
private const BRICKBOUNCE:Number = 0;
private const GRIDHEIGHT:int = 20;
private const DROP1BRICKTYPE:int = 1;
private var reallyExitButton:ReallyExitButton;
private var numOfCoins:int;// = 0
private var rightWall:RectangleParticle;
private var apeGroup:Group;
private var timeTick:int;// = 0
private var ballSkin:BallGraphic;
private var jump:Vector;
private var brickDropSound:BrickDropSound;
private var messageCommandFormat:TextFormat;
private var gravity:VectorForce;
private var moveLeftAdded:Boolean;// = false
private var ballHighBounceSound;
private var leftWall:RectangleParticle;
private var startScreenShowing:Boolean;// = false
private var playerBall:CircleParticle;
private var coinCollisionDetector:ClipCollision;
private var currentScore:int;// = 0
private var messageHeaderFormat:TextFormat;
private var brickCrackSound:BrickCrackSound;
private var rightWallSkin:RightWallGraphic;
private var levelDisplay:TextField;
private var endScreenShowing:Boolean;// = false
private var levelPauseButton:PauseButton;
private var brickBreakSound:BrickBreakSound;
private var moveRight:VectorForce;
private var winSound;
private var makeBallJump:Boolean;// = false
private var sponsorButton:SponsorButton;
private var moveRightAdded:Boolean;// = false
private var messageTextFormat:TextFormat;
private var resetLevelButton:ResetLevelButton;
private var playFx:Boolean;// = true
private var brickGrid:Array;
private var timeDisplay:TextField;
private var coinCollectSound:CoinCollectSound;
private var messageCommand:TextField;
private var addExtraBounce:Boolean;// = false
private var displayFormat:TextFormat;
private var coinsCollected:int;// = 0
private var moveBrickPos2:Array;
private var coinGrid:Array;
private var moveLeft:VectorForce;
private var messageHeader:TextField;
private var messageBackdrop:MessageBackdrop;
private var moveBrickPos1:Array;
private var levelPoints:int;// = 0
private var currentLevel:int;// = 0
private var layoutGrid:Array;
private var leftWallSkin:LeftWallGraphic;
private var levelRunning:Boolean;// = false
private var exitBackdrop:ExitBackdrop;
private var blowedUpBricks:Array;
private var levelTimeElapsed:Number;// = 0
private var resumeButton:ResumeButton;
private var scoreDisplay:TextField;
private var messageText:TextField;
private var ballBounceSound:BallBounceSound;
private var exitButton:ExitButton;
public function Level(_arg1:int, _arg2:Number, _arg3:Boolean, _arg4:int){
var _local5:int;
PLAYMOREURL = new URLRequest("http://www.notdoppler.com");
brickGrid = new Array();
layoutGrid = new Array();
coinGrid = new Array();
moveBrickPos1 = new Array();
moveBrickPos2 = new Array();
blowedUpBricks = new Array();
currentLevel = 0;
levelTimeElapsed = 0;
timeTick = 0;
numOfCoins = 0;
coinsCollected = 0;
ballSkin = new BallGraphic();
leftWallSkin = new LeftWallGraphic();
rightWallSkin = new RightWallGraphic();
messageHeader = new TextField();
messageHeaderFormat = new TextFormat();
messageText = new TextField();
messageTextFormat = new TextFormat();
messageCommand = new TextField();
messageCommandFormat = new TextFormat();
scoreDisplay = new TextField();
levelDisplay = new TextField();
timeDisplay = new TextField();
displayFormat = new TextFormat();
levelRunning = false;
gravity = new VectorForce(false, 0, 4);
moveLeft = new VectorForce(false, -1.5, 0);
moveRight = new VectorForce(false, 1.5, 0);
jump = new Vector(0, 0);
moveLeftAdded = false;
moveRightAdded = false;
makeBallJump = false;
addExtraBounce = false;
currentScore = 0;
levelPoints = 0;
messageBackdrop = new MessageBackdrop();
playFx = true;
levelPauseButton = new PauseButton();
exitButton = new ExitButton();
sponsorButton = new SponsorButton();
resetLevelButton = new ResetLevelButton();
resumeButton = new ResumeButton();
reallyExitButton = new ReallyExitButton();
exitBackdrop = new ExitBackdrop();
coinCollisionDetector = new ClipCollision();
ballBounceSound = new BallBounceSound();
coinCollectSound = new CoinCollectSound();
brickBreakSound = new BrickBreakSound();
brickDropSound = new BrickDropSound();
brickCrackSound = new BrickCrackSound();
ballHighBounceSound = new BallHighBounceSound();
winSound = new WinSound();
startScreenShowing = false;
endScreenShowing = false;
super();
_local5 = 0;
while (_local5 < NUMGRIDSY) {
brickGrid[_local5] = new Array();
coinGrid[_local5] = new Array();
_local5++;
};
currentScore = _arg1;
levelTimeElapsed = _arg2;
playFx = _arg3;
currentLevel = _arg4;
}
public function listenForStart(){
stage.addEventListener(KeyboardEvent.KEY_DOWN, levelStartKeyCheck);
exitButton.addEventListener(MouseEvent.CLICK, showExitMenu);
startScreenShowing = true;
stage.focus = this;
}
private function stepLevel(_arg1:Event){
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
if ((((((playerBall.py > SCREENHEIGHT)) || ((playerBall.px < 0)))) || ((playerBall.px > SCREENWIDTH)))){
levelLost();
};
if (levelRunning){
if ((((playerBall.py <= SCREENHEIGHT)) && ((playerBall.py >= 0)))){
_local4 = returnGridPos(true, playerBall.px);
_local5 = returnGridPos(false, playerBall.py);
checkCoinCollisions(_local4, _local5);
if (_local5 >= 1){
checkCoinCollisions(_local4, (_local5 - 1));
};
if (_local5 < 23){
checkCoinCollisions(_local4, (_local5 + 1));
};
if (_local4 >= 1){
checkCoinCollisions((_local4 - 1), _local5);
};
if (_local4 < 12){
checkCoinCollisions((_local4 + 1), _local5);
};
};
timeTick++;
if (timeTick == 4){
levelTimeElapsed = (levelTimeElapsed + 0.1);
timeTick = 0;
};
timeDisplay.text = levelTimeElapsed.toFixed(1);
timeDisplay.setTextFormat(displayFormat);
APEngine.step();
APEngine.paint();
_local2 = moveBrickPos1.length;
_local3 = 0;
while (_local3 < _local2) {
if (brickGrid[moveBrickPos1[_local3]][moveBrickPos2[_local3]].moving){
brickGrid[moveBrickPos1[_local3]][moveBrickPos2[_local3]].moveDown();
};
if (!brickGrid[moveBrickPos1[_local3]][moveBrickPos2[_local3]].moving){
_local6 = brickGrid[moveBrickPos1[_local3]][moveBrickPos2[_local3]].typeOfBrick;
brickGrid[moveBrickPos1[_local3]][moveBrickPos2[_local3]].itemPosition1 = (brickGrid[moveBrickPos1[_local3]][moveBrickPos2[_local3]].itemPosition1 + _local6);
brickGrid[moveBrickPos1[_local3]][moveBrickPos2[_local3]].bouncePad.itemPosition1 = (brickGrid[moveBrickPos1[_local3]][moveBrickPos2[_local3]].bouncePad.itemPosition1 + _local6);
if ((moveBrickPos1[_local3] + _local6) <= 23){
if (brickGrid[(moveBrickPos1[_local3] + _local6)][moveBrickPos2[_local3]] != null){
if (playFx){
brickBreakSound.play();
};
addBlowedUpBrick(brickGrid[(moveBrickPos1[_local3] + _local6)][moveBrickPos2[_local3]].typeOfBrick, (moveBrickPos1[_local3] + _local6), moveBrickPos2[_local3]);
apeGroup.removeParticle(brickGrid[(moveBrickPos1[_local3] + _local6)][moveBrickPos2[_local3]].bouncePad);
apeGroup.removeParticle(brickGrid[(moveBrickPos1[_local3] + _local6)][moveBrickPos2[_local3]]);
delete brickGrid[(moveBrickPos1[_local3] + _local6)][moveBrickPos2[_local3]];
};
brickGrid[(moveBrickPos1[_local3] + _local6)][moveBrickPos2[_local3]] = brickGrid[moveBrickPos1[_local3]][moveBrickPos2[_local3]];
} else {
apeGroup.removeParticle(brickGrid[moveBrickPos1[_local3]][moveBrickPos2[_local3]].bouncePad);
apeGroup.removeParticle(brickGrid[moveBrickPos1[_local3]][moveBrickPos2[_local3]]);
};
brickGrid[moveBrickPos1[_local3]][moveBrickPos2[_local3]] = null;
moveBrickPos1.splice(_local3, 1);
moveBrickPos2.splice(_local3, 1);
_local2--;
_local3--;
};
_local3++;
};
if (makeBallJump){
jump = playerBall.velocity;
if (addExtraBounce){
jump.y = EXTRAJUMPFORCE;
addExtraBounce = false;
} else {
jump.y = JUMPFORCE;
};
playerBall.velocity = jump;
makeBallJump = false;
};
};
}
private function checkCoinCollisions(_arg1:int, _arg2:int){
if (coinGrid[_arg2][_arg1] != null){
if (coinCollisionDetector.isColliding(coinGrid[_arg2][_arg1], playerBall.displayObject, playerBall.px, playerBall.py, 0)){
collectedCoin(_arg1, _arg2);
};
};
}
private function resumeFromExitMenu(_arg1:MouseEvent){
resumeButton.removeEventListener(MouseEvent.CLICK, resumeFromExitMenu);
reallyExitButton.removeEventListener(MouseEvent.CLICK, exitLevel);
removeChild(resumeButton);
removeChild(reallyExitButton);
removeChild(exitBackdrop);
levelPauseButton.addEventListener(MouseEvent.CLICK, pauseGame);
levelPauseButton.addEventListener(MouseEvent.MOUSE_OVER, changeButtonState);
levelPauseButton.addEventListener(MouseEvent.MOUSE_OUT, changeButtonState);
exitButton.addEventListener(MouseEvent.CLICK, showExitMenu);
if (startScreenShowing){
stage.addEventListener(KeyboardEvent.KEY_DOWN, levelStartKeyCheck);
};
if (endScreenShowing){
stage.addEventListener(KeyboardEvent.KEY_DOWN, levelWonContinue);
};
stage.focus = this;
if (((!(startScreenShowing)) && (!(endScreenShowing)))){
startLevelActivities();
};
}
private function addBlowedUpBrick(_arg1:int, _arg2:int, _arg3:int){
var _local4:*;
switch (_arg1){
case NORMALBRICKTYPE:
_local4 = new NormalBrick();
break;
case DROP1BRICKTYPE:
_local4 = new Drop1Brick();
break;
case DROP2BRICKTYPE:
_local4 = new Drop2Brick();
break;
case DROP3BRICKTYPE:
_local4 = new Drop3Brick();
break;
case BOUNCEBRICKTYPE:
_local4 = new BounceBrick();
break;
case BREAKBRICKTYPE:
_local4 = new BreakBrick();
break;
case CRUMBLEBRICKTYPE:
_local4 = new CrumbleBrick();
break;
case COINTYPE:
_local4 = new CoinClip();
break;
};
_local4.x = ((_arg3 * GRIDWIDTH) + (GRIDWIDTH / 2));
_local4.y = ((_arg2 * GRIDHEIGHT) + (GRIDHEIGHT / 2));
addChild(_local4);
_local4.addEventListener(ClipDoneEvent.CLIPDONE, removeBlowedUpBrick);
_local4.gotoAndPlay("blowUp");
blowedUpBricks.push(_local4);
}
private function endLevelActivities(){
stopLevelActivities();
resetLevelButton.removeEventListener(MouseEvent.CLICK, resetLevel);
sponsorButton.removeEventListener(MouseEvent.CLICK, sponsorButtonClicked);
levelPauseButton.removeEventListener(MouseEvent.CLICK, pauseGame);
levelPauseButton.removeEventListener(MouseEvent.MOUSE_OVER, changeButtonState);
levelPauseButton.removeEventListener(MouseEvent.MOUSE_OUT, changeButtonState);
}
private function startLevel(){
removeChild(messageHeader);
removeChild(messageText);
removeChild(messageCommand);
removeChild(messageBackdrop);
levelRunning = true;
addEventListener(Event.ENTER_FRAME, stepLevel);
stage.addEventListener(KeyboardEvent.KEY_DOWN, levelKeyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, levelKeyReleased);
levelPauseButton.addEventListener(MouseEvent.CLICK, pauseGame);
levelPauseButton.addEventListener(MouseEvent.MOUSE_OVER, changeButtonState);
levelPauseButton.addEventListener(MouseEvent.MOUSE_OUT, changeButtonState);
resetLevelButton.addEventListener(MouseEvent.CLICK, resetLevel);
stage.focus = this;
}
private function stopLevelActivities(){
if (levelRunning){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, levelKeyPressed);
stage.removeEventListener(KeyboardEvent.KEY_UP, levelKeyReleased);
levelRunning = false;
removeEventListener(Event.ENTER_FRAME, stepLevel);
};
}
private function levelWon(){
var _local1:Number;
endLevelActivities();
_local1 = Math.round(((currentLevel * 100) / levelTimeElapsed));
levelPoints = ((100 + (currentLevel * 10)) + _local1);
messageBackdrop.x = 240;
messageBackdrop.y = 240;
addChild(messageBackdrop);
messageHeader.x = 114;
messageHeader.y = 125.5;
messageHeader.htmlText = "Level Cleared!";
messageHeader.setTextFormat(messageHeaderFormat);
messageText.x = 125;
messageText.y = 186;
messageTextFormat.align = "left";
messageText.htmlText = (((((((((("Previous Score: " + String(currentScore)) + "<br>") + "Level Bonus: ") + String((100 + (currentLevel * 10)))) + "<br>") + "Time Bonus: ") + String(_local1)) + "<br><br>") + "New Score: ") + String((levelPoints + currentScore)));
messageText.setTextFormat(messageTextFormat);
messageCommand.x = 114;
messageCommand.y = 328;
messageCommand.htmlText = "Press Space to Continue";
messageCommand.setTextFormat(messageCommandFormat);
addChild(messageHeader);
addChild(messageText);
addChild(messageCommand);
if (playFx){
winSound.play();
};
endScreenShowing = true;
stage.addEventListener(KeyboardEvent.KEY_DOWN, levelWonContinue);
}
private function levelKeyReleased(_arg1:KeyboardEvent){
if (levelRunning){
switch (_arg1.keyCode){
case Keyboard.LEFT:
if (moveLeftAdded){
APEngine.removeForce(moveLeft);
moveLeftAdded = false;
};
break;
case Keyboard.RIGHT:
if (moveRightAdded){
APEngine.removeForce(moveRight);
moveRightAdded = false;
};
break;
};
};
}
private function changeButtonState(_arg1:MouseEvent){
if (_arg1.target.currentLabel == "up"){
_arg1.target.gotoAndStop("over");
} else {
if (_arg1.target.currentLabel == "upOff"){
_arg1.target.gotoAndStop("overOff");
} else {
if (_arg1.target.currentLabel == "over"){
_arg1.target.gotoAndStop("up");
} else {
if (_arg1.target.currentLabel == "overOff"){
_arg1.target.gotoAndStop("upOff");
};
};
};
};
}
public function get levelTime():Number{
return (levelTimeElapsed);
}
public function set fxStatus(_arg1){
playFx = _arg1;
}
private function levelLost(){
endLevelActivities();
exitButton.removeEventListener(MouseEvent.CLICK, showExitMenu);
dispatchEvent(new LevelEvent(LevelEvent.RESETLEVEL));
}
private function startBrickMovement(_arg1:int, _arg2:int){
brickGrid[_arg1][_arg2].destination = (((_arg1 + brickGrid[_arg1][_arg2].typeOfBrick) * GRIDHEIGHT) + (GRIDHEIGHT / 2));
brickGrid[_arg1][_arg2].moving = true;
moveBrickPos1.push(_arg1);
moveBrickPos2.push(_arg2);
}
private function exitLevel(_arg1:MouseEvent){
resumeButton.removeEventListener(MouseEvent.CLICK, resumeFromExitMenu);
reallyExitButton.removeEventListener(MouseEvent.CLICK, exitLevel);
dispatchEvent(new LevelEvent(LevelEvent.EXITLEVEL));
}
private function pauseGame(_arg1:MouseEvent){
if (levelRunning){
stopLevelActivities();
levelPauseButton.gotoAndStop("overOff");
} else {
startLevelActivities();
stage.focus = this;
levelPauseButton.gotoAndStop("over");
};
}
public function set levelScore(_arg1:int){
currentScore = _arg1;
}
public function init(){
var _local1:int;
var _local2:int;
switch (currentLevel){
case 8:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 7, 0, 7, 0, 7, 0, 7, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 7, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 7, 0, 7, 0, 7, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 7, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 7, 0, 7, 0, 7, 0, 7, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 1:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 9, 0, 9, 0, 9, 0, 9, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 7, 0, 7, 0, 7, 0, 7, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 9, 0, 9, 0, 9, 0, 9, 0, 0, 9, 0);
layoutGrid[20] = new Array(0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 7, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 2:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 7, 1, 7, 0, 0, 0, 0, 7, 1, 7, 0);
layoutGrid[11] = new Array(0, 0, 9, 0, 0, 0, 0, 0, 0, 9, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 3:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 9, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 4, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 4:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 9, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 7, 0, 0, 0, 0, 7, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 7, 0, 9, 7, 0, 7, 0, 9, 0, 0);
layoutGrid[8] = new Array(0, 9, 7, 0, 0, 7, 0, 7, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 7, 0, 0, 7, 9, 7, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 7, 0, 0, 7, 0, 7, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 7, 0, 9, 7, 0, 7, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 7, 0, 0, 7, 9, 7, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 9, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 7, 4, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 11:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 9, 0, 0, 9, 0, 0, 9, 0, 0, 9, 0);
layoutGrid[6] = new Array(0, 3, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 9, 0, 0, 9, 0, 0, 9, 0, 0, 9, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 9, 0, 0, 9, 0, 0, 9, 0, 0, 9, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 9, 0, 0, 9, 0, 0, 9, 0, 0, 9, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 42:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 9, 0);
layoutGrid[7] = new Array(0, 5, 7, 0, 0, 5, 0, 0, 0, 0, 5, 0);
layoutGrid[8] = new Array(0, 9, 7, 0, 0, 0, 0, 0, 0, 0, 9, 0);
layoutGrid[9] = new Array(0, 7, 7, 0, 0, 0, 0, 0, 0, 0, 5, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 12:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 9, 0, 0, 9, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 9, 0, 0, 0, 0, 9, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 9, 0, 0, 0, 0, 0, 0, 9, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 5:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 9, 5, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 7, 9, 7, 7, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 5, 0, 0, 0, 9, 0, 0, 0);
layoutGrid[14] = new Array(0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 13:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 7, 0, 7, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 7, 0, 0, 0, 7, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 7, 0, 0, 0, 0, 0, 7, 0, 0, 0);
layoutGrid[9] = new Array(0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 7, 0, 0, 7, 0, 7, 0, 0, 7, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 14:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 7, 0, 9, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 9, 0, 7, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 7, 0, 9, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 9, 0, 7, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 9, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 7, 0, 0, 0, 9, 0, 7, 0, 9, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 6:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 9, 0, 0, 9, 0, 0, 9, 0, 0, 9, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 5, 0, 0, 5, 0, 0, 5, 0, 0, 5, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 9, 0, 0, 9, 0, 0, 9, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 5, 0, 0, 5, 0, 0, 5, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 9, 0, 0, 9, 0, 0, 9, 0, 0, 9, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 5, 0, 0, 5, 0, 0, 5, 0, 0, 5, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 16:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 9, 0, 0, 9, 0, 0, 9, 0, 0, 0);
layoutGrid[9] = new Array(0, 5, 5, 0, 0, 5, 0, 0, 5, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 9, 0, 0, 9, 0, 0, 9, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 36:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 9, 0, 7, 0, 9, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 5, 7, 3, 3, 3, 2, 1, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 7, 0, 9, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 7, 9, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 18:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 9, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 9, 0, 5, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 0, 9, 5, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 5, 9, 0, 9, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 19:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 2, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 9, 0, 9, 0, 9, 0, 9, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 6, 0, 6, 0, 6, 0, 6, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 9, 0, 9, 0, 9, 0, 9, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 20:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0);
layoutGrid[11] = new Array(0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0);
layoutGrid[12] = new Array(0, 0, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 28:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 7, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 7, 0, 9, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 7, 0, 9, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 9, 0, 3, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 7, 0, 9, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 9, 0, 7, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 9, 0, 7, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 9, 0, 7, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 9, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 47:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 9, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 5, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 15:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 5, 9, 9, 9, 9, 9, 9, 9, 9, 5, 0);
layoutGrid[5] = new Array(0, 5, 9, 9, 9, 9, 9, 9, 9, 9, 5, 0);
layoutGrid[6] = new Array(0, 5, 9, 9, 9, 9, 9, 9, 9, 9, 5, 0);
layoutGrid[7] = new Array(0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 5, 9, 5, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 5, 9, 5, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 5, 9, 5, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 5, 9, 5, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 5, 9, 5, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 5, 9, 5, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 5, 9, 5, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 5, 9, 5, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 5, 9, 5, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 5, 9, 5, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 5, 0, 9, 0, 5, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 5, 0, 0, 9, 0, 0, 5, 0, 0, 0);
layoutGrid[20] = new Array(0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 25:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 9, 0, 0, 0, 9, 9, 0, 0, 0, 9, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 7, 0, 0, 0, 7, 7, 0, 0, 0, 7, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 9, 0, 0, 0, 9, 9, 0, 0, 0, 9, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 5, 0, 0, 0, 5, 5, 0, 0, 0, 5, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 21:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0);
layoutGrid[9] = new Array(0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 0);
layoutGrid[10] = new Array(0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 0);
layoutGrid[11] = new Array(0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 0);
layoutGrid[12] = new Array(0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0);
layoutGrid[13] = new Array(0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 27:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0);
layoutGrid[5] = new Array(0, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 0);
layoutGrid[11] = new Array(0, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0);
layoutGrid[17] = new Array(0, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 43:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 9, 0, 0, 0, 9, 9, 0, 0, 9, 9, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 5, 9, 0, 0, 5, 5, 0, 0, 5, 5, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 9, 0, 0, 9, 0, 0, 9, 0, 0, 9, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 3, 0, 0, 3, 0, 0, 3, 0, 0, 3, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 31:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 7, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 9, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 7, 9, 0, 0, 9, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 7, 0, 0, 7, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 23:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 7, 0, 0, 0, 7, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 7, 0, 0, 7, 0, 7, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 7, 0, 7, 0, 0, 0, 7, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 7, 7, 0, 0, 0, 0, 0, 7, 0, 0);
layoutGrid[15] = new Array(0, 0, 7, 0, 9, 9, 9, 9, 9, 0, 7, 0);
layoutGrid[16] = new Array(0, 0, 0, 9, 9, 9, 9, 9, 9, 9, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 9, 0, 9, 0, 9, 0, 9, 0, 0);
layoutGrid[18] = new Array(0, 7, 7, 7, 6, 7, 5, 7, 6, 7, 7, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 22:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 7, 0);
layoutGrid[5] = new Array(0, 7, 0, 0, 0, 9, 0, 0, 0, 7, 0, 0);
layoutGrid[6] = new Array(0, 0, 7, 0, 0, 9, 0, 0, 7, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 5, 0, 9, 0, 5, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 7, 9, 7, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 9, 0, 9, 0, 9, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 4, 0, 9, 0, 4, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 46:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 7, 9, 7, 9, 7, 9, 7, 9, 7, 9, 0);
layoutGrid[11] = new Array(0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0);
layoutGrid[12] = new Array(0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0);
layoutGrid[13] = new Array(0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 38:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 0);
layoutGrid[6] = new Array(0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 0);
layoutGrid[7] = new Array(0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0);
layoutGrid[12] = new Array(0, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0);
layoutGrid[13] = new Array(0, 0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 7, 0, 4, 0, 4, 0, 4, 0, 7, 0, 0);
layoutGrid[18] = new Array(0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 0);
layoutGrid[19] = new Array(0, 7, 0, 7, 0, 7, 0, 7, 0, 7, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 5, 4, 5, 4, 5, 4, 5, 4, 5, 5, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 34:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 7, 0, 7, 0, 7, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 9, 0, 9, 0, 9, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 4, 0, 4, 0, 4, 0, 4, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 35:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0);
layoutGrid[8] = new Array(0, 9, 0, 0, 0, 9, 9, 0, 0, 0, 9, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 3, 0, 0, 0, 1, 2, 0, 0, 0, 3, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 32:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 5, 9, 0, 0, 0, 0, 0, 0, 5, 0, 0);
layoutGrid[12] = new Array(0, 0, 5, 0, 0, 0, 0, 0, 5, 9, 5, 0);
layoutGrid[13] = new Array(0, 0, 0, 5, 0, 0, 0, 0, 5, 9, 5, 0);
layoutGrid[14] = new Array(0, 0, 0, 5, 0, 0, 0, 0, 5, 9, 5, 0);
layoutGrid[15] = new Array(0, 0, 0, 5, 5, 5, 0, 0, 0, 5, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 5, 9, 9, 5, 0, 0, 5, 0, 0);
layoutGrid[17] = new Array(0, 0, 5, 9, 9, 9, 9, 5, 0, 5, 0, 0);
layoutGrid[18] = new Array(0, 0, 5, 9, 9, 9, 9, 5, 0, 5, 0, 0);
layoutGrid[19] = new Array(0, 0, 5, 9, 9, 9, 9, 5, 0, 5, 0, 0);
layoutGrid[20] = new Array(0, 0, 5, 9, 9, 9, 9, 5, 0, 5, 0, 0);
layoutGrid[21] = new Array(0, 0, 5, 9, 9, 9, 9, 5, 0, 5, 0, 0);
layoutGrid[22] = new Array(0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 17:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 9, 0, 0, 9, 0, 0, 9, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 3, 0, 0, 1, 0, 0, 2, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 9, 0, 0, 9, 0, 0, 9, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 9, 0, 0, 9, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 9, 0, 0, 0, 0, 0, 9, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 37:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 30:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 7, 7, 7, 7, 7, 0, 0, 9, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 7, 7, 7, 7, 7, 7, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 45:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 9, 0, 0, 0, 9, 0, 0, 0, 9, 0, 0);
layoutGrid[8] = new Array(0, 5, 0, 0, 0, 5, 0, 0, 0, 5, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 5, 0, 0, 0, 5, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 5, 0, 0, 0, 5, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 9, 0, 0, 0, 9, 0, 0, 0, 9, 0);
layoutGrid[23] = new Array(0, 0, 5, 0, 0, 0, 5, 0, 0, 0, 5, 0);
break;
case 24:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 7, 9, 9, 9, 9, 9, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 7, 9, 9, 9, 9, 9, 0);
layoutGrid[13] = new Array(0, 3, 2, 1, 5, 7, 7, 7, 7, 7, 7, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 33:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 9, 0, 0, 0, 9, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 7, 0, 7, 0, 0, 0, 7, 0, 7, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 7, 0, 9, 0, 7, 0, 7, 0, 9, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 7, 0, 7, 0, 9, 0, 7, 0, 7, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 7, 0, 9, 0, 7, 0, 7, 0, 9, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 7, 0, 7, 0, 9, 0, 7, 0, 7, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 7, 0, 9, 0, 7, 0, 7, 0, 9, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 7, 6, 7, 0, 0, 0, 7, 6, 7, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 29:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0);
layoutGrid[9] = new Array(0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0);
layoutGrid[10] = new Array(0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 44:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 9, 0, 0, 9, 9, 0, 0, 9, 9, 9, 0);
layoutGrid[14] = new Array(0, 7, 9, 9, 0, 3, 9, 9, 0, 0, 7, 0);
layoutGrid[15] = new Array(0, 0, 1, 2, 2, 3, 3, 2, 2, 1, 0, 0);
layoutGrid[16] = new Array(0, 0, 9, 0, 0, 0, 0, 0, 0, 9, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 9, 0, 0, 0, 0, 9, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 9, 0, 0, 9, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 40:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 9, 0, 0, 0, 0, 0, 0, 9, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 7, 0, 0, 0, 0, 0, 0, 7, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 9, 0, 0, 0, 0, 0, 0, 9, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 5, 7, 5, 0, 0, 0, 0, 5, 7, 5, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 9, 0, 0, 0, 0, 0, 0, 9, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 4, 7, 0, 0, 0, 0, 0, 0, 7, 4, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 9, 0, 0, 0, 0, 0, 0, 9, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 5, 7, 5, 0, 4, 4, 0, 5, 7, 5, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 10:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 7, 0, 9, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 7, 0, 9, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 9, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 7, 0, 9, 0, 0, 0);
layoutGrid[10] = new Array(0, 5, 0, 9, 0, 0, 0, 7, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 6, 0, 0, 0, 0, 0, 7, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 6, 0, 9, 0, 0, 0, 5, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 6, 0, 9, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 6, 0, 9, 0, 0);
layoutGrid[17] = new Array(0, 0, 9, 0, 0, 0, 0, 0, 6, 0, 0, 0);
layoutGrid[18] = new Array(0, 5, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0);
layoutGrid[19] = new Array(0, 0, 5, 0, 9, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 5, 0, 9, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0);
break;
case 49:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 9, 0, 0, 0, 9, 0, 0, 0, 0, 9, 0);
layoutGrid[6] = new Array(0, 5, 7, 7, 7, 7, 7, 7, 7, 7, 5, 0);
layoutGrid[7] = new Array(0, 3, 7, 9, 0, 9, 0, 9, 0, 7, 3, 0);
layoutGrid[8] = new Array(0, 0, 7, 0, 0, 0, 0, 0, 0, 7, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 1, 0, 2, 0, 1, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 9, 0, 0, 0, 9, 0, 0, 0, 0, 9, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 39:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 0);
layoutGrid[7] = new Array(0, 6, 0, 6, 0, 6, 0, 6, 0, 6, 0, 0);
layoutGrid[8] = new Array(0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0);
layoutGrid[13] = new Array(0, 0, 6, 0, 6, 0, 6, 0, 6, 0, 6, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 0);
layoutGrid[22] = new Array(0, 6, 0, 6, 0, 6, 0, 6, 0, 6, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 9:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0);
layoutGrid[9] = new Array(0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0);
layoutGrid[10] = new Array(0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0);
layoutGrid[11] = new Array(0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0);
layoutGrid[12] = new Array(0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 0);
layoutGrid[13] = new Array(0, 6, 0, 6, 0, 6, 0, 6, 0, 6, 0, 0);
layoutGrid[14] = new Array(0, 0, 6, 0, 6, 0, 6, 0, 6, 0, 6, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 48:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 5, 5, 5, 5, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 5, 0, 0, 0, 0, 5, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 5, 0, 0, 9, 9, 0, 0, 5, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 9, 9, 9, 9, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 5, 0, 9, 9, 9, 9, 9, 9, 0, 5, 0);
layoutGrid[13] = new Array(0, 5, 0, 9, 9, 9, 9, 9, 9, 0, 5, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 9, 9, 9, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 6, 0, 0, 9, 9, 0, 0, 6, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 6, 0, 0, 0, 0, 6, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 6, 6, 6, 6, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 7:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 0);
layoutGrid[11] = new Array(0, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0, 0);
layoutGrid[12] = new Array(0, 0, 9, 0, 0, 9, 0, 0, 9, 0, 0, 0);
layoutGrid[13] = new Array(0, 9, 0, 0, 9, 0, 0, 9, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 41:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0);
layoutGrid[7] = new Array(0, 6, 9, 9, 9, 9, 9, 9, 9, 9, 6, 0);
layoutGrid[8] = new Array(0, 0, 6, 9, 9, 9, 9, 9, 9, 6, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 6, 9, 9, 9, 9, 6, 0, 0, 0);
layoutGrid[10] = new Array(0, 0, 0, 0, 6, 9, 9, 6, 0, 0, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 6, 9, 9, 6, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 6, 9, 9, 6, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 6, 0, 0, 6, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 6, 0, 9, 0, 0, 6, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 6, 0, 0, 0, 9, 0, 0, 6, 0, 0);
layoutGrid[16] = new Array(0, 6, 0, 0, 9, 9, 9, 9, 0, 0, 6, 0);
layoutGrid[17] = new Array(0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 26:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[5] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[7] = new Array(0, 6, 7, 5, 7, 9, 7, 5, 7, 9, 7, 0);
layoutGrid[8] = new Array(0, 9, 7, 9, 7, 9, 7, 9, 7, 9, 7, 0);
layoutGrid[9] = new Array(0, 9, 7, 9, 7, 9, 7, 9, 7, 9, 7, 0);
layoutGrid[10] = new Array(0, 9, 7, 9, 7, 9, 7, 9, 7, 9, 7, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 9, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0);
layoutGrid[22] = new Array(0, 6, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
case 50:
layoutGrid[0] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[1] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[2] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[3] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[4] = new Array(0, 0, 0, 0, 9, 0, 9, 0, 9, 0, 9, 0);
layoutGrid[5] = new Array(0, 3, 7, 0, 5, 5, 5, 5, 5, 5, 5, 0);
layoutGrid[6] = new Array(0, 0, 0, 0, 0, 9, 0, 9, 0, 9, 0, 0);
layoutGrid[7] = new Array(0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[8] = new Array(0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 0, 0);
layoutGrid[9] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[10] = new Array(0, 9, 0, 0, 0, 6, 0, 6, 0, 6, 0, 0);
layoutGrid[11] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[12] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[13] = new Array(0, 0, 0, 5, 2, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[14] = new Array(0, 0, 0, 4, 9, 0, 0, 9, 0, 0, 0, 0);
layoutGrid[15] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[16] = new Array(0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[17] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[18] = new Array(0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[19] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[20] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[21] = new Array(0, 9, 0, 9, 0, 0, 0, 0, 0, 4, 0, 0);
layoutGrid[22] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
layoutGrid[23] = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
break;
};
APEngine.init((2 / 5));
APEngine.container = this;
APEngine.addForce(gravity);
apeGroup = new Group();
apeGroup.collideInternal = true;
playerBall = new CircleParticle(BALLXSTART, BALLYSTART, BALLRADIUS, false, BALLMASS, BALLBOUNCE, BALLFRICTION);
apeGroup.addParticle(playerBall);
playerBall.addEventListener(CollisionEvent.COLLIDE, checkCollision);
playerBall.setDisplay(ballSkin);
leftWall = new RectangleParticle(19, 240, WALLWIDTH, WALLHEIGHT, WALLROTATION, true, WALLMASS, WALLBOUNCE, WALLFRICTION);
apeGroup.addParticle(leftWall);
leftWall.setDisplay(leftWallSkin);
leftWall.sprite.name = "leftwall";
rightWall = new RectangleParticle(461, 240, WALLWIDTH, WALLHEIGHT, WALLROTATION, true, WALLMASS, WALLBOUNCE, WALLFRICTION);
apeGroup.addParticle(rightWall);
rightWall.setDisplay(rightWallSkin);
rightWall.sprite.name = "rightwall";
translateLayoutGrid();
displayFormat.font = new Prototype_EMBED().fontName;
displayFormat.color = 0xFFFFFF;
displayFormat.size = 16;
displayFormat.align = "left";
levelDisplay.x = 40;
levelDisplay.y = 7;
levelDisplay.width = 100;
levelDisplay.height = 20;
levelDisplay.embedFonts = true;
levelDisplay.selectable = false;
levelDisplay.text = ("Lvl " + String(currentLevel));
levelDisplay.setTextFormat(displayFormat);
timeDisplay.x = 99;
timeDisplay.y = 7;
timeDisplay.width = 100;
timeDisplay.height = 20;
timeDisplay.embedFonts = true;
timeDisplay.selectable = false;
timeDisplay.text = levelTimeElapsed.toFixed(1);
timeDisplay.setTextFormat(displayFormat);
scoreDisplay.x = 145;
scoreDisplay.y = 7;
scoreDisplay.width = 100;
scoreDisplay.height = 20;
scoreDisplay.embedFonts = true;
scoreDisplay.selectable = false;
scoreDisplay.text = ("Score " + String(currentScore));
scoreDisplay.setTextFormat(displayFormat);
messageBackdrop.x = 240;
messageBackdrop.y = 240;
messageHeaderFormat.font = new Prototype_EMBED().fontName;
messageHeaderFormat.color = 0;
messageHeaderFormat.size = 38;
messageHeaderFormat.align = "center";
messageTextFormat.font = new Prototype_EMBED().fontName;
messageTextFormat.color = 0;
messageTextFormat.size = 18;
messageTextFormat.align = "center";
messageCommandFormat.font = new Prototype_EMBED().fontName;
messageCommandFormat.color = 0;
messageCommandFormat.size = 22;
messageCommandFormat.align = "center";
messageHeader.x = 114;
messageHeader.y = 125.5;
messageHeader.width = 250;
messageHeader.height = 200;
messageHeader.embedFonts = true;
messageHeader.selectable = false;
messageHeader.multiline = true;
messageHeader.htmlText = ("Level " + String(currentLevel));
messageHeader.setTextFormat(messageHeaderFormat);
messageText.x = 114;
messageText.y = 186;
messageText.width = 250;
messageText.height = 240;
messageText.embedFonts = true;
messageText.selectable = false;
messageText.multiline = true;
switch (currentLevel){
case 1:
messageText.htmlText = "Use the left and right arrow <br> keys to control Dropple. <br><br> Collect all the coins <br> to advance.";
break;
case 2:
messageText.htmlText = "Bricks with arrows facing <br> down drop when you land <br> on them.";
break;
case 3:
messageText.htmlText = "Green bricks are extra <br> bouncy.";
break;
case 4:
messageText.htmlText = "Your game is saved <br> automatically as you <br> progress.<br>Resume a previous game <br> by selecting Resume Game <br> from the title screen.";
break;
case 5:
messageText.htmlText = "Glass bricks break when you <br> bounce on them.";
break;
case 6:
messageText.htmlText = "There are 50 levels in all. <br><br> Some of them will <br> really test your sanity. <br><br> You've been warned!";
break;
case 9:
messageText.htmlText = "Stone bricks crack on the <br> first bounce, and break <br> on the second bounce.";
break;
case 50:
messageText.htmlText = "Last one! <br><br> But it's a doozy...";
break;
default:
messageText.htmlText = "Collect all the coins!";
break;
};
messageText.setTextFormat(messageTextFormat);
messageCommand.x = 114;
messageCommand.y = 328;
messageCommand.width = 250;
messageCommand.height = 200;
messageCommand.embedFonts = true;
messageCommand.selectable = false;
messageCommand.multiline = true;
messageCommand.htmlText = "Press Space to Start!";
messageCommand.setTextFormat(messageCommandFormat);
APEngine.addGroup(apeGroup);
APEngine.step();
APEngine.paint();
_local1 = 0;
while (_local1 < NUMGRIDSY) {
_local2 = 0;
while (_local2 < NUMGRIDSX) {
if (coinGrid[_local1][_local2] != null){
setChildIndex(coinGrid[_local1][_local2], (numChildren - 1));
};
_local2++;
};
_local1++;
};
addChild(messageBackdrop);
addChild(messageHeader);
addChild(messageText);
addChild(messageCommand);
addChild(levelDisplay);
addChild(timeDisplay);
addChild(scoreDisplay);
sponsorButton.x = 264;
sponsorButton.y = 10;
addChild(sponsorButton);
sponsorButton.addEventListener(MouseEvent.CLICK, sponsorButtonClicked);
resetLevelButton.x = 304;
resetLevelButton.y = 9;
addChild(resetLevelButton);
levelPauseButton.x = 360;
levelPauseButton.y = 9;
addChild(levelPauseButton);
exitButton.x = 336;
exitButton.y = 8;
addChild(exitButton);
levelPauseButton.buttonMode = true;
levelPauseButton.useHandCursor = true;
exitButton.buttonMode = true;
exitButton.useHandCursor = true;
}
private function checkCollision(_arg1:CollisionEvent){
var _local2:*;
_local2 = _arg1.collidingItem.sprite.name;
switch (_local2){
case "bounceNormal":
makeBallJump = true;
if (playFx){
ballBounceSound.play();
};
break;
case "bounceDrop1":
makeBallJump = true;
if (!brickGrid[_arg1.collidingItem.itemPosition1][_arg1.collidingItem.itemPosition2].moving){
startBrickMovement(_arg1.collidingItem.itemPosition1, _arg1.collidingItem.itemPosition2);
if (playFx){
brickDropSound.play();
};
};
if (playFx){
ballBounceSound.play();
};
break;
case "bounceDrop2":
makeBallJump = true;
if (!brickGrid[_arg1.collidingItem.itemPosition1][_arg1.collidingItem.itemPosition2].moving){
startBrickMovement(_arg1.collidingItem.itemPosition1, _arg1.collidingItem.itemPosition2);
if (playFx){
brickDropSound.play();
};
};
if (playFx){
ballBounceSound.play();
};
break;
case "bounceDrop3":
makeBallJump = true;
if (!brickGrid[_arg1.collidingItem.itemPosition1][_arg1.collidingItem.itemPosition2].moving){
startBrickMovement(_arg1.collidingItem.itemPosition1, _arg1.collidingItem.itemPosition2);
if (playFx){
brickDropSound.play();
};
};
if (playFx){
ballBounceSound.play();
};
break;
case "extraBouncyPad":
makeBallJump = true;
addExtraBounce = true;
if (playFx){
ballHighBounceSound.play();
};
break;
case "breakPad":
makeBallJump = true;
addBlowedUpBrick(brickGrid[_arg1.collidingItem.itemPosition1][_arg1.collidingItem.itemPosition2].typeOfBrick, _arg1.collidingItem.itemPosition1, _arg1.collidingItem.itemPosition2);
apeGroup.removeParticle(brickGrid[_arg1.collidingItem.itemPosition1][_arg1.collidingItem.itemPosition2].bouncePad);
apeGroup.removeParticle(brickGrid[_arg1.collidingItem.itemPosition1][_arg1.collidingItem.itemPosition2]);
delete brickGrid[_arg1.collidingItem.itemPosition1][_arg1.collidingItem.itemPosition2];
if (playFx){
ballBounceSound.play();
};
if (playFx){
brickBreakSound.play();
};
break;
case "crumblePad":
makeBallJump = true;
if (playFx){
ballBounceSound.play();
};
brickGrid[_arg1.collidingItem.itemPosition1][_arg1.collidingItem.itemPosition2].breakNum--;
if (brickGrid[_arg1.collidingItem.itemPosition1][_arg1.collidingItem.itemPosition2].breakNum <= 0){
addBlowedUpBrick(brickGrid[_arg1.collidingItem.itemPosition1][_arg1.collidingItem.itemPosition2].typeOfBrick, _arg1.collidingItem.itemPosition1, _arg1.collidingItem.itemPosition2);
apeGroup.removeParticle(brickGrid[_arg1.collidingItem.itemPosition1][_arg1.collidingItem.itemPosition2].bouncePad);
apeGroup.removeParticle(brickGrid[_arg1.collidingItem.itemPosition1][_arg1.collidingItem.itemPosition2]);
delete brickGrid[_arg1.collidingItem.itemPosition1][_arg1.collidingItem.itemPosition2];
if (playFx){
brickBreakSound.play();
};
} else {
brickGrid[_arg1.collidingItem.itemPosition1][_arg1.collidingItem.itemPosition2].displayObject.gotoAndStop((brickGrid[_arg1.collidingItem.itemPosition1][_arg1.collidingItem.itemPosition2].displayObject.currentFrame + 1));
if (playFx){
brickCrackSound.play();
};
};
break;
};
}
public function set levelTime(_arg1:Number){
levelTimeElapsed = _arg1;
}
private function removeBlowedUpBrick(_arg1:ClipDoneEvent){
blowedUpBricks[0].removeEventListener(ClipDoneEvent.CLIPDONE, removeBlowedUpBrick);
removeChild(blowedUpBricks[0]);
delete blowedUpBricks[0];
blowedUpBricks.shift();
}
public function clearLevel(){
var _local1:int;
var _local2:int;
playerBall.removeEventListener(CollisionEvent.COLLIDE, checkCollision);
_local1 = 0;
while (_local1 < NUMGRIDSY) {
_local2 = 0;
while (_local2 < NUMGRIDSX) {
delete layoutGrid[_local1][_local2];
if (brickGrid[_local1][_local2] != null){
apeGroup.removeParticle(brickGrid[_local1][_local2]);
delete brickGrid[_local1][_local2];
};
if (coinGrid[_local1][_local2] != null){
removeChild(coinGrid[_local1][_local2]);
};
delete coinGrid[_local1][_local2];
_local2++;
};
delete layoutGrid[_local1];
delete brickGrid[_local1];
delete coinGrid[_local1];
_local1++;
};
apeGroup.removeParticle(leftWall);
apeGroup.removeParticle(rightWall);
apeGroup.removeParticle(playerBall);
if (moveLeftAdded){
APEngine.removeForce(moveLeft);
moveLeftAdded = false;
};
if (moveRightAdded){
APEngine.removeForce(moveRight);
moveRightAdded = false;
};
APEngine.removeGroup(apeGroup);
APEngine.removeAllForce();
}
private function levelWonContinue(_arg1:KeyboardEvent){
if (_arg1.keyCode == 32){
currentScore = (currentScore + levelPoints);
endScreenShowing = false;
exitButton.removeEventListener(MouseEvent.CLICK, showExitMenu);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, levelWonContinue);
dispatchEvent(new LevelEvent(LevelEvent.LEVELWON));
};
}
private function levelStartKeyCheck(_arg1:KeyboardEvent){
if (_arg1.keyCode == 32){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, levelStartKeyCheck);
startScreenShowing = false;
startLevel();
};
}
public function get fxStatus():Boolean{
return (playFx);
}
public function get levelScore():int{
return (currentScore);
}
private function levelKeyPressed(_arg1:KeyboardEvent){
if (levelRunning){
switch (_arg1.keyCode){
case Keyboard.LEFT:
if (!moveLeftAdded){
APEngine.addForce(moveLeft);
moveLeftAdded = true;
};
break;
case Keyboard.RIGHT:
if (!moveRightAdded){
APEngine.addForce(moveRight);
moveRightAdded = true;
};
break;
};
};
}
private function collectedCoin(_arg1:int, _arg2:int){
if (playFx){
coinCollectSound.play();
};
addBlowedUpBrick(COINTYPE, _arg2, _arg1);
removeChild(coinGrid[_arg2][_arg1]);
delete coinGrid[_arg2][_arg1];
coinsCollected++;
if (coinsCollected >= numOfCoins){
levelWon();
};
}
private function resetLevel(_arg1:MouseEvent){
levelLost();
}
private function sponsorButtonClicked(_arg1:MouseEvent){
navigateToURL(PLAYMOREURL, "_blank");
}
private function showExitMenu(_arg1:MouseEvent){
levelPauseButton.removeEventListener(MouseEvent.CLICK, pauseGame);
levelPauseButton.removeEventListener(MouseEvent.MOUSE_OVER, changeButtonState);
levelPauseButton.removeEventListener(MouseEvent.MOUSE_OUT, changeButtonState);
exitButton.removeEventListener(MouseEvent.CLICK, showExitMenu);
if (startScreenShowing){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, levelStartKeyCheck);
};
if (endScreenShowing){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, levelWonContinue);
};
stopLevelActivities();
exitBackdrop.x = 240;
exitBackdrop.y = 240;
addChild(exitBackdrop);
resumeButton.x = 121;
resumeButton.y = 259;
addChild(resumeButton);
reallyExitButton.x = 259;
reallyExitButton.y = 259;
addChild(reallyExitButton);
resumeButton.addEventListener(MouseEvent.CLICK, resumeFromExitMenu);
reallyExitButton.addEventListener(MouseEvent.CLICK, exitLevel);
}
private function startLevelActivities(){
if (!levelRunning){
levelRunning = true;
addEventListener(Event.ENTER_FRAME, stepLevel);
stage.addEventListener(KeyboardEvent.KEY_DOWN, levelKeyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, levelKeyReleased);
};
}
private function returnGridPos(_arg1:Boolean, _arg2:Number):int{
if (_arg1){
return (int(((_arg2 / GRIDWIDTH) - ((_arg2 % GRIDWIDTH) / GRIDWIDTH))));
};
return (int(((_arg2 / GRIDHEIGHT) - ((_arg2 % GRIDHEIGHT) / GRIDHEIGHT))));
}
private function translateLayoutGrid(){
var _local1:MovieClip;
var _local2:int;
var _local3:int;
_local2 = (NUMGRIDSY - 1);
while (_local2 >= 0) {
_local3 = 0;
while (_local3 < NUMGRIDSX) {
switch (layoutGrid[_local2][_local3]){
case 0:
brickGrid[_local2][_local3] = null;
coinGrid[_local2][_local3] = null;
break;
case NORMALBRICKTYPE:
_local1 = new NormalBrick();
brickGrid[_local2][_local3] = new Brick(NORMALBRICKTYPE, ((_local3 * GRIDWIDTH) + (GRIDWIDTH / 2)), ((_local2 * GRIDHEIGHT) + (GRIDHEIGHT / 2)), BRICKWIDTH, BRICKHEIGHT, BRICKROTATION, true, BRICKMASS, BRICKBOUNCE, BRICKFRICTION);
apeGroup.addParticle(brickGrid[_local2][_local3]);
apeGroup.addParticle(brickGrid[_local2][_local3].bouncePad);
brickGrid[_local2][_local3].setDisplay(_local1);
brickGrid[_local2][_local3].sprite.name = "normalBrick";
brickGrid[_local2][_local3].bouncePad.sprite.name = "bounceNormal";
brickGrid[_local2][_local3].itemPosition1 = _local2;
brickGrid[_local2][_local3].itemPosition2 = _local3;
brickGrid[_local2][_local3].bouncePad.itemPosition1 = _local2;
brickGrid[_local2][_local3].bouncePad.itemPosition2 = _local3;
break;
case DROP1BRICKTYPE:
_local1 = new Drop1Brick();
brickGrid[_local2][_local3] = new Brick(DROP1BRICKTYPE, ((_local3 * GRIDWIDTH) + (GRIDWIDTH / 2)), ((_local2 * GRIDHEIGHT) + (GRIDHEIGHT / 2)), BRICKWIDTH, BRICKHEIGHT, BRICKROTATION, true, BRICKMASS, BRICKBOUNCE, BRICKFRICTION);
apeGroup.addParticle(brickGrid[_local2][_local3]);
apeGroup.addParticle(brickGrid[_local2][_local3].bouncePad);
brickGrid[_local2][_local3].setDisplay(_local1);
brickGrid[_local2][_local3].sprite.name = "drop1Brick";
brickGrid[_local2][_local3].bouncePad.sprite.name = "bounceDrop1";
brickGrid[_local2][_local3].itemPosition1 = _local2;
brickGrid[_local2][_local3].itemPosition2 = _local3;
brickGrid[_local2][_local3].bouncePad.itemPosition1 = _local2;
brickGrid[_local2][_local3].bouncePad.itemPosition2 = _local3;
break;
case DROP2BRICKTYPE:
_local1 = new Drop2Brick();
brickGrid[_local2][_local3] = new Brick(DROP2BRICKTYPE, ((_local3 * GRIDWIDTH) + (GRIDWIDTH / 2)), ((_local2 * GRIDHEIGHT) + (GRIDHEIGHT / 2)), BRICKWIDTH, BRICKHEIGHT, BRICKROTATION, true, BRICKMASS, BRICKBOUNCE, BRICKFRICTION);
apeGroup.addParticle(brickGrid[_local2][_local3]);
apeGroup.addParticle(brickGrid[_local2][_local3].bouncePad);
brickGrid[_local2][_local3].setDisplay(_local1);
brickGrid[_local2][_local3].sprite.name = "drop2Brick";
brickGrid[_local2][_local3].bouncePad.sprite.name = "bounceDrop2";
brickGrid[_local2][_local3].itemPosition1 = _local2;
brickGrid[_local2][_local3].itemPosition2 = _local3;
brickGrid[_local2][_local3].bouncePad.itemPosition1 = _local2;
brickGrid[_local2][_local3].bouncePad.itemPosition2 = _local3;
break;
case DROP3BRICKTYPE:
_local1 = new Drop3Brick();
brickGrid[_local2][_local3] = new Brick(DROP3BRICKTYPE, ((_local3 * GRIDWIDTH) + (GRIDWIDTH / 2)), ((_local2 * GRIDHEIGHT) + (GRIDHEIGHT / 2)), BRICKWIDTH, BRICKHEIGHT, BRICKROTATION, true, BRICKMASS, BRICKBOUNCE, BRICKFRICTION);
apeGroup.addParticle(brickGrid[_local2][_local3]);
apeGroup.addParticle(brickGrid[_local2][_local3].bouncePad);
brickGrid[_local2][_local3].setDisplay(_local1);
brickGrid[_local2][_local3].sprite.name = "drop3Brick";
brickGrid[_local2][_local3].bouncePad.sprite.name = "bounceDrop3";
brickGrid[_local2][_local3].itemPosition1 = _local2;
brickGrid[_local2][_local3].itemPosition2 = _local3;
brickGrid[_local2][_local3].bouncePad.itemPosition1 = _local2;
brickGrid[_local2][_local3].bouncePad.itemPosition2 = _local3;
break;
case BOUNCEBRICKTYPE:
_local1 = new BounceBrick();
brickGrid[_local2][_local3] = new Brick(BOUNCEBRICKTYPE, ((_local3 * GRIDWIDTH) + (GRIDWIDTH / 2)), ((_local2 * GRIDHEIGHT) + (GRIDHEIGHT / 2)), BRICKWIDTH, BRICKHEIGHT, BRICKROTATION, true, BRICKMASS, BRICKBOUNCE, BRICKFRICTION);
apeGroup.addParticle(brickGrid[_local2][_local3]);
apeGroup.addParticle(brickGrid[_local2][_local3].bouncePad);
brickGrid[_local2][_local3].setDisplay(_local1);
brickGrid[_local2][_local3].sprite.name = "bounceBrick";
brickGrid[_local2][_local3].bouncePad.sprite.name = "extraBouncyPad";
brickGrid[_local2][_local3].itemPosition1 = _local2;
brickGrid[_local2][_local3].itemPosition2 = _local3;
brickGrid[_local2][_local3].bouncePad.itemPosition1 = _local2;
brickGrid[_local2][_local3].bouncePad.itemPosition2 = _local3;
break;
case BREAKBRICKTYPE:
_local1 = new BreakBrick();
brickGrid[_local2][_local3] = new Brick(BREAKBRICKTYPE, ((_local3 * GRIDWIDTH) + (GRIDWIDTH / 2)), ((_local2 * GRIDHEIGHT) + (GRIDHEIGHT / 2)), BRICKWIDTH, BRICKHEIGHT, BRICKROTATION, true, BRICKMASS, BRICKBOUNCE, BRICKFRICTION);
apeGroup.addParticle(brickGrid[_local2][_local3]);
apeGroup.addParticle(brickGrid[_local2][_local3].bouncePad);
brickGrid[_local2][_local3].setDisplay(_local1);
brickGrid[_local2][_local3].sprite.name = "breakBrick";
brickGrid[_local2][_local3].bouncePad.sprite.name = "breakPad";
brickGrid[_local2][_local3].itemPosition1 = _local2;
brickGrid[_local2][_local3].itemPosition2 = _local3;
brickGrid[_local2][_local3].bouncePad.itemPosition1 = _local2;
brickGrid[_local2][_local3].bouncePad.itemPosition2 = _local3;
break;
case CRUMBLEBRICKTYPE:
_local1 = new CrumbleBrick();
brickGrid[_local2][_local3] = new Brick(CRUMBLEBRICKTYPE, ((_local3 * GRIDWIDTH) + (GRIDWIDTH / 2)), ((_local2 * GRIDHEIGHT) + (GRIDHEIGHT / 2)), BRICKWIDTH, BRICKHEIGHT, BRICKROTATION, true, BRICKMASS, BRICKBOUNCE, BRICKFRICTION);
apeGroup.addParticle(brickGrid[_local2][_local3]);
apeGroup.addParticle(brickGrid[_local2][_local3].bouncePad);
brickGrid[_local2][_local3].setDisplay(_local1);
brickGrid[_local2][_local3].sprite.name = "crumbleBrick";
brickGrid[_local2][_local3].bouncePad.sprite.name = "crumblePad";
brickGrid[_local2][_local3].itemPosition1 = _local2;
brickGrid[_local2][_local3].itemPosition2 = _local3;
brickGrid[_local2][_local3].bouncePad.itemPosition1 = _local2;
brickGrid[_local2][_local3].bouncePad.itemPosition2 = _local3;
break;
case COINTYPE:
numOfCoins++;
coinGrid[_local2][_local3] = new CoinClip();
coinGrid[_local2][_local3].y = ((_local2 * GRIDHEIGHT) + (GRIDHEIGHT / 2));
coinGrid[_local2][_local3].x = ((_local3 * GRIDWIDTH) + (GRIDWIDTH / 2));
addChild(coinGrid[_local2][_local3]);
break;
};
_local3++;
};
_local2--;
};
}
}
}//package
Section 62
//LevelEvent (LevelEvent)
package {
import flash.events.*;
public class LevelEvent extends Event {
public static const LEVELWON:String = "levelwon";
public static const RESETLEVEL:String = "resetlevel";
public static const EXITLEVEL:String = "exitlevel";
public function LevelEvent(_arg1:String){
super(_arg1, true);
}
override public function clone():Event{
return (new LevelEvent(type));
}
}
}//package
Section 63
//LoaderBar (LoaderBar)
package {
import flash.display.*;
public dynamic class LoaderBar extends MovieClip {
}
}//package
Section 64
//LogoIntroClip (LogoIntroClip)
package {
import flash.display.*;
public dynamic class LogoIntroClip extends MovieClip {
}
}//package
Section 65
//LoseSound (LoseSound)
package {
import flash.media.*;
public dynamic class LoseSound extends Sound {
}
}//package
Section 66
//MessageBackdrop (MessageBackdrop)
package {
import flash.display.*;
public dynamic class MessageBackdrop extends MovieClip {
}
}//package
Section 67
//MochiBot (MochiBot)
package {
import flash.display.*;
import flash.net.*;
import flash.system.*;
public dynamic class MochiBot extends Sprite {
public static function track(_arg1:Sprite, _arg2:String):MochiBot{
var _local3:MochiBot;
var _local4:String;
var _local5:URLVariables;
var _local6:String;
var _local7:URLRequest;
var _local8:Loader;
if (Security.sandboxType == "localWithFile"){
return (null);
};
_local3 = new (MochiBot);
_arg1.addChild(_local3);
Security.allowDomain("*");
Security.allowInsecureDomain("*");
_local4 = "http://core.mochibot.com/my/core.swf";
_local5 = new URLVariables();
_local5["sb"] = Security.sandboxType;
_local5["v"] = Capabilities.version;
_local5["swfid"] = _arg2;
_local5["mv"] = "8";
_local5["fv"] = "9";
_local6 = _local3.root.loaderInfo.loaderURL;
if (_local6.indexOf("http") == 0){
_local5["url"] = _local6;
} else {
_local5["url"] = "local";
};
_local7 = new URLRequest(_local4);
_local7.contentType = "application/x-www-form-urlencoded";
_local7.method = URLRequestMethod.POST;
_local7.data = _local5;
_local8 = new Loader();
_local3.addChild(_local8);
_local8.load(_local7);
return (_local3);
}
}
}//package
Section 68
//MusicButton (MusicButton)
package {
import flash.display.*;
public dynamic class MusicButton extends MovieClip {
public function MusicButton(){
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4);
}
function frame3(){
stop();
}
function frame1(){
stop();
}
function frame4(){
stop();
}
function frame2(){
stop();
}
}
}//package
Section 69
//ND_Logo (ND_Logo)
package {
import flash.display.*;
public dynamic class ND_Logo extends MovieClip {
}
}//package
Section 70
//NormalBrick (NormalBrick)
package {
import flash.display.*;
public dynamic class NormalBrick extends MovieClip {
public function NormalBrick(){
addFrameScript(0, frame1, 22, frame23);
}
function frame1(){
stop();
}
function frame23(){
stop();
dispatchEvent(new ClipDoneEvent(ClipDoneEvent.CLIPDONE));
}
}
}//package
Section 71
//PauseButton (PauseButton)
package {
import flash.display.*;
public dynamic class PauseButton extends MovieClip {
public function PauseButton(){
addFrameScript(0, frame1, 1, frame2, 2, frame3, 3, frame4);
}
function frame3(){
stop();
}
function frame1(){
stop();
}
function frame4(){
stop();
}
function frame2(){
stop();
}
}
}//package
Section 72
//PlayDroppleButton (PlayDroppleButton)
package {
import flash.display.*;
public dynamic class PlayDroppleButton extends SimpleButton {
}
}//package
Section 73
//PlayMoreGamesButton (PlayMoreGamesButton)
package {
import flash.display.*;
public dynamic class PlayMoreGamesButton extends SimpleButton {
}
}//package
Section 74
//Prototype_EMBED (Prototype_EMBED)
package {
import flash.text.*;
public dynamic class Prototype_EMBED extends Font {
}
}//package
Section 75
//ReallyExitButton (ReallyExitButton)
package {
import flash.display.*;
public dynamic class ReallyExitButton extends SimpleButton {
}
}//package
Section 76
//ReplayIntro (ReplayIntro)
package {
import flash.display.*;
public dynamic class ReplayIntro extends SimpleButton {
}
}//package
Section 77
//ResetLevelButton (ResetLevelButton)
package {
import flash.display.*;
public dynamic class ResetLevelButton extends SimpleButton {
}
}//package
Section 78
//ResumeButton (ResumeButton)
package {
import flash.display.*;
public dynamic class ResumeButton extends SimpleButton {
}
}//package
Section 79
//ResumeTitleButton (ResumeTitleButton)
package {
import flash.display.*;
public dynamic class ResumeTitleButton extends SimpleButton {
}
}//package
Section 80
//RightWallGraphic (RightWallGraphic)
package {
import flash.display.*;
public dynamic class RightWallGraphic extends MovieClip {
}
}//package
Section 81
//SinisterSeaIntro (SinisterSeaIntro)
package {
import flash.display.*;
public dynamic class SinisterSeaIntro extends MovieClip {
public var ssLogo:LogoIntroClip;
public function SinisterSeaIntro(){
addFrameScript(138, frame139);
}
function frame139(){
stop();
dispatchEvent(new ClipDoneEvent(ClipDoneEvent.CLIPDONE));
}
}
}//package
Section 82
//SponsorButton (SponsorButton)
package {
import flash.display.*;
public dynamic class SponsorButton extends SimpleButton {
}
}//package
Section 83
//SponsorIntro (SponsorIntro)
package {
import flash.display.*;
public dynamic class SponsorIntro extends MovieClip {
public function SponsorIntro(){
addFrameScript(229, frame230);
}
function frame230(){
stop();
dispatchEvent(new ClipDoneEvent(ClipDoneEvent.CLIPDONE));
}
}
}//package
Section 84
//SponsorLoaderLink (SponsorLoaderLink)
package {
import flash.display.*;
public dynamic class SponsorLoaderLink extends SimpleButton {
}
}//package
Section 85
//StartGameButton (StartGameButton)
package {
import flash.display.*;
public dynamic class StartGameButton extends SimpleButton {
}
}//package
Section 86
//SteelCityComic_EMBED (SteelCityComic_EMBED)
package {
import flash.text.*;
public dynamic class SteelCityComic_EMBED extends Font {
}
}//package
Section 87
//SubmitScoreButton (SubmitScoreButton)
package {
import flash.display.*;
public dynamic class SubmitScoreButton extends SimpleButton {
}
}//package
Section 88
//TitleBackground (TitleBackground)
package {
import flash.display.*;
public dynamic class TitleBackground extends MovieClip {
}
}//package
Section 89
//TitleMusic (TitleMusic)
package {
import flash.media.*;
public dynamic class TitleMusic extends Sound {
}
}//package
Section 90
//TitleScreen (TitleScreen)
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class TitleScreen extends Sprite {
private const PLAYMOREURL:URLRequest;
private const SINISTERSEAURL:URLRequest;
private var titleLogo:Sprite;
private var droppleIntro:DroppleIntro;
public var playFx:Boolean;// = true
public var resumeTitleBtn:ResumeTitleButton;
private var coinCollectSound:CoinCollectSound;
public var startGameBtn:StartGameButton;
private var playMoreGamesBtn:PlayMoreGamesButton;
private var titleBackdrop:Sprite;
private var sponsorLogo:Sprite;
private var creditsText:Sprite;
public var highScoresBtn:HighScoresButton;
public function TitleScreen(){
PLAYMOREURL = new URLRequest("http://www.notdoppler.com");
SINISTERSEAURL = new URLRequest("http://www.sinistersea.com");
startGameBtn = new StartGameButton();
highScoresBtn = new HighScoresButton();
resumeTitleBtn = new ResumeTitleButton();
playMoreGamesBtn = new PlayMoreGamesButton();
titleBackdrop = new TitleBackground();
titleLogo = new GameLogo();
creditsText = new CreditsTag();
sponsorLogo = new ND_Logo();
droppleIntro = new DroppleIntro();
coinCollectSound = new CoinCollectSound();
playFx = true;
super();
drawContent();
}
private function anyButtonClicked(_arg1:MouseEvent){
if (playFx){
coinCollectSound.play();
};
}
public function init(){
playMoreGamesBtn.addEventListener(MouseEvent.CLICK, showPlayMoreGames);
creditsText.addEventListener(MouseEvent.CLICK, creditsClicked);
creditsText.buttonMode = true;
creditsText.useHandCursor = true;
sponsorLogo.addEventListener(MouseEvent.CLICK, sponsorClicked);
sponsorLogo.buttonMode = true;
sponsorLogo.useHandCursor = true;
droppleIntro.gotoAndStop(2);
startGameBtn.addEventListener(MouseEvent.CLICK, anyButtonClicked);
highScoresBtn.addEventListener(MouseEvent.CLICK, anyButtonClicked);
playMoreGamesBtn.addEventListener(MouseEvent.CLICK, anyButtonClicked);
droppleIntro.addEventListener(MouseEvent.CLICK, anyButtonClicked);
resumeTitleBtn.addEventListener(MouseEvent.CLICK, anyButtonClicked);
}
private function creditsClicked(_arg1:MouseEvent){
navigateToURL(SINISTERSEAURL, "_blank");
}
public function deInit(){
playMoreGamesBtn.removeEventListener(MouseEvent.CLICK, showPlayMoreGames);
creditsText.removeEventListener(MouseEvent.CLICK, creditsClicked);
sponsorLogo.removeEventListener(MouseEvent.CLICK, sponsorClicked);
startGameBtn.removeEventListener(MouseEvent.CLICK, anyButtonClicked);
highScoresBtn.removeEventListener(MouseEvent.CLICK, anyButtonClicked);
playMoreGamesBtn.removeEventListener(MouseEvent.CLICK, anyButtonClicked);
droppleIntro.removeEventListener(MouseEvent.CLICK, anyButtonClicked);
}
public function startIntro(){
droppleIntro.gotoAndPlay(2);
}
public function removeContent(){
removeChild(titleBackdrop);
removeChild(titleLogo);
removeChild(creditsText);
removeChild(startGameBtn);
removeChild(highScoresBtn);
removeChild(playMoreGamesBtn);
removeChild(droppleIntro);
}
private function drawContent(){
titleBackdrop.x = 0;
titleBackdrop.y = 0;
addChild(titleBackdrop);
titleLogo.x = 6;
titleLogo.y = 6;
addChild(titleLogo);
creditsText.x = 325;
creditsText.y = 38;
addChild(creditsText);
sponsorLogo.x = 208;
sponsorLogo.y = 2;
addChild(sponsorLogo);
startGameBtn.x = 6;
startGameBtn.y = 76;
addChild(startGameBtn);
resumeTitleBtn.x = 113;
resumeTitleBtn.y = 76;
addChild(resumeTitleBtn);
highScoresBtn.x = 243;
highScoresBtn.y = 76;
addChild(highScoresBtn);
playMoreGamesBtn.x = 355;
playMoreGamesBtn.y = 76;
addChild(playMoreGamesBtn);
droppleIntro.x = 0;
droppleIntro.y = 130;
addChildAt(droppleIntro, 0);
}
private function sponsorClicked(_arg1:MouseEvent){
navigateToURL(PLAYMOREURL, "_blank");
}
private function showPlayMoreGames(_arg1:MouseEvent){
navigateToURL(PLAYMOREURL, "_blank");
}
private function returnFromHighScores(_arg1:MouseEvent){
setChildIndex(titleBackdrop, 0);
}
}
}//package
Section 91
//TransitionClip (TransitionClip)
package {
import flash.display.*;
public dynamic class TransitionClip extends MovieClip {
public function TransitionClip(){
addFrameScript(59, frame60, 119, frame120);
}
function frame120(){
stop();
dispatchEvent(new ClipDoneEvent(ClipDoneEvent.CLIPDONE));
}
function frame60(){
stop();
dispatchEvent(new ClipDoneEvent(ClipDoneEvent.CLIPDONE));
}
}
}//package
Section 92
//WinSound (WinSound)
package {
import flash.media.*;
public dynamic class WinSound extends Sound {
}
}//package