warning
...
@author awesomeguy1
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
import flash.system.Security;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.net.URLRequest;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.geom.Point;
/**
* ...
* @author awesomeguy1
*/
[SWF(width = "800", height = "600", frameRate = "30", backgroundColor = "#FFFFFF")]
public class Main extends Sprite
{
public var _mochiads_game_id:String = "212c3c694a4aa67d";
public static var instance:Main;
public var stageheight:int;
public var stagewidth:int;
public var blocks:Array;
public var player:Player;
public var blockspeed:int = 10;
public const levelwidth:uint = 1560;
public var timer:Loadybar;
public var score:int;
public var scoretext:scoredisplay;
public var button:buttonstart;
public var title:TextField;
public var instructions:TextField;
public var finish:int;
public var rooms:XML =
<rooms>
<room difficulty="1">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="1">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
</room>
<room difficulty="1">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="1">
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="1">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="1">
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
</room>
<room difficulty="1">
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="1">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="1">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
</room>
<room difficulty="1">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="2">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="2">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="2">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="2">
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="2">
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="2">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="2">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="2">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="2">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
</room>
<room difficulty="2">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="3">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="3">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
</room>
<room difficulty="3">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="3">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="3">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="3">
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
</room>
<room difficulty="3">
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
</room>
<room difficulty="3">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
</room>
<room difficulty="3">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
<room difficulty="3">
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="1" />
<square block="0" />
<square block="0" />
<square block="0" />
<square block="1" />
<square block="1" />
</room>
</rooms>
public var spritearray:Array;
public var kongregate:*;
public function loadComplete(event:Event):void {
kongregate = event.target.content;
kongregate.services.connect();
}
public function getMainLoaderInfo():LoaderInfo {
var loaderInfo:LoaderInfo = root.loaderInfo;
if (loaderInfo.loader != null) {
loaderInfo = loaderInfo.loader.loaderInfo;
}
return loaderInfo;
}
public function Main():void {
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
public function createrooms():void {
for (var difficulties:uint = 1; difficulties <= 3; difficulties++) {
var a:Array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
var b:Array = new Array();
for (var n:int = 0; n < 10; n++) {
var i:int = Math.floor(Math.random() * a.length);
b.push(a[i]);
a.splice(i, 1);
}
for (var m:int = 0; m < 10; m++) {
var c:int = 0;
var spr:Sprite = new Sprite();
stage.addChild(spr);
spritearray.push(spr);
for (var xvar:int = 0; xvar < levelwidth; xvar += 120) {
for ( var yvar:int = 0; yvar < stageheight; yvar += 120) {
if (rooms.room[b[m]+10*(difficulties-1)].square[c].attribute("block") == 1) {
var bl:Block = new Block();
spr.addChild(bl);
bl.x = xvar;
bl.y = yvar;
blocks.push(bl);
}
c++;
}
}
}
for (var counter:int = 0; counter < spritearray.length; counter++) {
spritearray[counter].x = (counter * levelwidth) + 1000;
}
stage.addChild(timer);
stage.addChild(scoretext);
scoretext.x = stagewidth - scoretext.width;
}
finish = ((counter) * levelwidth) + 1000 + stagewidth;
}
private function init(e:Event = null):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
var paramObj:Object = getMainLoaderInfo().parameters;
var apiPath:String = paramObj.kongregate_api_path ||
"http://www.kongregate.com/flash/API_AS3_Local.swf";
Security.allowDomain(apiPath);
var request:URLRequest = new URLRequest(apiPath);
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.load(request);
addChild(loader);
instance = this;
stageheight = 600;
stagewidth = 800;
stage.addChild(new background());
mainmenu();
}
public function win():void {
clearstage();
stage.addChild(new popup("You Win!","Your score is: " + String(score),[["Menu",27,77],["Play Again",32,13,82]], end, this));
}
public function step(e:Event):void {
score += 10;
for (var n:String in spritearray) {
spritearray[n].x -= blockspeed;
}
finish -= blockspeed;
}
public function newgame(b:Boolean):void {
if (b) {
stage.removeChild(button);
stage.removeChild(title);
stage.removeChild(instructions);
button = null;
title = null;
instructions = null;
}
blocks = new Array();
timer = new Loadybar();
score = 0;
scoretext = new scoredisplay();
player = new Player();
player.y = 250;
stage.addChild(player);
spritearray = new Array();
createrooms();
addEventListener(Event.ENTER_FRAME, step);
}
public function mainmenu():void {
title = new TextField();
var f:TextFormat = new TextFormat();
f.align = "center";
f.size = 48;
f.bold = true;
f.color = 0xFF0000;
title.selectable = false;
title.autoSize = TextFieldAutoSize.CENTER;
title.defaultTextFormat = f;
title.text = "Warning";
stage.addChild(title);
title.x = stagewidth / 2 - title.width / 2;
title.y = 200;
var f2:TextFormat = new TextFormat();
f2.align = "center";
f2.size = 26;
f2.bold = true;
f2.color = 0xFF0000;
instructions = new TextField();
instructions.selectable = false;
instructions.autoSize = TextFieldAutoSize.CENTER;
instructions.defaultTextFormat = f2;
instructions.text = "Use the arrow keys or WASD to move!\nUse the space bar or x to shoot!";
stage.addChild(instructions);
instructions.x = stagewidth / 2 - instructions.width / 2;
instructions.y = 350;
button = new buttonstart();
button.x = stagewidth / 2 - button.width / 2;
button.y = stageheight - 100;
stage.addChild(button);
}
public function gameend():void {
clearstage();
stage.addChild(new popup("You Lose!","Your score is: " + String(score),[["Menu",27,77],["Retry",32,13,82]], end, this));
}
public function clearstage():void {
kongregate.stats.submit("score", score);
stage.removeChild(player);
player = null;
stage.removeChild(scoretext);
scoretext = null;
stage.removeChild(timer);
timer = null;
removeEventListener(Event.ENTER_FRAME, step);
for (var n:int = 0; n < blocks.length;n++) {
blocks[n].parent.removeChild(blocks[n]);
}
blocks = null;
for (var m:int = 0; m < spritearray.length; m++) {
stage.removeChild(spritearray[m]);
}
spritearray = null;
}
public function end(n:uint):void {
if (n) {
newgame(false);
}
else {
mainmenu();
}
}
}
}
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
import flash.system.Security;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.net.URLRequest;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.geom.Point;
class scoredisplay extends Sprite
{
public var text:TextField;
public function scoredisplay()
{
addEventListener(Event.ENTER_FRAME, step);
addEventListener(Event.REMOVED_FROM_STAGE, removed);
text = new TextField();
addChild(text);
var d:TextFormat = new TextFormat();
d.color = 0xFF0000;
d.align = "right";
d.bold = true;
d.size = 24;
text.defaultTextFormat = d;
}
public function step(e:Event):void {
text.text = String(Main.instance.score);
}
public function removed(e:Event):void {
removeEventListener(Event.REMOVED_FROM_STAGE, removed);
removeEventListener(Event.ENTER_FRAME, step);
}
}
/**
* ...
* @author awesomeguy1
*/
class background extends Sprite
{
public function background()
{
}
}
/**
* ...
* @author awesomeguys
*/
/**
* ...
* @author awesomeguy1
*/
class base extends Sprite {
public function base():void {
addEventListener (Event.ADDED_TO_STAGE, added);
}
public function added(e:Event):void {
removeEventListener(Event.ADDED, added);
}
}
/**
* ...
* @author awesomeguys
*/
class Block extends Sprite
{
public function Block()
{
if (Math.floor(Math.random() * 2)) {
graphics.beginFill(0x000000);
}
else {
graphics.beginFill(0xFFFF00);
}
graphics.drawRect(0, 0, 120, 120);
graphics.endFill();
}
}
/**
* ...
* @author awesomeguys
*/
class Bullet extends Sprite
{
public const speed:int = 20;
public function Bullet()
{
addEventListener(Event.ENTER_FRAME, step);
var size:int = 4;
for (var i:int = 0; i < 50; i += size * 2) {
graphics.beginFill(0xFFFF00);
graphics.drawRect(i, 0, size, 10);
graphics.beginFill(0x000000);
graphics.drawRect(i + size, 0, size, 10);
}
}
public function step(e:Event):void {
x += speed;
var f:Boolean = false;
if (Main.instance.blocks != null) {
for (var n:int = 0; n < Main.instance.blocks.length; n++) {
var b:Block = Main.instance.blocks[n];
if (hitTestObject(b)) {
b.parent.removeChild(b);
Main.instance.blocks.splice(n, 1);
n--;
removeEventListener(Event.ENTER_FRAME, step);
f = true;
}
}
}
else {
die();
}
if (f) {
die();
}
if (x > Main.instance.stagewidth) {
die();
}
}
public function die():void {
removeEventListener(Event.ENTER_FRAME, step);
if (this.parent) stage.removeChild(this);
}
}
/**
* ...
* @author awesomeguy1
*/
class Buttonbase extends base
{
public override function added(e:Event):void {
if (hitTestPoint(localToGlobal(new Point(mouseX, mouseY)).x, localToGlobal(new Point(mouseX, mouseY)).y, false)) {
addEventListener(Event.ENTER_FRAME, step);
}
else {
}
addEventListener(MouseEvent.MOUSE_DOWN, click);
addEventListener(MouseEvent.MOUSE_OVER, over);
addEventListener(MouseEvent.MOUSE_OUT, out);
addEventListener(MouseEvent.MOUSE_UP, up);
stage.addEventListener(MouseEvent.MOUSE_UP, globalup);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keydown);
stage.addEventListener(KeyboardEvent.KEY_UP, keyup);
removeEventListener(Event.ADDED_TO_STAGE, added);
addEventListener(Event.REMOVED_FROM_STAGE, removed);
}
private function step(e:Event):void {
if (!(hitTestPoint(localToGlobal(new Point(mouseX, mouseY)).x, localToGlobal(new Point(mouseX, mouseY)).y, false))) {
removeEventListener(Event.ENTER_FRAME, step);
}
}
private function removed(e:Event):void {
stage.removeEventListener(KeyboardEvent.KEY_DOWN, keydown);
stage.removeEventListener(KeyboardEvent.KEY_UP, keyup);
stage.removeEventListener(MouseEvent.MOUSE_UP, globalup);
removeEventListener(MouseEvent.MOUSE_OUT, out);
removeEventListener(MouseEvent.MOUSE_OVER, over);
removeEventListener(MouseEvent.MOUSE_DOWN, click);
removeEventListener(MouseEvent.MOUSE_UP, up);
removeEventListener(Event.REMOVED_FROM_STAGE, removed);
}
public function click(e:MouseEvent = null):void {
}
public function over(e:MouseEvent):void {
}
public function out(e:MouseEvent):void {
}
public function globalup(e:MouseEvent = null):void {
}
public function up(e:MouseEvent = null):void {
}
public function keydown(e:KeyboardEvent):void {
}
public function keyup(e:KeyboardEvent):void {
}
}
/**
* ...
* @author awesomeguy1
*/
class buttonstart extends Buttonbase
{
public override function up(e:MouseEvent = null):void {
Main.instance.newgame(true);
Main.instance.stage.focus = stage;
}
public function buttonstart():void {
graphics.beginFill(0xFF0000);
graphics.drawRect(0, 0, 64, 32);
graphics.endFill();
}
public override function added(e:Event):void {
super.added(e);
var textfield:TextField = new TextField();
textfield.text = "Start";
addChild(textfield);
textfield.x = 4;
textfield.y = 4;
textfield.selectable = false;
textfield.width = 64;
textfield.height = 32;
}
public override function keydown(e:KeyboardEvent):void {
if (e.keyCode == 13 || e.keyCode == 32) click();
}
public override function keyup(e:KeyboardEvent):void {
if (e.keyCode == 13 || e.keyCode == 32) {
up();
globalup();
}
}
}
/**
* ...
* @author awesomeguys
*/
class Loadybar extends Sprite
{
public var s:Sprite = new Sprite();
public function Loadybar()
{
addEventListener(Event.ADDED_TO_STAGE, added);
}
public function added(e:Event):void {
removeEventListener(Event.ENTER_FRAME, added);
addEventListener(Event.REMOVED_FROM_STAGE, removed);
graphics.lineStyle(1);
graphics.drawRect(0, 0, 100, 10);
addEventListener(Event.ENTER_FRAME, step);
addChild(s);
}
public function step(e:Event):void {
s.graphics.clear();
s.graphics.beginFill(0xFF0000);
s.graphics.drawRect(1, 1, Main.instance.player.counter / (Main.instance.player.countermax/100) - 2, 8);
s.graphics.endFill();
}
public function removed(e:Event):void {
removeEventListener(Event.REMOVED_FROM_STAGE, removed);
removeEventListener(Event.ENTER_FRAME, step);
}
}
/**
* ...
* @author awesomeguy1
*/
class messageButton extends Buttonbase
{
public var number:uint;
public var keycode:Array = new Array();
public var text:String;
public override function up(e:MouseEvent = null):void {
popup(parent).buttonpressed(number);
}
public function messageButton():void {
graphics.beginFill(0xFF0000);
graphics.drawRect(0, 0, 64, 32);
graphics.endFill();
}
public override function added(e:Event):void {
super.added(e);
var textfield:TextField = new TextField();
textfield.text = text;
addChild(textfield);
textfield.x = 4;
textfield.y = 4;
textfield.selectable = false;
textfield.width = 64;
textfield.height = 32;
}
public override function keydown(e:KeyboardEvent):void {
for (var n:String in keycode) {
if (e.keyCode == keycode[n]) click();
}
}
public override function keyup(e:KeyboardEvent):void {
for (var n:String in keycode) {
if (e.keyCode == keycode[n]) {
up();
globalup();
}
}
}
}
/**
* ...
* @author awesomeguys
*/
class Player extends Sprite
{
public const dist:int = -100;
public var up:Boolean = false;
public var right:Boolean = false;
public var left:Boolean = false;
public var down:Boolean = false;
public var speed:uint;
public const countermax:uint = 60;
public var counter:uint = countermax;
public function Player()
{
graphics.beginFill(0xFF0000);
graphics.drawRect(0, 0, 66, 100);
graphics.endFill();
addEventListener(Event.ADDED_TO_STAGE, added);
width = 66;
height = 100;
}
public function added(e:Event):void {
removeEventListener(Event.ADDED_TO_STAGE, added);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keydown);
stage.addEventListener(KeyboardEvent.KEY_UP, keyup);
addEventListener(Event.ENTER_FRAME, step);
speed = Main.instance.blockspeed + 5;
addEventListener(Event.REMOVED_FROM_STAGE, removed);
}
public function removed(e:Event):void {
stage.removeEventListener(KeyboardEvent.KEY_DOWN, keydown);
stage.removeEventListener(KeyboardEvent.KEY_UP, keyup);
removeEventListener(Event.ENTER_FRAME, step);
removeEventListener(Event.REMOVED_FROM_STAGE, removed);
}
public function keyup(e:KeyboardEvent):void {
switch (e.keyCode) {
case 37: //left
case 65:
left = false;
break;
case 38: //up
case 87:
up = false;
break;
case 39: //right
case 68:
right = false;
break;
case 40: //down
case 83:
down = false;
break;
}
}
public function keydown(e:KeyboardEvent):void {
switch (e.keyCode) {
case 37: //left
case 65:
left = true;
break;
case 38: //up
case 87:
up = true;
break;
case 39: //right
case 68:
right = true;
break;
case 40: //down
case 83:
down = true;
break;
case 32:
case 88:
if (counter == countermax) {
shoot();
Main.instance.score -= 500;
}
break;
}
}
public function shoot():void {
var b:Bullet = new Bullet();
stage.addChild(b);
b.x = x + width;
b.y = y + height / 2
counter = 0;
}
public function step(e:Event):void {
if (counter != countermax) counter++;
var newx:int = x;
var newy:int = y;
if (left) {
newx -= speed;
}
if (right) {
newx += speed;
}
if (up) {
newy -= speed;
}
if (down) {
newy += speed;
}
if (newx > Main.instance.stagewidth - width) {
newx = Main.instance.stagewidth - width;
}
if (newy > Main.instance.stageheight - height) {
newy = Main.instance.stageheight - height;
}
if (newx < dist) {
Main.instance.gameend();
}
if (newy < 0) newy = 0;
for (var n:String in Main.instance.blocks) {
var bl:Block = Main.instance.blocks[n];
var block:Point = bl.parent.localToGlobal(new Point(bl.x, bl.y));
if ((x + width < block.x + bl.width && x + width > block.x + Main.instance.blockspeed) || (x < block.x + bl.width && x > block.x)) {
if (newy + height > block.y && newy < block.y) {
newy = block.y - height;
}
if (newy < block.y + bl.height && newy + height > block.y + bl.height) {
newy = block.y + bl.height;
}
}
if ((y + height < block.y + bl.height && y + height > block.y) || (y < block.y + bl.height && y > block.y)) {
if (newx + width > block.x && newx < block.x) {
newx = block.x - width;
}
if (newx < block.x + bl.width && newx + width > block.x + bl.width) {
newx = block.x + bl.width;
}
}
}
x = newx;
y = newy;
if (x > Main.instance.finish) {
Main.instance.win();
}
}
}
/**
* ...
* @author awesomeguy1
*/
class popup extends base
{
private var text:String;
private var text2:String;
private var textfield:TextField;
private var textfield2:TextField
private var buttons:Array;
private var buttonobjects:Array;
private const thewidth:int = 384;
private const theheight:int = 128;
private var funct:Function;
private var caller:Object;
private var backgroundimage:Bitmap;
public function popup(t:String,t2:String,b:Array, f:Function,c:Object):void {
x = Main.instance.stagewidth / 2 - thewidth / 2;
y = Main.instance.stageheight / 2 - theheight / 2;
funct = f;
text = t;
caller = c;
buttons = b;
text2 = t2;
}
public override function added(e:Event):void {
removeEventListener(Event.ADDED_TO_STAGE, added);
textfield = new TextField();
var f:TextFormat = new TextFormat();
f.bold = true;
f.align = "center";
f.size = 24;
textfield.defaultTextFormat = f;
textfield.text = text;
textfield.x = 10;
textfield.y = 10;
textfield.selectable = false;
textfield.width = thewidth;
textfield.height = theheight;
addChild(textfield);
var f2:TextFormat = new TextFormat();
f2.bold = true;
f2.align = "center";
textfield2 = new TextField();
textfield2.defaultTextFormat = f2;
textfield2.x = 10;
textfield2.y = 40;
textfield2.selectable = false;
textfield2.text = text2;
textfield2.width = thewidth;
textfield2.height = theheight;
addChild(textfield2);
buttonobjects = new Array();
for (var i:int = 0; i < buttons.length; i++) {
var button:messageButton = new messageButton();
buttonobjects.push(button);
buttonobjects[i].number = i;
buttonobjects[i].text = buttons[i][0];
buttonobjects[i].y = 64;
buttonobjects[i].x = 32 + i * 80;
for (var n:int = 1; n < buttons[i].length; n++) {
buttonobjects[i].keycode.push(buttons[i][n]);
}
addChild(button);
}
}
public function buttonpressed(n:uint):void {
Main.instance.stage.focus = stage;
funct.call(caller,n);
stage.removeChild(this);
}
}