Section 1
//KeyPoll (bigroom.input.KeyPoll)
package bigroom.input {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
public class KeyPoll {
private var states:ByteArray;
public var press:Boolean;// = false
public var click:Boolean;// = false
public var onscreen:Boolean;// = true
public var hasclicked:Boolean;// = false
private var dispObj:DisplayObject;
public function KeyPoll(obj:DisplayObject){
super();
states = new ByteArray();
states.writeUnsignedInt(0);
states.writeUnsignedInt(0);
states.writeUnsignedInt(0);
states.writeUnsignedInt(0);
states.writeUnsignedInt(0);
states.writeUnsignedInt(0);
states.writeUnsignedInt(0);
states.writeUnsignedInt(0);
dispObj = obj;
dispObj.addEventListener(KeyboardEvent.KEY_DOWN, keyDownListener, false, 0, true);
dispObj.addEventListener(KeyboardEvent.KEY_UP, keyUpListener, false, 0, true);
dispObj.addEventListener(Event.ACTIVATE, activateListener, false, 0, true);
dispObj.addEventListener(Event.DEACTIVATE, deactivateListener, false, 0, true);
dispObj.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);
dispObj.addEventListener(MouseEvent.MOUSE_UP, mouseUpListener);
dispObj.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
dispObj.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
}
public function mouseOutHandler(e:MouseEvent):void{
onscreen = false;
}
public function isUp(keyCode:uint):Boolean{
return (((states[(keyCode >>> 3)] & (1 << (keyCode & 7))) == 0));
}
private function activateListener(ev:Event):void{
var i:int;
while (i < 8) {
states[i] = 0;
i++;
};
}
public function isDown(keyCode:uint):Boolean{
return (!(((states[(keyCode >>> 3)] & (1 << (keyCode & 7))) == 0)));
}
private function keyUpListener(ev:KeyboardEvent):void{
states[(ev.keyCode >>> 3)] = (states[(ev.keyCode >>> 3)] & ~((1 << (ev.keyCode & 7))));
}
private function deactivateListener(ev:Event):void{
var i:int;
while (i < 8) {
states[i] = 0;
i++;
};
}
public function mouseOverHandler(e:MouseEvent):void{
onscreen = true;
}
public function mouseUpListener(e:MouseEvent):void{
press = false;
click = false;
hasclicked = false;
}
public function mouseDownListener(e:MouseEvent):void{
press = true;
click = true;
hasclicked = true;
}
private function keyDownListener(ev:KeyboardEvent):void{
states[(ev.keyCode >>> 3)] = (states[(ev.keyCode >>> 3)] | (1 << (ev.keyCode & 7)));
}
}
}//package bigroom.input
Section 2
//BitmapAsset (mx.core.BitmapAsset)
package mx.core {
import flash.display.*;
public class BitmapAsset extends FlexBitmap implements IFlexAsset, IFlexDisplayObject {
mx_internal static const VERSION:String = "3.4.0.6955";
public function BitmapAsset(bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=false){
super(bitmapData, pixelSnapping, smoothing);
}
public function get measuredWidth():Number{
if (bitmapData){
return (bitmapData.width);
};
return (0);
}
public function get measuredHeight():Number{
if (bitmapData){
return (bitmapData.height);
};
return (0);
}
public function setActualSize(newWidth:Number, newHeight:Number):void{
width = newWidth;
height = newHeight;
}
public function move(x:Number, y:Number):void{
this.x = x;
this.y = y;
}
}
}//package mx.core
Section 3
//FlexBitmap (mx.core.FlexBitmap)
package mx.core {
import flash.display.*;
import mx.utils.*;
public class FlexBitmap extends Bitmap {
mx_internal static const VERSION:String = "3.4.0.6955";
public function FlexBitmap(bitmapData:BitmapData=null, pixelSnapping:String="auto", smoothing:Boolean=false){
var bitmapData = bitmapData;
var pixelSnapping = pixelSnapping;
var smoothing = smoothing;
super(bitmapData, pixelSnapping, smoothing);
name = NameUtil.createUniqueName(this);
//unresolved jump
var _slot1 = e;
}
override public function toString():String{
return (NameUtil.displayObjectToString(this));
}
}
}//package mx.core
Section 4
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 5
//IFlexDisplayObject (mx.core.IFlexDisplayObject)
package mx.core {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.accessibility.*;
public interface IFlexDisplayObject extends IBitmapDrawable, IEventDispatcher {
function get visible():Boolean;
function get rotation():Number;
function localToGlobal(void:Point):Point;
function get name():String;
function set width(flash.display:Number):void;
function get measuredHeight():Number;
function get blendMode():String;
function get scale9Grid():Rectangle;
function set name(flash.display:String):void;
function set scaleX(flash.display:Number):void;
function set scaleY(flash.display:Number):void;
function get measuredWidth():Number;
function get accessibilityProperties():AccessibilityProperties;
function set scrollRect(flash.display:Rectangle):void;
function get cacheAsBitmap():Boolean;
function globalToLocal(void:Point):Point;
function get height():Number;
function set blendMode(flash.display:String):void;
function get parent():DisplayObjectContainer;
function getBounds(String:DisplayObject):Rectangle;
function get opaqueBackground():Object;
function set scale9Grid(flash.display:Rectangle):void;
function setActualSize(_arg1:Number, _arg2:Number):void;
function set alpha(flash.display:Number):void;
function set accessibilityProperties(flash.display:AccessibilityProperties):void;
function get width():Number;
function hitTestPoint(_arg1:Number, _arg2:Number, _arg3:Boolean=false):Boolean;
function set cacheAsBitmap(flash.display:Boolean):void;
function get scaleX():Number;
function get scaleY():Number;
function get scrollRect():Rectangle;
function get mouseX():Number;
function get mouseY():Number;
function set height(flash.display:Number):void;
function set mask(flash.display:DisplayObject):void;
function getRect(String:DisplayObject):Rectangle;
function get alpha():Number;
function set transform(flash.display:Transform):void;
function move(_arg1:Number, _arg2:Number):void;
function get loaderInfo():LoaderInfo;
function get root():DisplayObject;
function hitTestObject(mx.core:IFlexDisplayObject/mx.core:IFlexDisplayObject:stage/get:DisplayObject):Boolean;
function set opaqueBackground(flash.display:Object):void;
function set visible(flash.display:Boolean):void;
function get mask():DisplayObject;
function set x(flash.display:Number):void;
function set y(flash.display:Number):void;
function get transform():Transform;
function set filters(flash.display:Array):void;
function get x():Number;
function get y():Number;
function get filters():Array;
function set rotation(flash.display:Number):void;
function get stage():Stage;
}
}//package mx.core
Section 6
//IRepeaterClient (mx.core.IRepeaterClient)
package mx.core {
public interface IRepeaterClient {
function get instanceIndices():Array;
function set instanceIndices(C:\autobuild\3.x\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void;
function get isDocument():Boolean;
function set repeaters(C:\autobuild\3.x\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void;
function initializeRepeaterArrays(C:\autobuild\3.x\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:IRepeaterClient):void;
function get repeaters():Array;
function set repeaterIndices(C:\autobuild\3.x\frameworks\projects\framework\src;mx\core;IRepeaterClient.as:Array):void;
function get repeaterIndices():Array;
}
}//package mx.core
Section 7
//mx_internal (mx.core.mx_internal)
package mx.core {
public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal";
}//package mx.core
Section 8
//SoundAsset (mx.core.SoundAsset)
package mx.core {
import flash.media.*;
public class SoundAsset extends Sound implements IFlexAsset {
mx_internal static const VERSION:String = "3.4.0.6955";
public function SoundAsset(){
super();
}
}
}//package mx.core
Section 9
//NameUtil (mx.utils.NameUtil)
package mx.utils {
import flash.display.*;
import mx.core.*;
import flash.utils.*;
public class NameUtil {
mx_internal static const VERSION:String = "3.4.0.6955";
private static var counter:int = 0;
public function NameUtil(){
super();
}
public static function displayObjectToString(displayObject:DisplayObject):String{
var result:String;
var o:DisplayObject;
var s:String;
var indices:Array;
var displayObject = displayObject;
o = displayObject;
while (o != null) {
if (((((o.parent) && (o.stage))) && ((o.parent == o.stage)))){
break;
};
s = o.name;
if ((o is IRepeaterClient)){
indices = IRepeaterClient(o).instanceIndices;
if (indices){
s = (s + (("[" + indices.join("][")) + "]"));
};
};
result = ((result == null)) ? s : ((s + ".") + result);
o = o.parent;
};
//unresolved jump
var _slot1 = e;
return (result);
}
public static function createUniqueName(object:Object):String{
if (!object){
return (null);
};
var name:String = getQualifiedClassName(object);
var index:int = name.indexOf("::");
if (index != -1){
name = name.substr((index + 2));
};
var charCode:int = name.charCodeAt((name.length - 1));
if ((((charCode >= 48)) && ((charCode <= 57)))){
name = (name + "_");
};
return ((name + counter++));
}
}
}//package mx.utils
Section 10
//between_song (between_song)
package {
import flash.media.*;
public dynamic class between_song extends Sound {
}
}//package
Section 11
//blockclass (blockclass)
package {
import flash.geom.*;
public class blockclass {
public var hp:int;
public var rect:Rectangle;
public var active:Boolean;
public var yp:int;
public var xp:int;
public var wp:int;
public var type:int;
public var trigger:int;
public function blockclass():void{
super();
clear();
}
public function clear():void{
active = false;
type = 0;
trigger = 0;
xp = 0;
yp = 0;
wp = 0;
hp = 0;
rect = new Rectangle();
rect.x = xp;
rect.y = yp;
rect.width = wp;
rect.height = hp;
}
public function rectset(xi:int, yi:int, wi:int, hi:int):void{
rect.x = xi;
rect.y = yi;
rect.width = wi;
rect.height = hi;
}
}
}//package
Section 12
//entclass (entclass)
package {
public class entclass {
public var size:int;
public var active:Boolean;
public var onentity:int;
public var rule:int;
public var jumpframe:int;
public var actionframe:int;
public var state:int;
public var statedelay:int;
public var walkingframe:int;
public var jumping:Boolean;
public var yp:Number;
public var isplatform:Boolean;
public var newxp:Number;
public var harmful:Boolean;
public var dir:int;
public var onwall:int;
public var behave:int;
public var onground:int;
public var tile:int;
public var ax:Number;
public var ay:Number;
public var x1:int;
public var type:int;
public var framedelay:int;
public var vy:Number;
public var onywall:int;
public var newyp:Number;
public var vx:Number;
public var onxwall:int;
public var onroof:int;
public var colour:int;
public var gravity:Boolean;
public var x2:int;
public var y1:int;
public var y2:int;
public var invis:Boolean;
public var oldxp:Number;
public var para:int;
public var animate:int;
public var drawframe:int;
public var h:int;
public var cx:int;
public var cy:int;
public var w:int;
public var xp:Number;
public var life:int;
public var oldyp:Number;
public function entclass():void{
super();
clear();
}
public function clear():void{
active = false;
invis = false;
type = 0;
size = 0;
tile = 0;
rule = 0;
state = 0;
statedelay = 0;
life = 0;
colour = 0;
para = 0;
behave = 0;
animate = 0;
xp = 0;
yp = 0;
ax = 0;
ay = 0;
vx = 0;
vy = 0;
w = 32;
h = 32;
cx = 0;
cy = 0;
newxp = 0;
newyp = 0;
x1 = 0;
y1 = 0;
x2 = 320;
y2 = 240;
jumping = false;
gravity = false;
onground = 0;
onroof = 0;
jumpframe = 0;
onentity = 0;
harmful = false;
onwall = 0;
onxwall = 0;
onywall = 0;
isplatform = false;
framedelay = 0;
drawframe = 0;
walkingframe = 0;
dir = 0;
actionframe = 0;
}
}
}//package
Section 13
//entityclass (entityclass)
package {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
public class entityclass {
public var z:int;
public var nsimpleentity:int;
public var blocks:Array;
public var temph:int;
public var activetrigger:int;
public var colpoint1:Point;
public var tempw:int;
public var tempy:int;
public var tempx:int;
public var nblocks:int;
public var colpoint2:Point;
public var tpx1:int;
public var tpx2:int;
public var temprect:Rectangle;
public var entities:Array;
public var nentity:int;
public var temp:int;
public var tpy2:int;
public var temp2:int;
public var i:int;
public var k:int;
public var tpy1:int;
public var simpleentities:Array;
public var j:int;
public var temprect2:Rectangle;
public static var TRIGGER:Number = 1;
public static var BLOCK:Number = 0;
public static var DAMAGE:Number = 2;
public function entityclass(){
entities = new Array();
simpleentities = new Array();
blocks = new Array();
super();
}
public function removeblock(t:int):void{
blocks[t].clear();
i = (nblocks - 1);
while ((((i >= 0)) && (!(blocks[i].active)))) {
nblocks--;
i--;
};
}
public function updateentities(i:int, game:gameclass, music:musicclass):Boolean{
if (entities[i].active){
if (entities[i].statedelay <= 0){
switch (entities[i].type){
case 0:
if (entities[i].state == 0){
};
break;
case 1:
if (entities[i].state == 0){
if (entities[i].xp > 320){
entities[i].active = false;
};
if (entities[i].xp < -10){
entities[i].active = false;
};
if (entities[i].yp < -10){
entities[i].active = false;
};
if (entities[i].yp > 250){
entities[i].active = false;
};
};
break;
case 2:
if (entities[i].state == 0){
if (entities[i].xp > 500){
entities[i].active = false;
};
if (entities[i].xp < -200){
entities[i].active = false;
};
if (entities[i].yp < -200){
entities[i].active = false;
};
if (entities[i].yp > 450){
entities[i].active = false;
};
} else {
if (entities[i].state == 1){
game.score = (game.score + 50);
music.playef(0, 10);
if (nsimpleentity > 80){
j = 0;
while (j < 4) {
createsimpleentity(entities[i].xp, entities[i].yp, (help.cosine[((j * 16) + 4)] * 10), (help.sine[((j * 16) + 4)] * 10), 0, 1, 10, 0);
j++;
};
} else {
j = 0;
while (j < 16) {
createsimpleentity(entities[i].xp, entities[i].yp, (help.cosine[(j * 4)] * 10), (help.sine[(j * 4)] * 10), 0, 1, 10, 0);
j++;
};
};
entities[i].active = false;
};
};
break;
case 3:
if (entities[i].state == 0){
if (entities[i].xp > 500){
entities[i].active = false;
};
if (entities[i].xp < -200){
entities[i].active = false;
};
if (entities[i].yp < -200){
entities[i].active = false;
};
if (entities[i].yp > 450){
entities[i].active = false;
};
} else {
if (entities[i].state == 1){
music.playef(1, 10);
game.score = (game.score + 100);
if (nsimpleentity > 80){
j = 0;
while (j < 4) {
createsimpleentity(entities[i].xp, entities[i].yp, (help.cosine[((j * 16) + 4)] * 10), (help.sine[((j * 16) + 4)] * 10), 0, 1, 10, 0);
j++;
};
} else {
j = 0;
while (j < 16) {
createsimpleentity(entities[i].xp, entities[i].yp, (help.cosine[(j * 4)] * 10), (help.sine[(j * 4)] * 10), 0, 1, 10, 0);
j++;
};
};
entities[i].active = false;
};
};
break;
case 4:
if (entities[i].state == 0){
if (entities[i].xp > 500){
entities[i].active = false;
};
if (entities[i].xp < -200){
entities[i].active = false;
};
if (entities[i].yp < -200){
entities[i].active = false;
};
if (entities[i].yp > 450){
entities[i].active = false;
};
} else {
if (entities[i].state == 1){
music.playef(2, 10);
game.score = (game.score + 1000);
if (nsimpleentity > 80){
j = 0;
while (j < 4) {
createsimpleentity(entities[i].xp, entities[i].yp, (help.cosine[((j * 16) + 4)] * 10), (help.sine[((j * 16) + 4)] * 10), 0, 1, 10, 0);
j++;
};
} else {
j = 0;
while (j < 16) {
createsimpleentity(entities[i].xp, entities[i].yp, (help.cosine[(j * 4)] * 10), (help.sine[(j * 4)] * 10), 0, 1, 10, 0);
j++;
};
};
entities[i].active = false;
};
};
break;
case 5:
if (entities[i].state < 10){
entities[i].state = (entities[i].state + 2);
entities[i].statedelay = 10;
createentity(entities[i].xp, entities[i].yp, 29, 20, 20);
} else {
if (entities[i].state == 10){
createentity(entities[i].xp, entities[i].yp, 29, 20, 20);
createentity((entities[i].xp + 4), (entities[i].yp + 4), 29, 12, 12);
createentity((entities[i].xp + 8), (entities[i].yp + 8), 29, 4, 4);
createentity(entities[i].xp, entities[i].yp, 6);
entities[i].active = false;
};
};
break;
case 6:
if (entities[i].state == 0){
j = getplayer();
if (j > -1){
entities[i].vx = 0;
if (entities[i].xp < entities[j].xp){
entities[i].vx = 1;
};
if (entities[i].xp > entities[j].xp){
entities[i].vx = -1;
};
entities[i].vy = 0;
if (entities[i].yp < entities[j].yp){
entities[i].vy = 1;
};
if (entities[i].yp > entities[j].yp){
entities[i].vy = -1;
};
};
if (entities[i].xp > 500){
entities[i].active = false;
};
if (entities[i].xp < -200){
entities[i].active = false;
};
if (entities[i].yp < -200){
entities[i].active = false;
};
if (entities[i].yp > 450){
entities[i].active = false;
};
} else {
if (entities[i].state == 1){
music.playef(0, 10);
game.score = (game.score + 100);
if (nsimpleentity > 80){
j = 0;
while (j < 4) {
createsimpleentity(entities[i].xp, entities[i].yp, (help.cosine[((j * 16) + 4)] * 10), (help.sine[((j * 16) + 4)] * 10), 0, 1, 10, 0);
j++;
};
} else {
j = 0;
while (j < 16) {
createsimpleentity(entities[i].xp, entities[i].yp, (help.cosine[(j * 4)] * 10), (help.sine[(j * 4)] * 10), 0, 1, 10, 0);
j++;
};
};
entities[i].active = false;
};
};
break;
case 24:
if (entities[i].state == 0){
entities[i].behave--;
entities[i].xp = (entities[i].xp - 6);
entities[i].yp = (entities[i].yp - 6);
entities[i].w = (entities[i].w + 12);
entities[i].h = (entities[i].h + 12);
if (entities[i].w > 360){
entities[i].active = false;
};
if (entities[i].behave <= 0){
entities[i].active = false;
};
};
break;
};
} else {
entities[i].statedelay--;
if (entities[i].statedelay < 0){
entities[i].statedelay = 0;
};
};
};
return (true);
}
public function removeblockat(x:int, y:int):void{
i = 0;
while (i < nblocks) {
if ((((blocks[i].x == x)) && ((blocks[i].y == y)))){
removeblock(i);
};
i++;
};
}
public function checkblocks():Boolean{
i = 0;
while (i < nblocks) {
if (blocks[i].active){
if (blocks[i].type == BLOCK){
if (blocks[i].rect.intersects(temprect)){
return (true);
};
};
};
i++;
};
return (false);
}
public function init():void{
var entity:entclass;
var simpleentity:simpleentclass;
var block:blockclass;
nentity = 0;
nblocks = 0;
temprect = new Rectangle();
temprect2 = new Rectangle();
colpoint1 = new Point();
colpoint2 = new Point();
var z:Number = 0;
while (z < 500) {
entity = new entclass();
entities.push(entity);
simpleentity = new simpleentclass();
simpleentities.push(simpleentity);
block = new blockclass();
blocks.push(block);
z++;
};
}
public function createblock(t:int, xp:int=0, yp:int=0, w:int=0, h:int=0, trig:int=0):void{
if (nblocks == 0){
z = 0;
nblocks++;
} else {
i = 0;
z = -1;
while (i < nblocks) {
if (!blocks[i].active){
z = i;
i = nblocks;
};
i++;
};
if (z == -1){
z = nblocks;
nblocks++;
};
};
blocks[z].clear();
blocks[z].active = true;
switch (t){
case BLOCK:
blocks[z].type = BLOCK;
blocks[z].xp = xp;
blocks[z].yp = yp;
blocks[z].wp = w;
blocks[z].hp = h;
blocks[z].rectset(xp, yp, w, h);
nblocks++;
break;
case TRIGGER:
blocks[z].type = TRIGGER;
blocks[z].x = xp;
blocks[z].y = yp;
blocks[z].w = w;
blocks[z].h = h;
blocks[z].rectset(xp, yp, w, h);
blocks[z].trigger = trig;
nblocks++;
break;
case DAMAGE:
blocks[z].type = DAMAGE;
blocks[z].x = xp;
blocks[z].y = yp;
blocks[z].w = w;
blocks[z].h = h;
blocks[z].rectset(xp, yp, w, h);
nblocks++;
break;
};
}
public function gettype(t:int):Boolean{
var i:int;
while (i < nentity) {
if (entities[i].type == t){
return (true);
};
i++;
};
return (false);
}
public function createsimpleentity(xp:Number, yp:Number, vx:Number=0, vy:Number=0, t:int=0, size:int=0, life:int=0, c:int=0):void{
if (nsimpleentity == 0){
z = 0;
nsimpleentity++;
} else {
i = 0;
z = -1;
while (i < nsimpleentity) {
if (!simpleentities[i].active){
z = i;
i = nsimpleentity;
};
i++;
};
if (z == -1){
z = nsimpleentity;
nsimpleentity++;
};
};
simpleentities[z].clear();
simpleentities[z].active = true;
simpleentities[z].tile = t;
simpleentities[z].size = size;
simpleentities[z].colour = c;
simpleentities[z].life = life;
simpleentities[z].xp = xp;
simpleentities[z].yp = yp;
simpleentities[z].vx = vx;
simpleentities[z].vy = vy;
}
public function animateentities(game:gameclass, i:int):void{
if (entities[i].active){
if (entities[i].statedelay <= 0){
switch (entities[i].type){
default:
entities[i].drawframe = entities[i].tile;
entities[i].drawframe = (entities[i].drawframe + entities[i].dir);
break;
};
} else {
entities[i].statedelay--;
if (entities[i].statedelay < 0){
entities[i].statedelay = 0;
};
};
};
}
public function cleanup():void{
i = (nentity - 1);
while ((((i >= 0)) && (!(entities[i].active)))) {
nentity--;
i--;
};
}
public function checktrigger():int{
i = 0;
while (i < nentity) {
if (entities[i].rule == 0){
tempx = (entities[i].xp + entities[i].cx);
tempy = (entities[i].yp + entities[i].cy);
tempw = entities[i].w;
temph = entities[i].h;
rectset(tempx, tempy, tempw, temph);
j = 0;
while (j < nblocks) {
if ((((blocks[j].type == TRIGGER)) && (blocks[j].active))){
if (blocks[j].rect.intersects(temprect)){
activetrigger = blocks[j].trigger;
return (blocks[j].trigger);
};
};
j++;
};
};
i++;
};
return (-1);
}
public function removetrigger(t:int):void{
i = 0;
while (i < nblocks) {
if (blocks[i].type == TRIGGER){
if (blocks[i].trigger == t){
removeblock(i);
};
};
i++;
};
}
public function getplayer():int{
var i:int;
while (i < nentity) {
if (entities[i].type == 0){
return (i);
};
i++;
};
return (-1);
}
public function entitymapcollision(t:int, map:mapclass):void{
if (testwallsx(map, t, entities[t].newxp, entities[t].yp)){
entities[t].xp = entities[t].newxp;
} else {
if (entities[t].onwall > 0){
entities[t].state = entities[t].onwall;
};
if (entities[t].onxwall > 0){
entities[t].state = entities[t].onxwall;
};
};
if (testwallsy(map, t, entities[t].xp, entities[t].newyp)){
entities[t].yp = entities[t].newyp;
} else {
if (entities[t].onwall > 0){
entities[t].state = entities[t].onwall;
};
if (entities[t].onywall > 0){
entities[t].state = entities[t].onywall;
};
entities[t].jumpframe = 0;
};
}
public function entitycollisioncheck(gfx:graphicsclass, game:gameclass, map:mapclass, music:musicclass):void{
i = 0;
while (i < nentity) {
if (entities[i].active){
j = 0;
while (j < nentity) {
if (((((entities[j].active) && (!((entities[j].rule == 4))))) && (entities[j].harmful))){
if ((((entities[i].rule == 1)) && ((entities[j].rule == 2)))){
if (entitycollide(i, j)){
entities[j].state = entities[j].onentity;
entities[j].statedelay = 0;
entities[i].active = false;
};
};
if ((((entities[i].rule == 0)) && ((((entities[j].rule == 2)) || ((entities[j].rule == 3)))))){
if (entitycollide(i, j)){
entities[j].state = entities[j].onentity;
entities[j].statedelay = 0;
entities[i].active = false;
music.playef(3, 10);
game.deathseq = 60;
music.fadeout();
};
};
};
j++;
};
};
i++;
};
j = getplayer();
if (j > -1){
if (!testwallsx(map, j, entities[j].xp, entities[j].yp)){
entities[j].yp = (entities[j].yp - 3);
};
};
activetrigger = -1;
if (checktrigger() > -1){
game.state = activetrigger;
game.statedelay = 0;
};
}
public function testwallsx(map:mapclass, t:int, tx:int, ty:int):Boolean{
tempx = (tx + entities[t].cx);
tempy = (ty + entities[t].cy);
tempw = entities[t].w;
temph = entities[t].h;
rectset(tempx, tempy, tempw, temph);
if (checkwall(map)){
if (entities[t].vx > 1){
entities[t].vx--;
entities[t].newxp = int((entities[t].xp + entities[t].vx));
return (testwallsx(map, t, entities[t].newxp, entities[t].yp));
};
if (entities[t].vx < -1){
entities[t].vx++;
entities[t].newxp = int((entities[t].xp + entities[t].vx));
return (testwallsx(map, t, entities[t].newxp, entities[t].yp));
};
entities[t].vx = 0;
return (false);
};
return (true);
}
public function testwallsy(map:mapclass, t:int, tx:int, ty:int):Boolean{
tempx = (tx + entities[t].cx);
tempy = (ty + entities[t].cy);
tempw = entities[t].w;
temph = entities[t].h;
rectset(tempx, tempy, tempw, temph);
if (checkwall(map)){
if (entities[t].vy > 1){
entities[t].vy--;
entities[t].newyp = int((entities[t].yp + entities[t].vy));
return (testwallsy(map, t, entities[t].xp, entities[t].newyp));
};
if (entities[t].vy < -1){
entities[t].vy++;
entities[t].newyp = int((entities[t].yp + entities[t].vy));
return (testwallsy(map, t, entities[t].xp, entities[t].newyp));
};
entities[t].vy = 0;
return (false);
};
return (true);
}
public function checkwall(map:mapclass):Boolean{
if (checkblocks()){
return (true);
};
tempx = getgridpoint(temprect.x);
tempy = getgridpoint(temprect.y);
tempw = getgridpoint(((temprect.x + temprect.width) - 1));
temph = getgridpoint(((temprect.y + temprect.height) - 1));
if (map.collide(tempx, tempy)){
return (true);
};
if (map.collide(tempw, tempy)){
return (true);
};
if (map.collide(tempx, temph)){
return (true);
};
if (map.collide(tempw, temph)){
return (true);
};
if (temprect.height >= 12){
tpy1 = getgridpoint((temprect.y + 6));
if (map.collide(tempx, tpy1)){
return (true);
};
if (map.collide(tempw, tpy1)){
return (true);
};
if (temprect.height >= 18){
tpy1 = getgridpoint((temprect.y + 12));
if (map.collide(tempx, tpy1)){
return (true);
};
if (map.collide(tempw, tpy1)){
return (true);
};
if (temprect.height >= 24){
tpy1 = getgridpoint((temprect.y + 18));
if (map.collide(tempx, tpy1)){
return (true);
};
if (map.collide(tempw, tpy1)){
return (true);
};
};
};
};
if (temprect.width >= 12){
tpx1 = getgridpoint((temprect.x + 6));
if (map.collide(tpx1, tempy)){
return (true);
};
if (map.collide(tpx1, temph)){
return (true);
};
};
return (false);
}
public function rect2set(xi:int, yi:int, wi:int, hi:int):void{
temprect2.x = xi;
temprect2.y = yi;
temprect2.width = wi;
temprect2.height = hi;
}
public function createentity(xp:Number, yp:Number, t:int, vx:Number=0, vy:Number=0, para:int=0):void{
if (nentity == 0){
z = 0;
nentity++;
} else {
i = 0;
z = -1;
while (i < nentity) {
if (!entities[i].active){
z = i;
i = nentity;
};
i++;
};
if (z == -1){
z = nentity;
nentity++;
};
};
entities[z].clear();
entities[z].active = true;
entities[z].type = t;
switch (t){
case 0:
entities[z].rule = 0;
entities[z].tile = 0;
entities[z].xp = xp;
entities[z].yp = yp;
entities[z].cx = 6;
entities[z].cy = 4;
entities[z].w = 16;
entities[z].h = 10;
break;
case 1:
entities[z].rule = 1;
entities[z].tile = 4;
entities[z].xp = xp;
entities[z].yp = yp;
entities[z].vx = vx;
entities[z].vy = vy;
entities[z].cx = 0;
entities[z].cy = 0;
entities[z].w = 20;
entities[z].h = 20;
break;
case 2:
entities[z].rule = 2;
entities[z].tile = 5;
entities[z].xp = xp;
entities[z].yp = yp;
entities[z].vx = vx;
entities[z].vy = vy;
entities[z].cx = 0;
entities[z].cy = 0;
entities[z].w = (5 * 4);
entities[z].h = (5 * 4);
entities[z].onentity = 1;
entities[z].harmful = true;
break;
case 3:
entities[z].rule = 2;
entities[z].tile = 5;
entities[z].size = 1;
entities[z].xp = xp;
entities[z].yp = yp;
entities[z].vx = vx;
entities[z].vy = vy;
entities[z].cx = 0;
entities[z].cy = 0;
entities[z].w = (16 * 5);
entities[z].h = (16 * 5);
entities[z].onentity = 1;
entities[z].harmful = true;
break;
case 4:
entities[z].rule = 2;
entities[z].tile = 5;
entities[z].size = 2;
entities[z].xp = xp;
entities[z].yp = yp;
entities[z].vx = vx;
entities[z].vy = vy;
entities[z].cx = 0;
entities[z].cy = 0;
entities[z].w = (24 * 5);
entities[z].h = (24 * 5);
entities[z].onentity = 1;
entities[z].harmful = true;
break;
case 5:
entities[z].rule = 3;
entities[z].tile = 0;
entities[z].size = 4;
entities[z].xp = xp;
entities[z].yp = yp;
entities[z].vx = vx;
entities[z].vy = vy;
entities[z].cx = 0;
entities[z].cy = 0;
entities[z].w = (5 * 4);
entities[z].h = (5 * 4);
entities[z].onentity = 1;
entities[z].harmful = false;
break;
case 6:
entities[z].rule = 2;
entities[z].tile = 5;
entities[z].xp = xp;
entities[z].yp = yp;
entities[z].vx = vx;
entities[z].vy = vy;
entities[z].cx = 0;
entities[z].cy = 0;
entities[z].w = (5 * 4);
entities[z].h = (5 * 4);
entities[z].onentity = 1;
entities[z].harmful = true;
break;
case 28:
entities[z].type = 24;
entities[z].rule = 4;
entities[z].size = 3;
entities[z].tile = 0;
entities[z].xp = xp;
entities[z].yp = yp;
entities[z].w = vx;
entities[z].h = vy;
entities[z].behave = 30;
switch (int((Math.random() * 6))){
case 0:
entities[z].life = 0xFF0000;
break;
case 1:
entities[z].life = 0xFF00;
break;
case 2:
entities[z].life = 0xFF00FF;
break;
case 3:
entities[z].life = 0xFFFF00;
break;
case 4:
entities[z].life = 0xFF;
break;
case 5:
entities[z].life = 0xFFFF;
break;
default:
entities[z].life = 0xFFFFFF;
break;
};
break;
case 29:
entities[z].type = 24;
entities[z].rule = 4;
entities[z].size = 3;
entities[z].tile = 0;
entities[z].xp = (xp + 2);
entities[z].yp = (yp + 2);
entities[z].w = (vx - 4);
entities[z].h = (vy - 4);
entities[z].behave = 30;
switch (int((Math.random() * 6))){
case 0:
entities[z].life = 0;
break;
case 1:
entities[z].life = 0;
break;
case 2:
entities[z].life = 0;
break;
case 3:
entities[z].life = 0;
break;
case 4:
entities[z].life = 0;
break;
case 5:
entities[z].life = 0;
break;
default:
entities[z].life = 0;
break;
};
break;
};
}
public function removeallblocks():void{
i = 0;
while (i < nblocks) {
blocks[i].clear();
i++;
};
nblocks = 0;
}
public function applyfriction(t:int, xrate:Number, yrate:Number):void{
if (entities[t].vx > 0){
entities[t].vx = (entities[t].vx - xrate);
};
if (entities[t].vx < 0){
entities[t].vx = (entities[t].vx + xrate);
};
if (entities[t].vy > 0){
entities[t].vy = (entities[t].vy - yrate);
};
if (entities[t].vy < 0){
entities[t].vy = (entities[t].vy + yrate);
};
if (entities[t].vy > 4){
entities[t].vy = 4;
};
if (entities[t].vy < -4){
entities[t].vy = -4;
};
if (entities[t].vx > 4){
entities[t].vx = 4;
};
if (entities[t].vx < -4){
entities[t].vx = -4;
};
if (Math.abs(entities[t].vx) <= xrate){
entities[t].vx = 0;
};
if (Math.abs(entities[t].vy) <= yrate){
entities[t].vy = 0;
};
}
public function entitycollidefloor(map:mapclass, t:int):Boolean{
tempx = (entities[t].xp + entities[t].cx);
tempy = ((entities[t].yp + entities[t].cy) + 1);
tempw = entities[t].w;
temph = entities[t].h;
rectset(tempx, tempy, tempw, temph);
if (checkwall(map)){
return (true);
};
return (false);
}
public function updateentitylogic(t:int, game:gameclass):void{
entities[t].oldxp = entities[t].xp;
entities[t].oldyp = entities[t].yp;
entities[t].vx = (entities[t].vx + entities[t].ax);
entities[t].vy = (entities[t].vy + entities[t].ay);
entities[t].ax = 0;
if (entities[t].jumping){
if (entities[t].ay < 0){
entities[t].ay++;
};
if (entities[t].ay > -1){
entities[t].ay = 0;
};
entities[t].jumpframe--;
if (entities[t].jumpframe <= 0){
entities[t].jumping = false;
};
} else {
if (entities[t].gravity){
entities[t].ay = 3;
};
};
if (entities[t].gravity){
applyfriction(t, 0, 0.5);
};
entities[t].newxp = (entities[t].xp + entities[t].vx);
entities[t].newyp = (entities[t].yp + entities[t].vy);
}
public function getgridpoint(t:int):int{
t = ((t - (t % 16)) / 16);
return (t);
}
public function checkdamage():Boolean{
i = 0;
while (i < nentity) {
if (entities[i].rule == 0){
tempx = (entities[i].xp + entities[i].cx);
tempy = (entities[i].yp + entities[i].cy);
tempw = entities[i].w;
temph = entities[i].h;
rectset(tempx, tempy, tempw, temph);
j = 0;
while (j < nblocks) {
if ((((blocks[j].type == DAMAGE)) && (blocks[j].active))){
if (blocks[j].rect.intersects(temprect)){
return (true);
};
};
j++;
};
};
i++;
};
return (false);
}
public function entitycollide(a:int, b:int):Boolean{
tempx = (entities[a].xp + entities[a].cx);
tempy = (entities[a].yp + entities[a].cy);
tempw = entities[a].w;
temph = entities[a].h;
rectset(tempx, tempy, tempw, temph);
tempx = (entities[b].xp + entities[b].cx);
tempy = (entities[b].yp + entities[b].cy);
tempw = entities[b].w;
temph = entities[b].h;
rect2set(tempx, tempy, tempw, temph);
if (temprect.intersects(temprect2)){
return (true);
};
return (false);
}
public function updatesimpleentities(t:int):Boolean{
if (simpleentities[t].active){
simpleentities[t].vx = (simpleentities[t].vx + simpleentities[t].ax);
simpleentities[t].vy = (simpleentities[t].vy + simpleentities[t].ay);
simpleentities[t].ax = 0;
simpleentities[t].xp = (simpleentities[t].xp + simpleentities[t].vx);
simpleentities[t].yp = (simpleentities[t].yp + simpleentities[t].vy);
simpleentities[t].life--;
if (simpleentities[t].life <= 0){
simpleentities[t].active = false;
};
};
return (true);
}
public function rectset(xi:int, yi:int, wi:int, hi:int):void{
temprect.x = xi;
temprect.y = yi;
temprect.width = wi;
temprect.height = hi;
}
}
}//package
Section 14
//gameclass (gameclass)
package {
import flash.events.*;
import flash.display.*;
public class gameclass extends Sprite {
public var hascontrol:Boolean;
public var mutebutton:int;
public var newhighscore:Boolean;
public var state:int;
public var statedelay:int;
public var warningwave:int;
public var test:Boolean;
public var screenshake:int;
public var highscoretimer:int;
public var score:int;
public var teststring:String;
public var flashlight:int;
public var mx:int;
public var my:int;
public var paused:Boolean;
public var highscore:int;
public var jumppressed:int;
public var completestop:Boolean;
public var easydelay:int;
public var shootdelay:int;
public var infocus:Boolean;
public var globalsound:int;
public var gamestate:int;
public var jumpheld:Boolean;
public var i:int;
public var j:int;
public var muted:Boolean;
public var repeatstate:int;
public var warningsounddelay:int;
public var deathseq:int;
public var warningsound:int;
public static var GAMEMODE:Number = 0;
public static var TRIGGER:Number = 1;
public static var BLOCK:Number = 0;
public static var DAMAGE:Number = 2;
public function gameclass(obj:entityclass, music:musicclass):void{
super();
infocus = true;
paused = false;
muted = false;
globalsound = 1;
addEventListener(Event.DEACTIVATE, windowNotActive);
addEventListener(Event.ACTIVATE, windowActive);
gamestate = GAMEMODE;
completestop = false;
hascontrol = true;
jumpheld = false;
jumppressed = 0;
shootdelay = 0;
warningsound = 0;
warningsounddelay = 0;
newhighscore = false;
score = 0;
highscore = 3000;
highscoretimer = 0;
deathseq = 0;
test = false;
teststring = "TEST = True";
state = 0;
statedelay = 0;
updatestate(obj, music);
}
public function windowActive(e:Event):void{
infocus = true;
}
public function windowNotActive(e:Event):void{
infocus = false;
}
public function reset(obj:entityclass):void{
state = 0;
statedelay = 20;
obj.nentity = 0;
obj.nsimpleentity = 0;
warningwave = 4;
newhighscore = false;
}
public function start(obj:entityclass, music:musicclass):void{
obj.createentity(140, 110, 0);
}
public function updatestate(obj:entityclass, music:musicclass):void{
statedelay--;
if (statedelay <= 0){
statedelay = 0;
};
if (statedelay <= 0){
switch (state){
case 0:
if (warningwave <= 0){
state = (9 + (Math.random() * 11));
if (state > 18){
state = 18;
};
repeatstate = -1;
statedelay = (24 + 10);
warningwave = 4;
} else {
state = (50 + (Math.random() * 12));
warningwave--;
if (warningwave == 0){
warningsound = 4;
warningsounddelay = 0;
};
};
break;
case 1:
state = 0;
statedelay = 15;
break;
case 9:
i = 0;
while (i < 7) {
obj.createentity(325, (20 + (i * 30)), 2, -5, 0);
i++;
};
statedelay = 10;
if (repeatstate == -1){
repeatstate = 10;
};
repeatstate--;
state = 1;
if (repeatstate > 0){
state = 9;
};
break;
case 10:
i = 0;
while (i < 7) {
obj.createentity(-10, (20 + (i * 30)), 2, 5, 0);
i++;
};
statedelay = 10;
if (repeatstate == -1){
repeatstate = 10;
};
repeatstate--;
state = 1;
if (repeatstate > 0){
state = 10;
};
break;
case 11:
i = 0;
while (i < 12) {
obj.createentity((12 + (i * 25)), -20, 2, 0, 4);
i++;
};
statedelay = 10;
if (repeatstate == -1){
repeatstate = 10;
};
repeatstate--;
state = 1;
if (repeatstate > 0){
state = 11;
};
break;
case 12:
i = 0;
while (i < 12) {
obj.createentity((12 + (i * 25)), 242, 2, 0, -4);
i++;
};
statedelay = 10;
if (repeatstate == -1){
repeatstate = 10;
};
repeatstate--;
state = 1;
if (repeatstate > 0){
state = 12;
};
break;
case 13:
i = 0;
while (i < 3) {
obj.createentity(325, (20 + (i * 30)), 2, -5, 0);
i++;
};
i = 4;
while (i < 7) {
obj.createentity(-10, (20 + (i * 30)), 2, 5, 0);
i++;
};
statedelay = 10;
if (repeatstate == -1){
repeatstate = 10;
};
repeatstate--;
state = 1;
if (repeatstate > 0){
state = 13;
};
break;
case 14:
i = 4;
while (i < 7) {
obj.createentity(325, (20 + (i * 30)), 2, -5, 0);
i++;
};
i = 0;
while (i < 3) {
obj.createentity(-10, (20 + (i * 30)), 2, 5, 0);
i++;
};
statedelay = 10;
if (repeatstate == -1){
repeatstate = 10;
};
repeatstate--;
state = 1;
if (repeatstate > 0){
state = 14;
};
break;
case 15:
i = 0;
while (i < 7) {
obj.createentity((325 + (i * 20)), (20 + (i * 30)), 2, -5, 0);
i++;
};
statedelay = 10;
if (repeatstate == -1){
repeatstate = 4;
};
repeatstate--;
state = 1;
if (repeatstate > 0){
state = 15;
};
break;
case 16:
i = 0;
while (i < 12) {
obj.createentity((12 + (i * 25)), (242 + (i * 15)), 2, 0, -4);
i++;
};
statedelay = 10;
if (repeatstate == -1){
repeatstate = 4;
};
repeatstate--;
state = 1;
if (repeatstate > 0){
state = 16;
};
break;
case 17:
i = 0;
while (i < 2) {
obj.createentity(-60, (15 + (i * 120)), 3, 5, 0);
i++;
};
statedelay = 20;
if (repeatstate == -1){
repeatstate = 2;
};
repeatstate--;
state = 1;
if (repeatstate > 0){
state = 17;
};
break;
case 18:
obj.createentity(325, 45, 4, -5, 0);
statedelay = 25;
if (repeatstate == -1){
repeatstate = 0;
};
repeatstate--;
state = 1;
if (repeatstate > 0){
state = 18;
};
break;
case 50:
obj.createentity(((160 - 10) - 100), ((120 - 10) - 90), 5, 0, 0);
obj.createentity(((160 - 10) - 100), ((120 - 10) + 90), 5, 0, 0);
obj.createentity(((160 - 10) + 100), ((120 - 10) - 90), 5, 0, 0);
obj.createentity(((160 - 10) + 100), ((120 - 10) + 90), 5, 0, 0);
statedelay = 80;
state = 0;
break;
case 51:
obj.createentity(30, (30 + 30), 5, 0, 0);
obj.createentity(154, 30, 5, 0, 0);
obj.createentity(((320 - 30) - 10), (30 + 30), 5, 0, 0);
obj.createentity(30, (((240 - 30) - 10) - 30), 5, 0, 0);
obj.createentity(154, ((240 - 30) - 10), 5, 0, 0);
obj.createentity(((320 - 30) - 10), (((240 - 30) - 10) - 30), 5, 0, 0);
statedelay = 80;
state = 0;
break;
case 52:
obj.createentity(((160 - 10) - 20), ((120 - 10) - 20), 5, 0, 0);
obj.createentity(((160 - 10) - 20), ((120 - 10) + 20), 5, 0, 0);
obj.createentity(((160 - 10) + 20), ((120 - 10) - 20), 5, 0, 0);
obj.createentity(((160 - 10) + 20), ((120 - 10) + 20), 5, 0, 0);
statedelay = 80;
state = 0;
break;
case 53:
obj.createentity(((160 - 10) - 80), (120 - 10), 5, 0, 0);
obj.createentity(((160 - 10) + 80), (120 - 10), 5, 0, 0);
statedelay = 80;
state = 0;
break;
case 54:
obj.createentity((160 - 10), ((120 - 10) - 40), 5, 0, 0);
obj.createentity((160 - 10), ((120 - 10) + 40), 5, 0, 0);
statedelay = 80;
state = 0;
break;
case 55:
obj.createentity(((160 - 10) - 80), (120 - 10), 5, 0, 0);
obj.createentity(((160 - 10) + 80), (120 - 10), 5, 0, 0);
statedelay = 80;
state = 0;
break;
case 56:
i = 0;
while (i < 8) {
obj.createentity((((160 - 10) + (i * 30)) - 110), (120 - 10), 5, 0, 0);
i++;
};
statedelay = 80;
state = 0;
break;
case 57:
i = 0;
while (i < 6) {
obj.createentity((160 - 10), (((120 - 10) + (i * 40)) - 100), 5, 0, 0);
i++;
};
statedelay = 80;
state = 0;
break;
case 58:
obj.createentity(((160 - 10) + 80), ((120 - 10) - 40), 5, 0, 0);
obj.createentity(((160 - 10) + 110), ((120 - 10) - 40), 5, 0, 0);
obj.createentity(((160 - 10) + 80), ((120 - 10) - 70), 5, 0, 0);
obj.createentity(((160 - 10) + 110), ((120 - 10) - 70), 5, 0, 0);
statedelay = 80;
state = 0;
break;
case 59:
obj.createentity(((160 - 10) - 80), ((120 - 10) - 40), 5, 0, 0);
obj.createentity(((160 - 10) - 110), ((120 - 10) - 40), 5, 0, 0);
obj.createentity(((160 - 10) - 80), ((120 - 10) - 70), 5, 0, 0);
obj.createentity(((160 - 10) - 110), ((120 - 10) - 70), 5, 0, 0);
statedelay = 80;
state = 0;
break;
case 60:
obj.createentity(((160 - 10) - 80), ((120 - 10) + 40), 5, 0, 0);
obj.createentity(((160 - 10) - 110), ((120 - 10) + 40), 5, 0, 0);
obj.createentity(((160 - 10) - 80), ((120 - 10) + 70), 5, 0, 0);
obj.createentity(((160 - 10) - 110), ((120 - 10) + 70), 5, 0, 0);
statedelay = 80;
state = 0;
break;
case 61:
obj.createentity(((160 - 10) + 80), ((120 - 10) + 40), 5, 0, 0);
obj.createentity(((160 - 10) + 110), ((120 - 10) + 40), 5, 0, 0);
obj.createentity(((160 - 10) + 80), ((120 - 10) + 70), 5, 0, 0);
obj.createentity(((160 - 10) + 110), ((120 - 10) + 70), 5, 0, 0);
statedelay = 80;
state = 0;
break;
case 62:
case 63:
case 64:
case 65:
obj.createentity((160 - 10), ((120 - 10) - 40), 5, 0, 0);
obj.createentity((160 - 10), ((120 - 10) + 40), 5, 0, 0);
obj.createentity(((160 - 10) - 60), (((120 - 10) - 40) - 30), 5, 0, 0);
obj.createentity(((160 - 10) - 60), (((120 - 10) + 40) + 30), 5, 0, 0);
obj.createentity(((160 - 10) + 60), (((120 - 10) - 40) - 30), 5, 0, 0);
obj.createentity(((160 - 10) + 60), (((120 - 10) + 40) + 30), 5, 0, 0);
statedelay = 80;
state = 0;
break;
};
};
}
}
}//package
Section 15
//graphicsclass (graphicsclass)
package {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
public class graphicsclass extends Sprite {
public var bfontpos:int;
public var backgrounds:Array;
public var madrect:Rectangle;
public var sprites_rect:Rectangle;
public var cur:int;
public var fontheight:int;
public var buffer:BitmapData;
public var currentfont:String;
public var images_rect:Rectangle;
public var funkmeter:int;
public var tempshape:Shape;
public var sprites:Array;
public var bigbuffer:BitmapData;
public var ntextbox:int;
public var trect:Rectangle;
public var funktimer2:int;
public var tiles_rect:Rectangle;
public var i:int;
public var j:int;
public var k:int;
public var l:int;
public var madpoint:Point;
public var ct:ColorTransform;
public var z:int;
public var images:Array;
public var screen:Bitmap;
public var temptile:BitmapData;
public var textbox:Array;
public var alphamult:uint;
public var tiles:Array;
public var tl:Point;
public var tpoint:Point;
public var shapematrix:Matrix;
public var funkyroom:int;
public var scaleMatrix:Matrix;
public var screenbuffer:BitmapData;
public var bfont:Array;
public var bfont_rect:Rectangle;
public var bigbufferscreen:Bitmap;
public var tbuffer:BitmapData;
public var bfontlen:Array;
public var bfontmask_rect:Rectangle;
public var stemp:String;
public var updatebackground:Boolean;
public var fontwidth:int;
public var temp:int;
public var temp3:int;
public var temp2:int;
public var backbuffer:BitmapData;
public var funktimer:int;
public function graphicsclass(){
backgrounds = new Array();
images = new Array();
tiles = new Array();
sprites = new Array();
bfont = new Array();
bfontlen = new Array();
textbox = new Array();
scaleMatrix = new Matrix();
tempshape = new Shape();
shapematrix = new Matrix();
super();
}
public function createtextbox(t:String, xp:int, yp:int, r:int=0xFF, g:int=0xFF, b:int=0xFF):void{
if (ntextbox == 0){
z = 0;
ntextbox++;
} else {
i = 0;
z = -1;
while (i < ntextbox) {
if (!textbox[i].active){
z = i;
i = ntextbox;
};
i++;
};
if (z == -1){
z = ntextbox;
ntextbox++;
};
};
if (z < 20){
textbox[z].clear();
textbox[z].line[0] = t;
textbox[z].xp = xp;
if (xp == -1){
textbox[z].xp = (160 - (((t.length / 2) + 1) * 8));
};
textbox[z].yp = yp;
textbox[z].initcol(r, g, b);
textbox[z].resize();
};
}
public function textboxactive():void{
i = 0;
while (i < ntextbox) {
if (z != i){
textbox[i].remove();
};
i++;
};
}
public function drawentities(game:gameclass, obj:entityclass):void{
i = 0;
while (i < obj.nentity) {
obj.animateentities(game, i);
if (obj.entities[i].active){
if (obj.entities[i].size == 1){
if (!obj.entities[i].invis){
bigdrawsprite(obj.entities[i].xp, obj.entities[i].yp, obj.entities[i].drawframe, 16);
};
} else {
if (obj.entities[i].size == 2){
if (!obj.entities[i].invis){
bigdrawsprite(obj.entities[i].xp, obj.entities[i].yp, obj.entities[i].drawframe, 24);
};
} else {
if (obj.entities[i].size == 3){
if (obj.entities[i].active){
drawrectparticle(game, obj, i);
};
} else {
if (obj.entities[i].size == 4){
} else {
if (!obj.entities[i].invis){
bigdrawsprite(obj.entities[i].xp, obj.entities[i].yp, obj.entities[i].drawframe, 4);
};
};
};
};
};
};
i++;
};
}
public function makespritearray():void{
var i:Number;
var t:BitmapData;
var temprect:Rectangle;
var j:Number = 0;
while (j < 15) {
i = 0;
while (i < 20) {
t = new BitmapData(32, 32, true, 0);
temprect = new Rectangle((i * 32), (j * 32), 32, 32);
t.copyPixels(buffer, temprect, tl);
sprites.push(t);
i++;
};
j++;
};
}
public function drawbox(x1:int, y1:int, w1:int, h1:int, r:int, g:int, b:int):void{
settrect(x1, y1, w1, 1);
backbuffer.fillRect(trect, RGB(r, g, b));
settrect(x1, ((y1 + h1) - 1), w1, 1);
backbuffer.fillRect(trect, RGB(r, g, b));
settrect(x1, y1, 1, h1);
backbuffer.fillRect(trect, RGB(r, g, b));
settrect(((x1 + w1) - 1), y1, 1, h1);
backbuffer.fillRect(trect, RGB(r, g, b));
}
public function bigdrawsprite(x:int, y:int, t:int, sc:Number=2):void{
scaleMatrix.scale(sc, sc);
bigbuffer.fillRect(bigbuffer.rect, 0);
bigbuffer.copyPixels(sprites[t], sprites_rect, new Point(0, 0));
scaleMatrix.translate(x, y);
backbuffer.draw(bigbufferscreen, scaleMatrix);
scaleMatrix.identity();
}
public function init():void{
var t:textboxclass;
updatebackground = true;
tiles_rect = new Rectangle(0, 0, 16, 16);
sprites_rect = new Rectangle(0, 0, 32, 32);
trect = new Rectangle();
tpoint = new Point();
tbuffer = new BitmapData(1, 1, true);
tl = new Point(0, 0);
ct = new ColorTransform(0, 0, 0, 1, 0xFF, 0xFF, 0xFF, 1);
madpoint = new Point();
madrect = new Rectangle();
funkmeter = 0;
funktimer = 0;
funktimer2 = 0;
funkyroom = 0;
currentfont = "c64";
fontwidth = 8;
fontheight = 8;
if (currentfont == "terminal"){
fontheight = 12;
};
if (currentfont == "casual"){
fontheight = 16;
};
if (currentfont == "2xcrypt"){
fontwidth = 16;
fontheight = 16;
};
bfont_rect = new Rectangle(0, 0, fontwidth, fontheight);
bigbuffer = new BitmapData(320, 32, true, 0);
bigbufferscreen = new Bitmap(bigbuffer);
bigbufferscreen.width = 640;
bigbufferscreen.height = 64;
scaleMatrix = new Matrix();
i = 0;
while (i < 20) {
t = new textboxclass();
textbox.push(t);
i++;
};
ntextbox = 0;
backbuffer = new BitmapData(320, 240, false, 0);
screenbuffer = new BitmapData(320, 240, false, 0);
temptile = new BitmapData(16, 16, false, 0);
screen = new Bitmap(screenbuffer);
screen.width = 640;
screen.height = 480;
addChild(screen);
}
public function addline(t:String):void{
textbox[z].addline(t);
}
public function screenshake():void{
screenbuffer.lock();
screenbuffer.copyPixels(backbuffer, backbuffer.rect, tl, null, null, false);
screenbuffer.copyPixels(backbuffer, backbuffer.rect, new Point(((Math.random() * 5) - 3), ((Math.random() * 5) - 3)), null, null, false);
screenbuffer.unlock();
backbuffer.lock();
backbuffer.fillRect(backbuffer.rect, 0);
backbuffer.unlock();
}
public function funkybackground(t:int):void{
switch (t){
case 0:
funktimer--;
if (funktimer <= 0){
funktimer = 4;
funkmeter = ((funkmeter + 1) % 6);
};
backbuffer.copyPixels(images[funkmeter], new Rectangle(0, 0, images[funkmeter].width, images[funkmeter].height), new Point(0, 0));
break;
case 1:
funktimer--;
if (funktimer <= 0){
funktimer = 1;
funkmeter = ((funkmeter + 3) % 32);
};
backbuffer.copyPixels(images[6], new Rectangle(0, 0, images[6].width, images[6].height), new Point(funkmeter, 0));
backbuffer.copyPixels(images[6], new Rectangle(0, 0, images[6].width, images[6].height), new Point((funkmeter - 320), 0));
break;
case 2:
funktimer--;
if (funktimer <= 0){
funktimer = 1;
funkmeter = ((funkmeter + 9) % 74);
};
backbuffer.copyPixels(images[0], new Rectangle(0, 0, images[0].width, images[0].height), new Point(0, funkmeter));
backbuffer.copyPixels(images[0], new Rectangle(0, 0, images[0].width, images[0].height), new Point(0, (funkmeter - 240)));
break;
case 3:
funktimer--;
if (funktimer <= 0){
funktimer = 2;
funkmeter = ((funkmeter + 1) % 2);
};
backbuffer.copyPixels(images[(funkmeter + 2)], new Rectangle(0, 0, images[funkmeter].width, images[funkmeter].height), new Point(0, 0));
break;
case 4:
funktimer--;
if (funktimer <= 0){
funktimer = 1;
funkmeter = ((funkmeter + 3) % 80);
};
backbuffer.copyPixels(images[7], new Rectangle(0, 0, images[7].width, images[7].height), new Point(funkmeter, (funkmeter * 2)));
backbuffer.copyPixels(images[7], new Rectangle(0, 0, images[7].width, images[7].height), new Point((funkmeter - 320), 0));
backbuffer.copyPixels(images[7], new Rectangle(0, 0, images[7].width, images[7].height), new Point((funkmeter - 320), ((funkmeter * 2) - 240)));
backbuffer.copyPixels(images[7], new Rectangle(0, 0, images[7].width, images[7].height), new Point(funkmeter, -60));
break;
};
}
public function len(t:String):int{
bfontpos = 0;
var i:int;
while (i < t.length) {
cur = t.charCodeAt(i);
bfontpos = (bfontpos + bfontlen[cur]);
i++;
};
return (bfontpos);
}
public function rbigprint(x:int, y:int, t:String, r:int, g:int, b:int, cen:Boolean=false, sc:Number=2):void{
x = (x - (len(t) * sc));
bigprint(x, y, t, r, g, b, cen, sc);
}
public function flashlight():void{
backbuffer.fillRect(backbuffer.rect, 9383213);
}
public function drawbuffertile(x:int, y:int, t:int):void{
buffer.copyPixels(tiles[t], tiles_rect, new Point(x, y));
}
public function settrect(x:int, y:int, w:int, h:int):void{
trect.x = x;
trect.y = y;
trect.width = w;
trect.height = h;
}
public function drawline(x1:int, y1:int, x2:int, y2:int, r:int, g:int, b:int):void{
if (x1 > x2){
drawline(x2, y1, x1, y2, r, g, b);
} else {
if (y1 > y2){
drawline(x1, y2, x2, y1, r, g, b);
} else {
tempshape.graphics.clear();
tempshape.graphics.lineStyle(1, RGB(r, g, b));
tempshape.graphics.lineTo((x2 - x1), (y2 - y1));
shapematrix.translate(x1, y1);
backbuffer.draw(tempshape, shapematrix);
shapematrix.translate(-(x1), -(y1));
};
};
}
public function normalrender():void{
screenbuffer.lock();
screenbuffer.copyPixels(backbuffer, backbuffer.rect, tl, null, null, false);
screenbuffer.unlock();
backbuffer.lock();
backbuffer.fillRect(backbuffer.rect, 0);
backbuffer.unlock();
}
public function maketilearray():void{
var i:Number;
var t:BitmapData;
var temprect:Rectangle;
var j:Number = 0;
while (j < 15) {
i = 0;
while (i < 20) {
t = new BitmapData(16, 16, true, 0);
temprect = new Rectangle((i * 16), (j * 16), 16, 16);
t.copyPixels(buffer, temprect, tl);
tiles.push(t);
i++;
};
j++;
};
}
public function textboxcenter():void{
textbox[z].centerx();
textbox[z].centery();
}
public function addimage():void{
var t:BitmapData = new BitmapData(buffer.width, buffer.height, true, 0);
t.copyPixels(buffer, new Rectangle(0, 0, buffer.width, buffer.height), tl);
images.push(t);
}
public function textboxcleanup():void{
i = (ntextbox - 1);
while ((((i >= 0)) && (!(textbox[i].active)))) {
ntextbox--;
i--;
};
}
public function drawbackground(t:int):void{
backbuffer.copyPixels(backgrounds[t], backbuffer.rect, tl);
}
public function adjustletter(t1:int, d:int=1):void{
bfontlen[t1] = (bfontlen[t1] + d);
bfontlen[(t1 + 32)] = (bfontlen[(t1 + 32)] + d);
}
public function drawgui():void{
textboxcleanup();
i = 0;
while (i < ntextbox) {
textbox[i].update();
if (textbox[i].active){
if (textbox[i].ismenu){
backbuffer.fillRect(textbox[i].textrect, RGB((textbox[i].r / 6), (textbox[i].g / 6), (textbox[i].b / 6)));
j = 0;
while (j < textbox[i].numlines) {
if (textbox[i].highlighted == j){
print((textbox[i].xp + 2), ((textbox[i].yp + fontheight) + (j * fontheight)), ">", (0xFF - help.glow), (0xFF - help.glow), (0xFF - help.glow));
print((textbox[i].xp + 8), ((textbox[i].yp + fontheight) + (j * fontheight)), textbox[i].line[j], (0xFF - help.glow), (0xFF - help.glow), (0xFF - help.glow));
} else {
print((textbox[i].xp + 8), ((textbox[i].yp + fontheight) + (j * fontheight)), textbox[i].line[j], (textbox[i].r * 0.5), (textbox[i].g * 0.5), (textbox[i].b * 0.5));
};
j++;
};
} else {
backbuffer.fillRect(textbox[i].textrect, RGB((textbox[i].r / 6), (textbox[i].g / 6), (textbox[i].b / 6)));
j = 0;
while (j < textbox[i].numlines) {
print((textbox[i].xp + 8), ((textbox[i].yp + fontheight) + (j * fontheight)), textbox[i].line[j], textbox[i].r, textbox[i].g, textbox[i].b);
j++;
};
};
};
i++;
};
}
public function rprint(x:int, y:int, t:String, r:int, g:int, b:int):void{
x = (x - len(t));
print(x, y, t, r, g, b, false);
}
public function settpoint(x:int, y:int):void{
tpoint.x = x;
tpoint.y = y;
}
public function adjustcharacter(t1:int, d:int=1):void{
bfontlen[t1] = (bfontlen[t1] + d);
}
public function textboxremove():void{
i = 0;
while (i < ntextbox) {
textbox[i].remove();
i++;
};
}
public function textboxsetmenu():void{
textbox[z].ismenu = true;
}
public function textboxcenterx():void{
textbox[z].centerx();
}
public function textboxcentery():void{
textbox[z].centery();
}
public function textboxtimer(t:int):void{
textbox[z].timer = t;
}
public function makebfont():void{
var maprow:Array;
var tstring:String;
var k:int;
j = 0;
while (j < 16) {
i = 0;
while (i < 16) {
tbuffer = new BitmapData(fontwidth, fontheight, true, 0);
settrect((i * fontwidth), (j * fontheight), fontwidth, fontheight);
tbuffer.copyPixels(buffer, trect, tl);
bfont.push(tbuffer);
i++;
};
j++;
};
if (currentfont == "small"){
i = 0;
while (i < 0x0100) {
bfontlen.push(6);
i++;
};
tstring = "4,3,5,7,6,7,6,3,4,4,7,7,3,5,2,5,6,5,6,6,6,6,6,6,6,6,2,3,5,5,5,6,7,6,6,6,6,5,5,6,6,3,6,6,5,7,7,6,6,6,6,6,5,6,7,7,7,7,5,4,5,4,5,6,4,6,6,6,6,5,5,6,6,3,6,6,5,7,7,6,6,6,6,6,5,6,7,7,7,7,5,5,3,5,6,4";
maprow = new Array();
maprow = tstring.split(",");
k = 0;
while (k < 96) {
bfontlen[(k + 32)] = int(maprow[k]);
k++;
};
} else {
if (currentfont == "tiny"){
i = 0;
while (i < 0x0100) {
bfontlen.push(4);
i++;
};
adjustletter("I".charCodeAt(0), -2);
adjustletter("M".charCodeAt(0), 2);
adjustletter("N".charCodeAt(0));
adjustletter("W".charCodeAt(0), 2);
adjustcharacter(" ".charCodeAt(0), -1);
adjustcharacter(".".charCodeAt(0), -1);
adjustcharacter(",".charCodeAt(0), -1);
adjustcharacter(";".charCodeAt(0), -1);
adjustcharacter(":".charCodeAt(0), -1);
adjustcharacter("'".charCodeAt(0), -2);
adjustcharacter("&".charCodeAt(0));
adjustcharacter("*".charCodeAt(0), 2);
adjustcharacter("4".charCodeAt(0));
} else {
if (currentfont == "flixel"){
i = 0;
while (i < 0x0100) {
bfontlen.push(6);
i++;
};
adjustletter("I".charCodeAt(0), -3);
adjustletter("J".charCodeAt(0), -1);
adjustletter("K".charCodeAt(0));
adjustletter("L".charCodeAt(0), -1);
adjustletter("M".charCodeAt(0), 2);
adjustletter("N".charCodeAt(0));
adjustletter("O".charCodeAt(0));
adjustletter("Q".charCodeAt(0));
adjustletter("S".charCodeAt(0), -1);
adjustletter("T".charCodeAt(0));
adjustletter("V".charCodeAt(0));
adjustletter("W".charCodeAt(0), 2);
adjustletter("X".charCodeAt(0));
adjustletter("Y".charCodeAt(0));
adjustcharacter("c".charCodeAt(0), -1);
adjustcharacter("f".charCodeAt(0), -2);
adjustcharacter("k".charCodeAt(0), -1);
adjustcharacter("l".charCodeAt(0), -2);
adjustcharacter("m".charCodeAt(0));
adjustcharacter("n".charCodeAt(0), -1);
adjustcharacter("o".charCodeAt(0), -1);
adjustcharacter("q".charCodeAt(0), -1);
adjustcharacter("r".charCodeAt(0), -1);
adjustcharacter("t".charCodeAt(0), -3);
adjustcharacter("v".charCodeAt(0), -1);
adjustcharacter("x".charCodeAt(0), -1);
adjustcharacter("y".charCodeAt(0), -1);
adjustcharacter("'".charCodeAt(0), -4);
adjustcharacter(".".charCodeAt(0), -2);
adjustcharacter(",".charCodeAt(0), -2);
adjustcharacter("&".charCodeAt(0));
adjustcharacter(" ".charCodeAt(0), -1);
} else {
if (currentfont == "04b11"){
i = 0;
while (i < 0x0100) {
bfontlen.push(7);
i++;
};
adjustcharacter(" ".charCodeAt(0), -2);
adjustcharacter("i".charCodeAt(0), -4);
adjustcharacter("l".charCodeAt(0), -4);
adjustcharacter("j".charCodeAt(0), -2);
adjustcharacter("m".charCodeAt(0), 2);
adjustcharacter("w".charCodeAt(0), 2);
adjustcharacter(",".charCodeAt(0), -4);
adjustcharacter(".".charCodeAt(0), -4);
adjustcharacter("'".charCodeAt(0), -4);
adjustcharacter("1".charCodeAt(0), -3);
adjustcharacter("!".charCodeAt(0), -4);
adjustcharacter("$".charCodeAt(0), 1);
adjustcharacter("^".charCodeAt(0), -2);
adjustcharacter("[".charCodeAt(0), -3);
adjustcharacter("]".charCodeAt(0), -3);
adjustcharacter("(".charCodeAt(0), -3);
adjustcharacter(")".charCodeAt(0), -3);
adjustcharacter("I".charCodeAt(0), -2);
adjustcharacter("M".charCodeAt(0), 1);
adjustcharacter("W".charCodeAt(0), 2);
} else {
if (currentfont == "crypt"){
i = 0;
while (i < 0x0100) {
bfontlen.push(5);
i++;
};
} else {
if (currentfont == "2xcrypt"){
i = 0;
while (i < 0x0100) {
bfontlen.push(10);
i++;
};
} else {
if (currentfont == "starperv"){
i = 0;
while (i < 0x0100) {
bfontlen.push(6);
i++;
};
} else {
if (currentfont == "casual"){
i = 0;
while (i < 0x0100) {
bfontlen.push(8);
i++;
};
adjustcharacter("i".charCodeAt(0), -4);
adjustcharacter("j".charCodeAt(0), -2);
adjustcharacter("l".charCodeAt(0), -3);
adjustcharacter("f".charCodeAt(0), -1);
adjustcharacter("m".charCodeAt(0), 2);
adjustcharacter("w".charCodeAt(0));
adjustcharacter("'".charCodeAt(0), -4);
adjustcharacter(".".charCodeAt(0), -2);
adjustcharacter(",".charCodeAt(0), -2);
} else {
i = 0;
while (i < 0x0100) {
bfontlen.push(8);
i++;
};
};
};
};
};
};
};
};
};
}
public function addbackground():void{
var t:BitmapData = new BitmapData(160, 144, true, 0);
t.copyPixels(buffer, backbuffer.rect, tl);
backgrounds.push(t);
}
public function render(game:gameclass):void{
if (game.test){
print(5, 5, game.teststring, 196, 196, 196, false);
};
if (game.flashlight > 0){
game.flashlight--;
flashlight();
};
if (game.screenshake > 0){
game.screenshake--;
screenshake();
} else {
normalrender();
};
}
public function drawimage(t:int, xp:int, yp:int, cent:Boolean=false):void{
if (cent){
backbuffer.copyPixels(images[t], new Rectangle(0, 0, images[t].width, images[t].height), new Point((80 - int((images[t].width / 2))), yp));
} else {
backbuffer.copyPixels(images[t], new Rectangle(0, 0, images[t].width, images[t].height), new Point(xp, yp));
};
}
public function drawmap(map:mapclass):void{
j = 0;
while (j < 15) {
i = 0;
while (i < 20) {
drawtile((i * 16), (j * 16), map.at(i, j));
i++;
};
j++;
};
}
public function RGB(red:Number, green:Number, blue:Number):Number{
return (((blue | (green << 8)) | (red << 16)));
}
public function drawrectparticle(game:gameclass, obj:entityclass, i:int):void{
madrect.x = obj.entities[i].xp;
madrect.y = obj.entities[i].yp;
madrect.width = obj.entities[i].w;
madrect.height = 3;
backbuffer.fillRect(madrect, obj.entities[i].life);
madrect.x = obj.entities[i].xp;
madrect.y = obj.entities[i].yp;
madrect.width = 3;
madrect.height = obj.entities[i].h;
backbuffer.fillRect(madrect, obj.entities[i].life);
madrect.x = ((obj.entities[i].xp + obj.entities[i].w) - 3);
madrect.y = obj.entities[i].yp;
madrect.width = 3;
madrect.height = obj.entities[i].h;
backbuffer.fillRect(madrect, obj.entities[i].life);
madrect.x = obj.entities[i].xp;
madrect.y = ((obj.entities[i].yp + obj.entities[i].h) - 3);
madrect.width = obj.entities[i].w;
madrect.height = 3;
backbuffer.fillRect(madrect, obj.entities[i].life);
}
public function print(x:int, y:int, t:String, r:int, g:int, b:int, cen:Boolean=false):void{
if (r < 0){
r = 0;
};
if (g < 0){
g = 0;
};
if (b < 0){
b = 0;
};
if (r > 0xFF){
r = 0xFF;
};
if (g > 0xFF){
g = 0xFF;
};
if (b > 0xFF){
b = 0xFF;
};
ct.color = RGB(r, g, b);
if (cen){
x = (160 - (len(t) / 2));
};
bfontpos = 0;
var i:int;
while (i < t.length) {
cur = t.charCodeAt(i);
bfont[cur].colorTransform(bfont_rect, ct);
backbuffer.copyPixels(bfont[cur], bfont_rect, new Point((x + bfontpos), y));
bfontpos = (bfontpos + bfontlen[cur]);
i++;
};
}
public function drawsimpleentities(obj:entityclass):void{
i = 0;
while (i < obj.nsimpleentity) {
if (obj.simpleentities[i].active){
if (obj.simpleentities[i].size == 1){
settrect(obj.simpleentities[i].xp, obj.simpleentities[i].yp, 20, 20);
setcol(obj.simpleentities[i].colour);
backbuffer.fillRect(trect, ct.color);
} else {
if (obj.simpleentities[i].size == 2){
} else {
settpoint(obj.simpleentities[i].xp, obj.simpleentities[i].yp);
setcol(obj.simpleentities[i].colour);
sprites[obj.simpleentities[i].tile].colorTransform(sprites_rect, ct);
backbuffer.copyPixels(sprites[obj.simpleentities[i].tile], sprites_rect, tpoint);
};
};
};
i++;
};
}
public function bigprint(x:int, y:int, t:String, r:int, g:int, b:int, cen:Boolean=false, sc:Number=2):void{
if (r < 0){
r = 0;
};
if (g < 0){
g = 0;
};
if (b < 0){
b = 0;
};
if (r > 0xFF){
r = 0xFF;
};
if (g > 0xFF){
g = 0xFF;
};
if (b > 0xFF){
b = 0xFF;
};
ct.color = RGB(r, g, b);
scaleMatrix.scale(sc, sc);
bigbuffer.fillRect(bigbuffer.rect, 0);
ct.color = RGB(r, g, b);
if (sc == 2){
if (cen){
x = (160 - len(t));
};
} else {
if (sc == 3){
if (cen){
x = (160 - ((len(t) / 2) * 3));
};
} else {
if (sc == 4){
if (cen){
x = (160 - (len(t) * 2));
};
} else {
if (cen){
x = (160 - ((len(t) / 2) * sc));
};
};
};
};
bfontpos = 0;
i = 0;
while (i < t.length) {
cur = t.charCodeAt(i);
bfont[cur].colorTransform(bfont_rect, ct);
bigbuffer.copyPixels(bfont[cur], bfont_rect, new Point(bfontpos, 0));
bfontpos = (bfontpos + bfontlen[cur]);
i++;
};
scaleMatrix.translate(x, y);
backbuffer.draw(bigbufferscreen, scaleMatrix);
scaleMatrix.identity();
}
public function setcol(t:int):void{
ct.color = 0;
}
public function fillrect(x1:int, y1:int, w1:int, h1:int, r:int, g:int, b:int):void{
settrect(x1, y1, w1, h1);
backbuffer.fillRect(trect, RGB(r, g, b));
}
public function drawtile(x:int, y:int, t:int):void{
backbuffer.copyPixels(tiles[t], tiles_rect, new Point(x, y));
}
}
}//package
Section 16
//help (help)
package {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
public class help {
public static var sine:Array;
public static var slowsine:int;
public static var glow:int;
public static var globaltemp2:int;
public static var globaltemp3:int;
public static var glowdir:int;
public static var globaltemp:int;
public static var cosine:Array;
public function help(){
super();
}
public static function threedigits(t:int):String{
if (t < 10){
return (("00" + String(t)));
};
if (t < 100){
return (("0" + String(t)));
};
return (String(t));
}
public static function inbox(xc:int, yc:int, x1:int, y1:int, x2:int, y2:int):Boolean{
if ((((xc >= x1)) && ((xc <= x2)))){
if ((((yc >= y1)) && ((yc <= y2)))){
return (true);
};
};
return (false);
}
public static function number(t:int):String{
switch (t){
case 0:
return ("Zero");
case 1:
return ("One");
case 2:
return ("Two");
case 3:
return ("Three");
case 4:
return ("Four");
case 5:
return ("Five");
case 6:
return ("Six");
case 7:
return ("Seven");
case 8:
return ("Eight");
case 9:
return ("Nine");
case 10:
return ("Ten");
case 11:
return ("Eleven");
case 12:
return ("Twelve");
case 13:
return ("Thirteen");
case 14:
return ("Fourteen");
case 15:
return ("Fifteen");
case 16:
return ("Sixteen");
case 17:
return ("Seventeen");
case 18:
return ("Eighteen");
case 19:
return ("Nineteen");
case 20:
return ("Twenty");
case 21:
return ("Twenty One");
};
return ("Some");
}
public static function init():void{
sine = new Array();
cosine = new Array();
var i:int;
while (i < 64) {
sine[i] = Math.sin(((i * 6.283) / 64));
cosine[i] = Math.cos(((i * 6.283) / 64));
i++;
};
glow = 0;
glowdir = 0;
slowsine = 0;
}
public static function updateglow():void{
slowsine++;
if (slowsine >= 64){
slowsine = 0;
};
if (glowdir == 0){
glow = (glow + 2);
if (glow >= 62){
glowdir = 1;
};
} else {
glow = (glow - 2);
if (glow < 2){
glowdir = 0;
};
};
}
public static function thousand(t:int):String{
var temp:int;
if (t < 1000){
return (("$" + String(t)));
};
if (t < 1000000){
return (((("$" + String(((t - (t % 1000)) / 1000))) + ",") + threedigits((t % 1000))));
};
temp = ((t - (t % 1000)) / 1000);
return (((((("$" + String(((temp - (temp % 1000)) / 1000))) + ",") + threedigits((temp % 1000))) + ",") + threedigits((t % 1000))));
}
public static function opa(t:int):int{
return (((t + 32) % 64));
}
public static function removeObject(obj:Object, arr:Array):void{
var i:String;
for (i in arr) {
if (arr[i] == obj){
arr.splice(i, 1);
break;
};
};
}
public static function inboxw(xc:int, yc:int, x1:int, y1:int, x2:int, y2:int):Boolean{
if ((((xc >= x1)) && ((xc <= (x1 + x2))))){
if ((((yc >= y1)) && ((yc <= (y1 + y2))))){
return (true);
};
};
return (false);
}
}
}//package
Section 17
//kongapi (kongapi)
package {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.system.*;
public class kongapi {
public static var haskey:Boolean;
public static var loggedin:int;
public static var notboughtgame:Boolean;
public static var service;
public static var apitimeout:int;
public static var boughtgame:Boolean;
public static var loadcomplete:Boolean;
public function kongapi(){
super();
}
public static function guestcheck():void{
service.services.addEventListener("login", onKongregateInPageLogin);
}
private static function loaded(event:Event):void{
loadcomplete = true;
service = event.target.content;
service.services.connect();
}
public static function getusername():String{
if (loadcomplete){
return (service.services.getUsername());
};
return ("Guest");
}
public static function isguest():Boolean{
if (loadcomplete){
return (service.services.isGuest());
};
return (true);
}
public static function init(paramObj:Object, swfStage:Stage):void{
loadcomplete = false;
apitimeout = 60;
loggedin = 0;
var api_url:String = ((paramObj.api_path) || ("http://www.kongregate.com/flash/API_AS3_Local.swf"));
Security.allowDomain(api_url);
var request:URLRequest = new URLRequest(api_url);
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
loader.load(request);
swfStage.addChild(loader);
}
public static function submit(name:String, value:int):void{
if (loadcomplete){
service.stats.submit(name, value);
};
}
public static function onKongregateInPageLogin(event:Event):void{
if (loggedin == 0){
loggedin = 1;
};
}
}
}//package
Section 18
//Main (Main)
package {
import bigroom.input.*;
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.geom.*;
import flash.media.*;
import flash.net.*;
import flash.ui.*;
public class Main extends Sprite {
private var ef_0:Class;
private var ef_1:Class;
private var ef_2:Class;
private var ef_3:Class;
private var ef_4:Class;
private var ef_5:Class;
public var music:musicclass;
private var _current:Number;// = 0
public var CLICKTOSTART:int;// = 2
private var im_sprites:Class;
private var _timer:Timer;
public var FOCUSMODE:int;// = 3
public var map:mapclass;
public var key:KeyPoll;
private var _skip:Number;
public var i:int;
public var k:int;
public var j:int;
public var pixel2:uint;
private var _last:Number;// = -1
public var gfx:graphicsclass;
public var pixel:uint;
public var GAMEMODE:int;// = 0
public var slogo:MovieClip;
private var im_tiles:Class;
private var im_image0:Class;
private var im_image1:Class;
private var im_image2:Class;
private var im_image4:Class;
private var im_image5:Class;
private var im_image7:Class;
private var _delta:Number;// = 0
private var im_image3:Class;
private var _rate:Number;// = 16
private var im_image6:Class;
public var logoposition:Matrix;
public var TITLEMODE:int;// = 1
private var im_bfont:Class;
public var temp:int;
public var game:gameclass;
public var obj:entityclass;
public var pi:uint;
public var pj:uint;
public static const TARGET_FPS:Number = 60;
public static var TRIGGER:Number = 1;
public static var BLOCK:Number = 0;
public static var DAMAGE:Number = 2;
public function Main(){
this._rate = 16;
this._rate = 16;
this._rate = 16;
this.gfx = new graphicsclass();
this.music = new musicclass();
this.map = new mapclass();
this.obj = new entityclass();
this._skip = (this._rate * 10);
this._timer = new Timer(4);
this.im_tiles = Main_im_tiles;
this.im_sprites = Main_im_sprites;
this.im_bfont = Main_im_bfont;
this.im_image0 = Main_im_image0;
this.im_image1 = Main_im_image1;
this.im_image2 = Main_im_image2;
this.im_image3 = Main_im_image3;
this.im_image4 = Main_im_image4;
this.im_image5 = Main_im_image5;
this.im_image6 = Main_im_image6;
this.im_image7 = Main_im_image7;
this.ef_0 = Main_ef_0;
this.ef_1 = Main_ef_1;
this.ef_2 = Main_ef_2;
this.ef_3 = Main_ef_3;
this.ef_4 = Main_ef_4;
this.ef_5 = Main_ef_5;
super();
if (stage){
init();
} else {
addEventListener(Event.ADDED_TO_STAGE, this.gameinit);
};
}
private function gameinit(_arg1:Event=null):void{
var tempbmp:Bitmap;
var rc_menu:ContextMenu;
var credit:ContextMenuItem;
removeEventListener(Event.ADDED_TO_STAGE, this.gameinit);
if (this.sitelock()){
rc_menu = new ContextMenu();
credit = new ContextMenuItem("Visit distractionware.com");
credit.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, this.visit_distractionware);
rc_menu.hideBuiltInItems();
rc_menu.customItems.push(credit);
this.contextMenu = rc_menu;
this.obj.init();
this.key = new KeyPoll(stage);
SoundMixer.soundTransform = new SoundTransform(1);
this.music.currentsong = -1;
this.music.musicfade = 0;
this.music.initefchannels();
this.music.currentefchan = 0;
this.music.numplays = 0;
this.music.musicchan.push(new nice_song());
this.music.musicchan.push(new title_song());
this.music.musicchan.push(new slow_song());
this.music.musicchan.push(new nasty_song());
this.music.musicchan.push(new between_song());
this.music.play(0);
this.music.efchan.push(new this.ef_0());
this.music.efchan.push(new this.ef_1());
this.music.efchan.push(new this.ef_2());
this.music.efchan.push(new this.ef_3());
this.music.efchan.push(new this.ef_4());
this.music.efchan.push(new this.ef_5());
this.game = new gameclass(this.obj, this.music);
this.game.gamestate = this.TITLEMODE;
this.music.play(0);
this.gfx.init();
tempbmp = new this.im_tiles();
this.gfx.buffer = tempbmp.bitmapData;
this.gfx.maketilearray();
tempbmp = new this.im_sprites();
this.gfx.buffer = tempbmp.bitmapData;
this.gfx.makespritearray();
tempbmp = new this.im_bfont();
this.gfx.buffer = tempbmp.bitmapData;
this.gfx.makebfont();
tempbmp = new this.im_image0();
this.gfx.buffer = tempbmp.bitmapData;
this.gfx.addimage();
tempbmp = new this.im_image1();
this.gfx.buffer = tempbmp.bitmapData;
this.gfx.addimage();
tempbmp = new this.im_image2();
this.gfx.buffer = tempbmp.bitmapData;
this.gfx.addimage();
tempbmp = new this.im_image3();
this.gfx.buffer = tempbmp.bitmapData;
this.gfx.addimage();
tempbmp = new this.im_image4();
this.gfx.buffer = tempbmp.bitmapData;
this.gfx.addimage();
tempbmp = new this.im_image5();
this.gfx.buffer = tempbmp.bitmapData;
this.gfx.addimage();
tempbmp = new this.im_image6();
this.gfx.buffer = tempbmp.bitmapData;
this.gfx.addimage();
tempbmp = new this.im_image7();
this.gfx.buffer = tempbmp.bitmapData;
this.gfx.addimage();
this.gfx.buffer = new BitmapData(320, 240, false, 0);
addChild(this.gfx);
this._timer.addEventListener(TimerEvent.TIMER, this.mainloop);
this._timer.start();
} else {
this.gfx.init();
addChild(this.gfx);
tempbmp = new this.im_bfont();
this.gfx.buffer = tempbmp.bitmapData;
this.gfx.makebfont();
this.gfx.buffer = new BitmapData(320, 240, false, 0);
addEventListener(Event.ENTER_FRAME, this.lockedloop);
};
}
public function titlelogic(_arg1:KeyPoll, _arg2:graphicsclass, _arg3:mapclass, _arg4:gameclass, _arg5:entityclass, _arg6:musicclass):void{
if (_arg4.newhighscore){
_arg4.newhighscore = false;
kongapi.submit("Highscore", _arg4.highscore);
};
}
public function gamerender(_arg1:KeyPoll, _arg2:graphicsclass, _arg3:mapclass, _arg4:gameclass, _arg5:entityclass):void{
_arg2.funkybackground(_arg2.funkyroom);
_arg2.drawentities(_arg4, _arg5);
_arg2.drawsimpleentities(_arg5);
if (_arg4.score == _arg4.highscore){
if ((Math.random() * 100) > 50){
_arg2.bigprint(-1, 100, String(_arg4.score), 0xFF, 0, 0, true, 6);
} else {
_arg2.bigprint(-1, 100, String(_arg4.score), 0, 0, 0, true, 6);
};
} else {
_arg2.bigprint(-1, 218, String(_arg4.score), 0, 0, 0, true, 3);
};
if (_arg4.warningwave <= 0){
if ((Math.random() * 100) > 50){
_arg2.bigprint((5 + int((Math.random() * 5))), (10 + int((Math.random() * 5))), "INCOMING", 0xFF, 0, 0, true, 5);
_arg2.bigprint((5 + int((Math.random() * 5))), (195 + int((Math.random() * 5))), "INCOMING", 0xFF, 0, 0, true, 5);
} else {
_arg2.bigprint((5 + int((Math.random() * 5))), (10 + int((Math.random() * 5))), "INCOMING", 0, 0, 0, true, 5);
_arg2.bigprint((5 + int((Math.random() * 5))), (195 + int((Math.random() * 5))), "INCOMING", 0, 0, 0, true, 5);
};
};
_arg2.render(_arg4);
}
public function sitelock():Boolean{
var currUrl:String = stage.loaderInfo.url.toLowerCase();
if ((((currUrl.indexOf("distractionware.com") <= 0)) && ((currUrl.indexOf("kongregate.com") <= 0)))){
return (true);
};
return (true);
}
public function gameinput(_arg1:KeyPoll, _arg2:graphicsclass, _arg3:mapclass, _arg4:gameclass, _arg5:entityclass, _arg6:musicclass):void{
this.i = 0;
while (this.i < _arg2.ntextbox) {
if (_arg2.textbox[this.i].active){
if (_arg2.textbox[this.i].ismenu){
_arg2.textbox[this.i].highlighted = -1;
if (help.inboxw(_arg4.mx, _arg4.my, _arg2.textbox[this.i].textrect.x, _arg2.textbox[this.i].textrect.y, _arg2.textbox[this.i].textrect.width, _arg2.textbox[this.i].textrect.height)){
_arg2.textbox[this.i].highlighted = (_arg4.my - (_arg2.textbox[this.i].textrect.y + 8));
_arg2.textbox[this.i].highlighted = (_arg2.textbox[this.i].highlighted / 8);
};
if (_arg1.click){
if (_arg2.textbox[this.i].highlighted == 2){
_arg4.test = true;
};
};
};
};
this.i++;
};
this.i = 0;
while (this.i < _arg5.nentity) {
if (_arg5.entitycollidefloor(_arg3, this.i)){
_arg5.entities[this.i].onground = 2;
} else {
_arg5.entities[this.i].onground--;
};
if (_arg5.entities[this.i].rule == 0){
if (_arg4.hascontrol){
if (!(_arg1.isDown(90))){
_arg4.jumpheld = false;
};
if (_arg1.isDown(90)){
_arg4.jumpheld = true;
};
if (_arg4.jumppressed > 0){
_arg4.jumppressed--;
};
if (((_arg1.isDown(Keyboard.LEFT)) || (_arg1.isDown(65)))){
if (_arg5.entities[this.i].xp > 0){
_arg5.entities[this.i].vx = -6;
} else {
_arg5.entities[this.i].vx = 0;
};
if (!(_arg4.jumpheld)){
_arg5.entities[this.i].dir = 0;
};
} else {
if (((_arg1.isDown(Keyboard.RIGHT)) || (_arg1.isDown(68)))){
if (_arg5.entities[this.i].xp < 285){
_arg5.entities[this.i].vx = 6;
} else {
_arg5.entities[this.i].vx = 0;
};
if (!(_arg4.jumpheld)){
_arg5.entities[this.i].dir = 1;
};
} else {
_arg5.entities[this.i].vx = 0;
};
};
if (((_arg1.isDown(Keyboard.UP)) || (_arg1.isDown(87)))){
if (_arg5.entities[this.i].yp > 0){
_arg5.entities[this.i].vy = -6;
} else {
_arg5.entities[this.i].vy = 0;
};
if (!(_arg4.jumpheld)){
_arg5.entities[this.i].dir = 2;
};
} else {
if (((_arg1.isDown(Keyboard.DOWN)) || (_arg1.isDown(83)))){
if (_arg5.entities[this.i].yp < 220){
_arg5.entities[this.i].vy = 6;
} else {
_arg5.entities[this.i].vy = 0;
};
if (!(_arg4.jumpheld)){
_arg5.entities[this.i].dir = 3;
};
} else {
_arg5.entities[this.i].vy = 0;
};
};
if (!(_arg4.jumpheld)){
_arg2.funkyroom = _arg5.entities[this.i].dir;
_arg6.play((_arg5.entities[this.i].dir + 1));
};
if (_arg4.shootdelay <= 0){
switch (_arg5.entities[this.i].dir){
case 0:
default:
_arg5.createentity(_arg5.entities[this.i].xp, _arg5.entities[this.i].yp, 1, -20);
_arg5.createentity(_arg5.entities[this.i].xp, _arg5.entities[this.i].yp, 1, -20, -4);
_arg5.createentity(_arg5.entities[this.i].xp, _arg5.entities[this.i].yp, 1, -20, 4);
break;
case 1:
_arg5.createentity(_arg5.entities[this.i].xp, _arg5.entities[this.i].yp, 1, 20);
_arg5.createentity(_arg5.entities[this.i].xp, _arg5.entities[this.i].yp, 1, 20, -4);
_arg5.createentity(_arg5.entities[this.i].xp, _arg5.entities[this.i].yp, 1, 20, 4);
break;
case 2:
_arg5.createentity((_arg5.entities[this.i].xp + 16), _arg5.entities[this.i].yp, 1, 0, -20);
_arg5.createentity((_arg5.entities[this.i].xp + 16), _arg5.entities[this.i].yp, 1, -4, -20);
_arg5.createentity((_arg5.entities[this.i].xp + 16), _arg5.entities[this.i].yp, 1, 4, -20);
break;
case 3:
_arg5.createentity((_arg5.entities[this.i].xp + 16), _arg5.entities[this.i].yp, 1, 0, 20);
_arg5.createentity((_arg5.entities[this.i].xp + 16), _arg5.entities[this.i].yp, 1, -4, 20);
_arg5.createentity((_arg5.entities[this.i].xp + 16), _arg5.entities[this.i].yp, 1, 4, 20);
};
_arg4.shootdelay = 5;
} else {
_arg4.shootdelay--;
};
};
};
this.i++;
};
}
public function visit_sponsor(_arg1:Event):void{
var sponsor_link:URLRequest = new URLRequest("http://www.kongregate.com/?gamereferral=dontlookback");
navigateToURL(sponsor_link, "_blank");
}
public function visit_sponsor_logo():void{
var sponsor_link:URLRequest = new URLRequest("http://www.kongregate.com/?gamereferral=dontlookback");
navigateToURL(sponsor_link, "_blank");
}
public function visit_distractionware(_arg1:Event):void{
var distractionware_link:URLRequest = new URLRequest("http://www.distractionware.com");
navigateToURL(distractionware_link, "_blank");
}
public function logic():void{
if (!(this.game.infocus)){
if (this.game.globalsound > 0){
this.game.globalsound = 0;
SoundMixer.soundTransform = new SoundTransform(0);
};
this.music.processmusic();
help.updateglow();
} else {
switch (this.game.gamestate){
case this.TITLEMODE:
default:
this.titlelogic(this.key, this.gfx, this.map, this.game, this.obj, this.music);
break;
case this.GAMEMODE:
this.gamelogic(this.key, this.gfx, this.map, this.game, this.obj, this.music);
};
this.music.processmusic();
help.updateglow();
if (((this.key.isDown(77)) && ((this.game.mutebutton <= 0)))){
this.game.mutebutton = 8;
if (this.game.muted){
this.game.muted = false;
} else {
this.game.muted = true;
};
};
if (this.game.mutebutton > 0){
this.game.mutebutton--;
};
if (this.game.muted){
if (this.game.globalsound == 1){
this.game.globalsound = 0;
SoundMixer.soundTransform = new SoundTransform(0);
};
};
if (((!(this.game.muted)) && ((this.game.globalsound == 0)))){
this.game.globalsound = 1;
SoundMixer.soundTransform = new SoundTransform(1);
};
};
}
public function titleinput(_arg1:KeyPoll, _arg2:graphicsclass, _arg3:mapclass, _arg4:gameclass, _arg5:entityclass, _arg6:musicclass):void{
if (!(_arg1.isDown(90))){
_arg4.jumpheld = false;
};
if (_arg1.isDown("1".charCodeAt(0))){
_arg6.play(0);
};
if (_arg1.isDown("2".charCodeAt(0))){
_arg6.play(1);
};
if (_arg1.isDown("3".charCodeAt(0))){
_arg6.play(2);
};
if (_arg1.isDown("4".charCodeAt(0))){
_arg6.play(3);
};
if (_arg1.isDown("5".charCodeAt(0))){
_arg6.play(4);
};
if (((((((_arg1.isDown(90)) || (_arg1.isDown(32)))) || (_arg1.isDown(86)))) && (!(_arg4.jumpheld)))){
_arg4.reset(_arg5);
_arg4.gamestate = this.GAMEMODE;
_arg4.start(_arg5, _arg6);
_arg4.score = 0;
};
}
public function render():void{
this.gfx.backbuffer.lock();
if (!(this.game.infocus)){
this.gfx.bigprint(5, 105, "Game paused", (0xFF - (help.glow / 2)), (0xFF - (help.glow / 2)), (0xFF - (help.glow / 2)), true);
this.gfx.print(5, 125, "[click to resume]", (196 - (help.glow / 2)), (196 - (help.glow / 2)), (196 - (help.glow / 2)), true);
this.gfx.print(5, 230, "Press M to mute", (0xFF - (help.glow / 2)), (0xFF - (help.glow / 2)), (0xFF - (help.glow / 2)), true);
this.gfx.normalrender();
} else {
switch (this.game.gamestate){
case this.TITLEMODE:
default:
this.titlerender(this.key, this.gfx, this.map, this.game, this.obj);
break;
case this.GAMEMODE:
this.gamerender(this.key, this.gfx, this.map, this.game, this.obj);
break;
case this.CLICKTOSTART:
this.gfx.print(5, 115, "[Click to start]", (0xFF - (help.glow / 2)), (0xFF - (help.glow / 2)), (0xFF - (help.glow / 2)), true);
this.gfx.normalrender();
};
};
}
public function gamelogic(_arg1:KeyPoll, _arg2:graphicsclass, _arg3:mapclass, _arg4:gameclass, _arg5:entityclass, _arg6:musicclass):void{
_arg4.updatestate(_arg5, _arg6);
if (_arg4.warningsound > 0){
_arg4.warningsounddelay--;
if (_arg4.warningsounddelay <= 0){
_arg6.playef(5);
_arg4.warningsound--;
_arg4.warningsounddelay = 25;
};
};
if (_arg4.deathseq == 0){
_arg4.score = (_arg4.score + 10);
};
if (_arg4.score >= _arg4.highscore){
_arg4.highscore = _arg4.score;
_arg4.newhighscore = true;
_arg4.highscoretimer--;
if (_arg4.highscoretimer <= 0){
_arg4.highscoretimer = 20;
_arg6.playef(4, 10);
};
};
if (!(_arg4.completestop)){
this.i = 0;
while (this.i < _arg5.nsimpleentity) {
_arg5.updatesimpleentities(this.i);
this.i++;
};
this.i = 0;
while (this.i < _arg5.nentity) {
_arg5.updateentities(this.i, _arg4, _arg6);
_arg5.updateentitylogic(this.i, _arg4);
_arg5.entitymapcollision(this.i, _arg3);
this.i++;
};
_arg5.entitycollisioncheck(_arg2, _arg4, _arg3, _arg6);
};
_arg5.cleanup();
if (_arg4.deathseq == 1){
_arg4.warningsound = 0;
_arg4.warningsounddelay = 0;
_arg4.deathseq = 0;
_arg4.gamestate = 1;
_arg6.play(0);
} else {
if (_arg4.deathseq > 1){
_arg4.deathseq--;
};
};
}
public function lockedloop(_arg1:Event):void{
this.gfx.backbuffer.lock();
this.gfx.print(5, 110, "Sorry! This game can only by played on", (196 - help.glow), (196 - help.glow), (0xFF - help.glow), true);
this.gfx.print(5, 120, "www.kongregate.com", (196 - help.glow), (196 - help.glow), (0xFF - help.glow), true);
this.gfx.normalrender();
this.gfx.backbuffer.unlock();
help.updateglow();
}
public function input():void{
if (this.game.infocus){
this.game.mx = (mouseX / 2);
this.game.my = (mouseY / 2);
switch (this.game.gamestate){
case this.TITLEMODE:
default:
this.titleinput(this.key, this.gfx, this.map, this.game, this.obj, this.music);
break;
case this.GAMEMODE:
this.gameinput(this.key, this.gfx, this.map, this.game, this.obj, this.music);
break;
case this.CLICKTOSTART:
if (this.key.click){
this.game.gamestate = this.TITLEMODE;
};
};
};
}
public function mainloop(_arg1:TimerEvent):void{
this._current = getTimer();
if (this._last < 0){
this._last = this._current;
};
this._delta = (this._delta + (this._current - this._last));
this._last = this._current;
if (this._delta >= this._rate){
this._delta = (this._delta % this._skip);
while (this._delta >= this._rate) {
this._delta = (this._delta - this._rate);
this.input();
this.logic();
if (this.key.hasclicked){
this.key.click = false;
};
};
this.render();
_arg1.updateAfterEvent();
};
}
public function titlerender(_arg1:KeyPoll, _arg2:graphicsclass, _arg3:mapclass, _arg4:gameclass, _arg5:entityclass):void{
_arg2.funkybackground(4);
_arg2.bigprint(5, 80, "memrrtiks, suashem", 0, 0, 0, true);
_arg2.bigprint(5, 180, "highscore", 0, 0, 0, true);
_arg2.bigprint(-1, 200, String(_arg4.highscore), 0, 0, 0, true, 5);
_arg2.drawgui();
_arg2.render(_arg4);
}
}
}//package
Section 19
//Main_ef_0 (Main_ef_0)
package {
import mx.core.*;
public class Main_ef_0 extends SoundAsset {
}
}//package
Section 20
//Main_ef_1 (Main_ef_1)
package {
import mx.core.*;
public class Main_ef_1 extends SoundAsset {
}
}//package
Section 21
//Main_ef_2 (Main_ef_2)
package {
import mx.core.*;
public class Main_ef_2 extends SoundAsset {
}
}//package
Section 22
//Main_ef_3 (Main_ef_3)
package {
import mx.core.*;
public class Main_ef_3 extends SoundAsset {
}
}//package
Section 23
//Main_ef_4 (Main_ef_4)
package {
import mx.core.*;
public class Main_ef_4 extends SoundAsset {
}
}//package
Section 24
//Main_ef_5 (Main_ef_5)
package {
import mx.core.*;
public class Main_ef_5 extends SoundAsset {
}
}//package
Section 25
//Main_im_bfont (Main_im_bfont)
package {
import mx.core.*;
public class Main_im_bfont extends BitmapAsset {
}
}//package
Section 26
//Main_im_image0 (Main_im_image0)
package {
import mx.core.*;
public class Main_im_image0 extends BitmapAsset {
}
}//package
Section 27
//Main_im_image1 (Main_im_image1)
package {
import mx.core.*;
public class Main_im_image1 extends BitmapAsset {
}
}//package
Section 28
//Main_im_image2 (Main_im_image2)
package {
import mx.core.*;
public class Main_im_image2 extends BitmapAsset {
}
}//package
Section 29
//Main_im_image3 (Main_im_image3)
package {
import mx.core.*;
public class Main_im_image3 extends BitmapAsset {
}
}//package
Section 30
//Main_im_image4 (Main_im_image4)
package {
import mx.core.*;
public class Main_im_image4 extends BitmapAsset {
}
}//package
Section 31
//Main_im_image5 (Main_im_image5)
package {
import mx.core.*;
public class Main_im_image5 extends BitmapAsset {
}
}//package
Section 32
//Main_im_image6 (Main_im_image6)
package {
import mx.core.*;
public class Main_im_image6 extends BitmapAsset {
}
}//package
Section 33
//Main_im_image7 (Main_im_image7)
package {
import mx.core.*;
public class Main_im_image7 extends BitmapAsset {
}
}//package
Section 34
//Main_im_sprites (Main_im_sprites)
package {
import mx.core.*;
public class Main_im_sprites extends BitmapAsset {
}
}//package
Section 35
//Main_im_tiles (Main_im_tiles)
package {
import mx.core.*;
public class Main_im_tiles extends BitmapAsset {
}
}//package
Section 36
//mapclass (mapclass)
package {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
public class mapclass {
public var contents:Array;
public var vmult:Array;
public var tmap:Array;
public var i:int;
public var j:int;
public var k:int;
public var temp2:int;
public var background:int;
public var temp:int;
public function mapclass():void{
contents = new Array();
vmult = new Array();
tmap = new Array();
super();
i = 0;
while (i < 15) {
vmult.push(int((i * 20)));
i++;
};
j = 0;
while (j < 15) {
i = 0;
while (i < 20) {
contents.push(0);
i++;
};
j++;
};
}
public function loadlevel(r:int, obj:entityclass):void{
switch (r){
case 0:
tmap = new Array();
tmap.push("1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1");
tmap.push("1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1");
tmap.push("1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1");
tmap.push("1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1");
tmap.push("1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1");
tmap.push("1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1");
tmap.push("1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1");
tmap.push("1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,1,1,1,1");
tmap.push("1,1,1,2,2,2,2,1,1,1,1,1,1,1,2,2,2,2,1,1");
tmap.push("1,1,1,2,2,2,2,2,1,1,1,1,1,1,2,2,2,2,2,2");
tmap.push("1,1,1,2,2,2,2,2,2,2,1,1,1,2,2,2,2,2,2,2");
tmap.push("2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2");
tmap.push("2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2");
tmap.push("2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2");
tmap.push("2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2");
fillcontent(tmap);
break;
};
}
public function fillcontent(tmap:Array):void{
var maprow:Array;
j = 0;
while (j < 15) {
maprow = new Array();
maprow = tmap[j].split(",");
i = 0;
while (i < 20) {
contents[(i + vmult[j])] = maprow[i];
i++;
};
j++;
};
}
public function at(xp:int, yp:int):int{
if ((((((((xp >= 0)) && ((yp >= 0)))) && ((xp < 20)))) && ((yp < 15)))){
return (contents[(xp + vmult[yp])]);
};
return (0);
}
public function collide(x:int, y:int):Boolean{
if ((((((((x < 0)) || ((y < 0)))) || ((x >= 20)))) || ((y >= 14)))){
return (false);
};
if (contents[(x + vmult[y])] == 2){
return (true);
};
return (false);
}
}
}//package
Section 37
//musicclass (musicclass)
package {
import flash.events.*;
import flash.display.*;
import flash.media.*;
public class musicclass {
public var musicchannel:SoundChannel;
public var musicfadein:int;
public var currentsong:int;
public var efchannel:Array;
public var musicfade:int;
public var currentefchan:int;
public var efchan:Array;
public var musicchan:Array;
public var numplays:int;
public function musicclass(){
musicchan = new Array();
efchannel = new Array();
efchan = new Array();
super();
}
public function loopmusic(e:Event):void{
musicchannel.removeEventListener(Event.SOUND_COMPLETE, loopmusic);
if (currentsong > -1){
musicchannel = musicchan[currentsong].play();
musicchannel.addEventListener(Event.SOUND_COMPLETE, loopmusic);
};
}
public function stop():void{
musicchannel.removeEventListener(Event.SOUND_COMPLETE, stopmusic);
musicchannel.stop();
currentsong = -1;
}
public function initefchannels():void{
var i:int;
while (i < 16) {
efchannel.push(new SoundChannel());
i++;
};
}
public function processmusicfade():void{
musicfade--;
if (musicfade > 0){
musicchannel.soundTransform = new SoundTransform((musicfade / 30));
} else {
musicchannel.stop();
currentsong = -1;
};
}
public function playef(t:int, offset:int=0):void{
efchannel[currentefchan] = efchan[t].play(offset);
currentefchan++;
if (currentefchan > 15){
currentefchan = (currentefchan - 16);
};
}
public function processmusic():void{
if (musicfade > 0){
processmusicfade();
};
if (musicfadein > 0){
processmusicfadein();
};
}
public function fadeout():void{
if (musicfade == 0){
musicfade = 31;
};
}
public function stopmusic(e:Event):void{
musicchannel.removeEventListener(Event.SOUND_COMPLETE, stopmusic);
musicchannel.stop();
currentsong = -1;
}
public function play(t:int):void{
if (currentsong != t){
if (currentsong != -1){
musicchannel.stop();
musicchannel.removeEventListener(Event.SOUND_COMPLETE, loopmusic);
};
if (t != -1){
currentsong = t;
musicchannel = musicchan[currentsong].play(0);
musicchannel.addEventListener(Event.SOUND_COMPLETE, loopmusic);
} else {
currentsong = -1;
};
};
}
public function processmusicfadein():void{
musicfadein--;
if (musicfadein > 0){
musicchannel.soundTransform = new SoundTransform(((60 - musicfadein) / 60));
} else {
musicchannel.soundTransform = new SoundTransform(1);
};
}
}
}//package
Section 38
//nasty_song (nasty_song)
package {
import flash.media.*;
public dynamic class nasty_song extends Sound {
}
}//package
Section 39
//nice_song (nice_song)
package {
import flash.media.*;
public dynamic class nice_song extends Sound {
}
}//package
Section 40
//Preloader (Preloader)
package {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.ui.*;
import flash.net.*;
import mochi.as3.*;
import flash.utils.*;
public dynamic class Preloader extends MovieClip {
public var stagewidth:int;
public var bfontpos:int;
public var loadercol:int;
public var adson:Boolean;
public var screenheight:int;
public var tpoint:Point;
public var screenbuffer:BitmapData;
public var bfont:Array;
public var bfont_rect:Rectangle;
public var stageheight:int;
public var frontcol:int;
public var temprect:Rectangle;
public var backcol:int;
public var buffer:BitmapData;
public var bfontlen:Array;
public var cur:int;
public var startgame:Boolean;
private var im_bfont:Class;
public var screenwidth:int;
public var temp:int;
public var tempstring:String;
public var screen:Bitmap;
public var ct:ColorTransform;
public var backbuffer:BitmapData;
public var tl:Point;
public var onkong:Boolean;
public function Preloader(){
var tempbmp:Bitmap;
bfontlen = new Array();
bfont = new Array();
im_bfont = Preloader_im_bfont;
super();
onkong = true;
adson = false;
screenwidth = 320;
screenheight = 240;
stagewidth = 640;
stageheight = 480;
backcol = RGB(0, 0xFF, 0);
frontcol = RGB(0xFF, 0, 0xFF);
loadercol = RGB(0xFF, 0, 0xFF);
if (adson){
if (checksite()){
adson = false;
} else {
adson = true;
};
};
if (onkong){
kongapi.init(loaderInfo.parameters, stage);
};
help.init();
if (adson){
};
var rc_menu:ContextMenu = new ContextMenu();
rc_menu.hideBuiltInItems();
this.contextMenu = rc_menu;
ct = new ColorTransform(0, 0, 0, 1, 0xFF, 0xFF, 0xFF, 1);
temprect = new Rectangle();
tl = new Point(0, 0);
tpoint = new Point(0, 0);
bfont_rect = new Rectangle(0, 0, 8, 8);
tempbmp = new im_bfont();
buffer = tempbmp.bitmapData;
makebfont();
backbuffer = new BitmapData(screenwidth, screenheight, false, 0);
screenbuffer = new BitmapData(screenwidth, screenheight, false, 0);
screen = new Bitmap(screenbuffer);
screen.width = stagewidth;
screen.height = stageheight;
addChild(screen);
addEventListener(Event.ENTER_FRAME, checkFrame);
startgame = false;
}
public function makebfont():void{
var i:Number;
var t:BitmapData;
var t2emprect:Rectangle;
var j:Number = 0;
while (j < 16) {
i = 0;
while (i < 16) {
t = new BitmapData(8, 8, true, 0);
t2emprect = new Rectangle((i * 8), (j * 8), 8, 8);
t.copyPixels(buffer, t2emprect, tl);
bfont.push(t);
i++;
};
j++;
};
i = 0;
while (i < 0x0100) {
bfontlen.push(6);
i++;
};
var k:int;
while (k < 96) {
bfontlen[(k + 32)] = 8;
k++;
};
}
public function len(t:String):int{
bfontpos = 0;
var i:int;
while (i < t.length) {
cur = t.charCodeAt(i);
bfontpos = (bfontpos + bfontlen[cur]);
i++;
};
return (bfontpos);
}
public function rprintcol(x:int, y:int, t:String, col:int, cen:Boolean=false):void{
printcol((x - len(t)), y, t, col, false);
}
public function visit_sponsor(e:Event):void{
var sponsor_link:URLRequest = new URLRequest("http://www.kongregate.com/?gamereferral=dontlookback");
navigateToURL(sponsor_link, "_blank");
}
public function print(x:int, y:int, t:String, r:int, g:int, b:int, cen:Boolean=false):void{
if (r < 0){
r = 0;
};
if (g < 0){
g = 0;
};
if (b < 0){
b = 0;
};
if (r > 0xFF){
r = 0xFF;
};
if (g > 0xFF){
g = 0xFF;
};
if (b > 0xFF){
b = 0xFF;
};
ct.color = RGB(r, g, b);
if (cen){
x = ((screenwidth - len(t)) / 2);
};
bfontpos = 0;
var i:int;
while (i < t.length) {
cur = t.charCodeAt(i);
tpoint.x = (x + bfontpos);
tpoint.y = y;
bfont[cur].colorTransform(bfont_rect, ct);
backbuffer.copyPixels(bfont[cur], bfont_rect, tpoint);
bfontpos = (bfontpos + bfontlen[cur]);
i++;
};
}
public function printcol(x:int, y:int, t:String, col:int, cen:Boolean=false):void{
ct.color = col;
if (cen){
x = ((screenwidth - len(t)) / 2);
};
bfontpos = 0;
var i:int;
while (i < t.length) {
cur = t.charCodeAt(i);
tpoint.x = (x + bfontpos);
tpoint.y = y;
bfont[cur].colorTransform(bfont_rect, ct);
backbuffer.copyPixels(bfont[cur], bfont_rect, tpoint);
bfontpos = (bfontpos + bfontlen[cur]);
i++;
};
}
public function RGB(red:Number, green:Number, blue:Number):Number{
return (((blue | (green << 8)) | (red << 16)));
}
public function checkFrame(e:Event):void{
var p:Number = (this.loaderInfo.bytesLoaded / this.loaderInfo.bytesTotal);
if (p >= 1){
startgame = true;
};
backbuffer.fillRect(backbuffer.rect, backcol);
temp = int((p * (screenwidth - 114)));
fillrect(55, ((screenheight / 2) - 13), (screenwidth - 110), 12, frontcol);
fillrect(57, ((screenheight / 2) - 11), (screenwidth - 114), 8, backcol);
fillrect(57, ((screenheight / 2) - 11), temp, 8, loadercol);
tempstring = "LOADING...";
printcol(70, ((screenheight / 2) + 7), tempstring, frontcol, false);
tempstring = (String(int((p * 100))) + "%");
rprintcol((screenwidth - 70), ((screenheight / 2) + 7), tempstring, frontcol, false);
screenbuffer.lock();
screenbuffer.copyPixels(backbuffer, backbuffer.rect, tl, null, null, false);
screenbuffer.unlock();
backbuffer.lock();
backbuffer.fillRect(backbuffer.rect, 0);
backbuffer.unlock();
if (currentFrame >= totalFrames){
if (startgame){
startup();
};
};
}
public function visit_distractionware(e:Event):void{
var distractionware_link:URLRequest = new URLRequest("http://www.distractionware.com");
navigateToURL(distractionware_link, "_blank");
}
public function checksite():Boolean{
var currUrl:String = stage.loaderInfo.url.toLowerCase();
if ((((((((currUrl.indexOf("distractionware.com") <= 0)) && ((currUrl.indexOf("flashgamelicense.com") <= 0)))) && ((currUrl.indexOf("kongregate.com") <= 0)))) && ((currUrl.indexOf("chat.kongregate.com") <= 0)))){
return (false);
};
return (true);
}
public function fillrect(x:int, y:int, w:int, h:int, col:int):void{
temprect.x = x;
temprect.y = y;
temprect.width = w;
temprect.height = h;
backbuffer.fillRect(temprect, col);
}
public function rprint(x:int, y:int, t:String, r:int, g:int, b:int, cen:Boolean=false):void{
print((x - len(t)), y, t, r, g, b, false);
}
private function startup():void{
removeChild(screen);
removeEventListener(Event.ENTER_FRAME, checkFrame);
var mainClass:Class = (getDefinitionByName("Main") as Class);
addChild((new (mainClass) as DisplayObject));
}
}
}//package
Section 41
//Preloader_im_bfont (Preloader_im_bfont)
package {
import mx.core.*;
public class Preloader_im_bfont extends BitmapAsset {
}
}//package
Section 42
//simpleentclass (simpleentclass)
package {
public class simpleentclass {
public var size:int;
public var life:int;
public var active:Boolean;
public var vx:Number;
public var vy:Number;
public var colour:int;
public var ay:Number;
public var yp:Number;
public var oldxp:Number;
public var tile:int;
public var ax:Number;
public var xp:Number;
public var oldyp:Number;
public function simpleentclass():void{
super();
clear();
}
public function clear():void{
active = false;
size = 0;
tile = 0;
life = 0;
colour = 0;
xp = 0;
yp = 0;
ax = 0;
ay = 0;
vx = 0;
vy = 0;
}
}
}//package
Section 43
//slow_song (slow_song)
package {
import flash.media.*;
public dynamic class slow_song extends Sound {
}
}//package
Section 44
//textboxclass (textboxclass)
package {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import flash.net.*;
public class textboxclass {
public var tr:int;
public var active:Boolean;
public var ismenu:Boolean;
public var lw:int;
public var textrect:Rectangle;
public var yp:int;
public var iter:int;
public var numlines:int;
public var timer:int;
public var highlighted:int;
public var boxname:String;
public var b:int;
public var g:int;
public var h:int;
public var max:int;
public var r:int;
public var tg:int;
public var line:Array;
public var tb:int;
public var tl:Number;
public var tm:int;
public var w:int;
public var xp:int;
public function textboxclass():void{
line = new Array();
super();
firstcreate();
}
public function remove():void{
tm = 2;
tl = 1;
}
public function addline(t:String):void{
line[numlines] = t;
numlines++;
resize();
if (numlines >= 10){
numlines = 0;
};
}
public function firstcreate():void{
var t:String;
iter = 0;
while (iter < 10) {
t = new String();
t = "";
line.push(t);
iter++;
};
xp = 0;
yp = 0;
w = 0;
h = 0;
numlines = 0;
lw = 0;
tl = 0;
tm = 0;
active = false;
timer = 0;
ismenu = false;
boxname = "textbox";
highlighted = 1;
}
public function resize():void{
max = 0;
iter = 0;
while (iter < numlines) {
if (line[iter].length > max){
max = line[iter].length;
};
iter++;
};
lw = max;
w = ((max + 2) * 6);
h = ((numlines + 2) * 8);
textrect.x = xp;
textrect.y = yp;
textrect.width = w;
textrect.height = h;
}
public function centerx():void{
resize();
xp = (160 - (w / 2));
resize();
}
public function centery():void{
resize();
yp = (120 - (h / 2));
resize();
}
public function update():void{
if (tm == 0){
tl = (tl + 0.1);
if (tl >= 1){
tl = 1;
tm = 1;
};
setcol(int((tr * tl)), int((tg * tl)), int((tb * tl)));
} else {
if (tm == 2){
tl = (tl - 0.1);
if (tl <= 0.5){
tl = 0.5;
active = false;
};
setcol(int((tr * tl)), int((tg * tl)), int((tb * tl)));
};
};
if (timer > 0){
timer--;
if (timer == 0){
tm = 2;
};
};
}
public function clear():void{
iter = 0;
while (iter < 10) {
line[iter] = "";
iter++;
};
textrect = new Rectangle();
xp = 0;
yp = 0;
w = 0;
h = 0;
numlines = 1;
lw = 0;
tl = 0;
tm = 0;
active = true;
timer = 0;
}
public function setcol(rr:int, gg:int, bb:int):void{
r = rr;
g = gg;
b = bb;
}
public function initcol(rr:int, gg:int, bb:int):void{
tr = rr;
tg = gg;
tb = bb;
r = 0;
g = 0;
b = 0;
tl = 0.5;
}
}
}//package
Section 45
//title_song (title_song)
package {
import flash.media.*;
public dynamic class title_song extends Sound {
}
}//package