Section 1
//Audio (GWars.Audio)
package GWars {
import flash.media.*;
import flash.utils.*;
public class Audio {
static var sounds:Array;
static var spectrum:ByteArray;
static var volume:Number;
static var prevMagnitude:Number;
public function Audio(){
prevMagnitude = -1;
sounds = new Array();
spectrum = new ByteArray();
volume = 0.5;
}
public static function beatDetect(_arg1, _arg2, _arg3){
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
prevMagnitude = (prevMagnitude * 0.95);
SoundMixer.computeSpectrum(spectrum, true);
_local4 = 0;
_local5 = 0;
_local6 = _arg1;
while (_local6 < _arg2) {
_local7 = (spectrum[_local6] / 0xFF);
_local4 = (_local4 + _local7);
if (_local7 > _local5){
_local5 = _local7;
};
_local6++;
};
_local4 = (_local4 / (_arg2 - _arg1));
if (prevMagnitude < 0){
prevMagnitude = _local4;
};
prevMagnitude = ((prevMagnitude + _local4) * 0.5);
if ((_local5 - prevMagnitude) > _arg3){
return ((_local5 * 2));
};
return (0);
}
public static function addSound(_arg1, _arg2){
var _local3:Object;
_local3 = new Object();
_local3.sound = _arg1;
_local3.name = _arg2;
sounds.push(_local3);
}
public static function getSound(_arg1){
var _local2:uint;
_local2 = 0;
while (_local2 < sounds.length) {
if (sounds[_local2].name == _arg1){
return (sounds[_local2]);
};
_local2++;
};
return (null);
}
public static function playSound(_arg1, _arg2, _arg3=0){
var _local4:Object;
var _local5:Object;
var _local6:SoundTransform;
_local4 = getSound(_arg1);
if (_local4 == null){
return;
};
_local5 = new Object();
_local5.sound = _local4.sound;
_local5.played = false;
_local5.channel = _local5.sound.play(0, _arg3);
_local6 = _local5.channel.soundTransform;
_local6.volume = (_arg2 * volume);
_local5.channel.soundTransform = _local6;
}
}
}//package GWars
Section 2
//Entity (GWars.Entity)
package GWars {
import flash.display.*;
import flash.geom.*;
import flash.ui.*;
public class Entity {
public var rotation:Number;
public var type:String;
public var weaponRechargeTime:Number;
public var radius:Number;
public var health:Number;
public var velocity:Vector2;
public var weaponRecharge:Number;
public var hasWeapon:Boolean;
public var graphic:IBitmapDrawable;
public var position:Vector2;
public var isPlayer:Boolean;
public var maxHP:Number;
public var isDead:Boolean;
public var bulletDamageMultiplier:Number;
public var direction:Vector2;
public function Entity(_arg1, _arg2=100, _arg3=false){
this.weaponRechargeTime = 55;
this.weaponRecharge = this.weaponRechargeTime;
this.maxHP = _arg2;
this.isPlayer = _arg3;
this.graphic = _arg1;
this.health = this.maxHP;
this.position = new Vector2(0, 0);
this.velocity = new Vector2(0, 0);
this.direction = new Vector2();
this.rotation = 0;
this.bulletDamageMultiplier = 15;
if (this.isPlayer){
this.bulletDamageMultiplier = 3;
};
this.isDead = false;
this.radius = (Math.max(_arg1.width, _arg1.height) * 0.5);
}
public function boundaryCollide(_arg1){
if ((this.position.x - this.radius) < _arg1.left){
this.velocity.x = -(this.velocity.x);
this.position.x = (_arg1.left + this.radius);
};
if ((this.position.x + this.radius) > _arg1.right){
this.velocity.x = -(this.velocity.x);
this.position.x = (_arg1.right - this.radius);
};
if ((this.position.y + this.radius) > _arg1.bottom){
this.velocity.y = -(this.velocity.y);
this.position.y = (_arg1.bottom - this.radius);
};
if ((this.position.y - this.radius) < _arg1.top){
this.velocity.y = -(this.velocity.y);
this.position.y = (_arg1.top + this.radius);
};
}
public function draw(_arg1:BitmapData, _arg2=null){
var _local3:Matrix;
_local3 = new Matrix();
_local3.identity();
_local3.rotate(this.rotation);
if (_arg2 == null){
_local3.translate(this.position.x, this.position.y);
} else {
_local3.translate((this.position.x + _arg2.x), (this.position.y + _arg2.y));
};
_arg1.draw(this.graphic, _local3, null, null, null, false);
}
public function _rotateToPoint(_arg1){
var _local2:Number;
this.direction.x = (_arg1.x - position.x);
this.direction.y = (_arg1.y - position.y);
_local2 = Math.atan2((_arg1.x - position.x), -((_arg1.y - position.y)));
this.rotation = _local2;
}
public function _fire(_arg1){
var _local2:uint;
var _local3:Projectile;
var _local4:Vector2;
_local2 = 4294949632;
if (this.type == "Circle"){
_local2 = 4294906163;
};
if (this.type == "Triangle"){
_local2 = 4279369523;
};
_local3 = _arg1.createProjectile(this.position.x, this.position.y, isPlayer, _local2);
_local4 = new Vector2();
_local4.x = this.direction.x;
_local4.y = this.direction.y;
_local4.normalize();
_local4.x = (_local4.x * 25);
_local4.y = (_local4.y * 25);
_local3.velocity = _local4;
if (this.isPlayer){
Audio.playSound("fire", 1);
};
}
public function entityCollide(_arg1){
var _local2:Vector2;
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local2 = _arg1.position.sub(this.position);
_local3 = _local2.len();
_local4 = this.velocity.len();
if (_local3 < (this.radius + _arg1.radius)){
_local5 = ((this.radius + _arg1.radius) - _local3);
_local2.normalize();
_arg1.velocity.addeq(_local2);
this.velocity.subeq(_local2);
_local2.scaleeq(_local5);
_arg1.position.addeq(_local2);
this.position.subeq(_local2);
if (((this.isPlayer) && (!(_arg1.hasWeapon)))){
this.health = (this.health - 2.5);
} else {
if (((_arg1.isPlayer) && (!(this.hasWeapon)))){
_arg1.health = (_arg1.health - 2.5);
};
};
};
}
public function update(_arg1:Number, _arg2:Game, _arg3=null){
var _local4:Number;
var _local5:Number;
var _local6:Vector2;
var _local7:Number;
if (this.health <= 0){
if (!this.isDead){
Audio.playSound("death", 1);
_arg2._explosion(position.x, position.y, (55 + (Math.random() * 80)));
this.isDead = true;
if (!this.isPlayer){
if (!_arg2.playerShip.isDead){
_arg2.playerScore = (_arg2.playerScore + (this.hasWeapon) ? 172 : 131);
_arg2.playerCharge = (_arg2.playerCharge + 5);
};
} else {
_arg2.playerLives--;
};
};
if (((this.isDead) && (this.isPlayer))){
if (Input.keyDown(Keyboard.SPACE)){
if (_arg2.playerLives > 0){
_arg2.killAll();
this.health = 100;
this.isDead = false;
this.position.x = 750;
this.position.y = 750;
this.velocity = new Vector2();
};
};
};
return;
};
if (((this.isPlayer) && ((this.health < 30.5)))){
this.health = (this.health + (0.75 * _arg1));
};
this.weaponRecharge = (this.weaponRecharge - (50 * _arg1));
if (this.isPlayer){
if (((Input.keyDown(87)) || (Input.keyDown(Keyboard.UP)))){
velocity.y = (velocity.y - (_arg1 * 2));
};
if (((Input.keyDown(83)) || (Input.keyDown(Keyboard.DOWN)))){
velocity.y = (velocity.y + (_arg1 * 2));
};
if (((Input.keyDown(65)) || (Input.keyDown(Keyboard.LEFT)))){
velocity.x = (velocity.x - (_arg1 * 2));
};
if (((Input.keyDown(68)) || (Input.keyDown(Keyboard.RIGHT)))){
velocity.x = (velocity.x + (_arg1 * 2));
};
velocity.x = (velocity.x * 0.96);
velocity.y = (velocity.y * 0.96);
if (velocity.len() > 7){
velocity.normalize();
velocity.scaleeq(7);
};
_local4 = Input.getMouseX(740);
_local5 = Input.getMouseY(480);
if (_arg3 != null){
_local4 = (_local4 - _arg3.x);
_local5 = (_local5 - _arg3.y);
};
_rotateToPoint(new Vector2(_local4, _local5));
if (Input.msdwn){
if (this.weaponRecharge < 0){
_fire(_arg2);
this.weaponRecharge = this.weaponRechargeTime;
};
};
} else {
if (_arg2.playerShip.health > 0){
if ((((this.type == "Diamond")) || ((this.type == "Triangle")))){
velocity = _arg2.playerShip.position.sub(this.position);
velocity.normalize();
velocity.scaleeq(5);
};
if ((((this.type == "Circle")) || ((this.type == "Triangle")))){
_rotateToPoint(_arg2.playerShip.position);
_local6 = _arg2.playerShip.position.sub(this.position);
_local7 = _local6.len();
if ((((Math.random() > 0.8)) && ((_local7 < 400)))){
if (this.weaponRecharge < 0){
_fire(_arg2);
this.weaponRecharge = this.weaponRechargeTime;
};
};
};
};
};
this.position.addeq(this.velocity);
}
}
}//package GWars
Section 3
//Game (GWars.Game)
package GWars {
import flash.geom.*;
public class Game {
public var entities:Array;
public var level:Number;
public var projectiles:Array;
public var rechargeTimer:Number;
public var camera:Vector2;
public var playerLives:Number;
public var boundary:Rectangle;
public var playerScore:Number;
public var playerCharge:Number;
public var playerShip:Entity;
public function Game(){
playerShip = null;
playerScore = 0;
playerLives = 3;
playerCharge = 0;
rechargeTimer = 50;
camera = new Vector2();
entities = new Array();
projectiles = new Array();
boundary = new Rectangle(0, 0, 1500, 1500);
level = 3;
}
public function createProjectile(_arg1, _arg2, _arg3, _arg4){
var _local5:Projectile;
_local5 = _findDeadProjectile();
if (_local5 == null){
_local5 = new Projectile(_arg3, _arg4);
_local5.position.x = _arg1;
_local5.position.y = _arg2;
projectiles.push(_local5);
} else {
_local5.isFromPlayer = _arg3;
_local5.colour = _arg4;
_local5.life = 1;
_local5.position.x = _arg1;
_local5.position.y = _arg2;
};
_local5.isFromExplosion = false;
return (_local5);
}
public function update(_arg1:Number){
var _local2:Entity;
var _local3:Projectile;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Entity;
if (((!((this.playerShip == null))) && (!(this.playerShip.isDead)))){
level = (level + 0.001);
rechargeTimer--;
this.playerCharge = Math.max((this.playerCharge - _arg1), 0);
if (rechargeTimer < 0){
if (!this.playerShip.isDead){
_local4 = (0.1 + (Math.random() * 5));
_local5 = (this.playerShip.position.x + (Math.sin(_local4) * (450 + (_local4 * 20))));
_local6 = (this.playerShip.position.y + (Math.cos(_local4) * (450 + (_local4 * 20))));
if (_local5 < 0){
_local5 = (1000 - _local5);
};
if (_local5 > 1000){
_local5 = (_local5 - 1000);
};
if (_local6 < 0){
_local6 = (1000 - _local6);
};
if (Math.random() > (((level * 0.01) + 0.5) / 2)){
if (Math.random() > 0.5){
createDiamond(_local5, _local6);
} else {
createTriangle(_local5, _local6);
};
} else {
createCircle(_local5, _local6);
};
};
rechargeTimer = Math.max(40, ((1 / level) * 150));
};
camera.x = (camera.x - Math.min(15, (((camera.x - (-(playerShip.position.x) + (740 / 2))) * 0.5) * _arg1)));
camera.y = (camera.y - Math.min(15, (((camera.y - (-(playerShip.position.y) + 240)) * 0.5) * _arg1)));
};
for each (_local2 in entities) {
if (((_local2.isDead) && (!((_local2 == playerShip))))){
} else {
_local2.boundaryCollide(this.boundary);
for each (_local7 in entities) {
if (((!((_local7 == _local2))) && ((_local7.health > 0)))){
_local2.entityCollide(_local7);
};
};
_local2.update(_arg1, this, camera);
};
};
for each (_local3 in projectiles) {
if (_local3.life <= 0){
} else {
_local3.boundaryCollide(this.boundary);
if (_local3.isFromPlayer){
for each (_local2 in entities) {
if (((!((_local2 == playerShip))) && ((((_local2.health > 0)) || (!(_local2.isDead)))))){
if (_local3.entityCollide(_local2)){
break;
};
};
};
} else {
if (playerShip.health > 0){
_local3.entityCollide(playerShip);
};
};
_local3.update(_arg1);
};
};
}
public function draw(_arg1){
var _local2:Projectile;
var _local3:Entity;
_drawGridLines(_arg1);
for each (_local2 in projectiles) {
_local2.draw(_arg1, camera);
};
for each (_local3 in entities) {
if ((((_local3.health <= 0)) || (_local3.isDead))){
} else {
_local3.draw(_arg1, camera);
};
};
_drawBoundary(_arg1, 37, 4278190080);
_drawBoundary(_arg1);
}
public function createPlayer(_arg1, _arg2){
var _local3:Entity;
_local3 = new Entity(new _mc_player(), 100, true);
_local3.position.x = _arg1;
_local3.position.y = _arg2;
entities.push(_local3);
playerShip = _local3;
return (_local3);
}
public function _explosion(_arg1, _arg2, _arg3){
var _local4:uint;
var _local5:uint;
var _local6:Projectile;
_local4 = Math.max(0, Math.min(_arg3, 200));
_local5 = 0;
while (_local5 < _local4) {
_local6 = createProjectile((_arg1 + ((Math.random() - 0.5) * 10)), _arg2, true, _randomRainbowColour());
_local6.velocity.x = ((Math.sin((((_local5 / _local4) * Math.PI) * 2)) * (0.2 + Math.random())) * 22);
_local6.velocity.y = ((Math.cos((((_local5 / _local4) * Math.PI) * 2)) * (0.2 + Math.random())) * 22);
_local6.isFromExplosion = true;
_local5++;
};
}
public function createPlayerShip(_arg1, _arg2, _arg3){
var _local4:Entity;
_local4 = new Entity(_arg1, 100, true);
_local4.position.x = _arg2;
_local4.position.y = _arg3;
entities.push(_local4);
playerShip = _local4;
return (_local4);
}
public function _randomRainbowColour():uint{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:uint;
var _local5:Number;
_local1 = (Math.random() * 2);
_local2 = Math.random();
_local3 = Math.random();
_local1 = (_local1 + 0.3);
_local2 = (_local2 + 0.3);
_local3 = (_local3 + 0.3);
if ((((((_local1 < 0.6)) && ((_local2 < 0.6)))) && ((_local3 < 0.6)))){
_local5 = Math.random();
if (_local5 > 0.2){
_local1 = Math.min((0.8 + Math.random()), 1);
} else {
if (_local5 > 0.5){
_local2 = Math.min((0.8 + Math.random()), 1);
} else {
if (_local5 > 0.8){
_local3 = Math.min((0.8 + Math.random()), 1);
};
};
};
};
_local4 = ((((0xFF << 24) | ((_local1 * 0xFF) << 16)) | ((_local2 * 0xFF) << 8)) | (_local3 * 0xFF));
return (_local4);
}
public function killAll(){
var _local1:Entity;
for each (_local1 in entities) {
_local1.health = -1;
_local1.isDead = true;
};
}
public function createTriangle(_arg1, _arg2){
var _local3:Entity;
_local3 = new Entity(new _mc_triangle(), 70, false);
_local3.position.x = _arg1;
_local3.position.y = _arg2;
_local3.hasWeapon = true;
_local3.type = "Triangle";
entities.push(_local3);
return (_local3);
}
public function createCircle(_arg1, _arg2){
var _local3:Entity;
_local3 = new Entity(new _mc_circle(), 70, false);
_local3.position.x = _arg1;
_local3.position.y = _arg2;
_local3.hasWeapon = true;
_local3.type = "Circle";
_local3.velocity.x = (Math.random() - 0.5);
_local3.velocity.y = (Math.random() - 0.5);
_local3.velocity.normalize();
_local3.velocity.scaleeq(4);
entities.push(_local3);
return (_local3);
}
public function _drawBoundary(_arg1, _arg2=5, _arg3=4281532671){
var _local4:Rectangle;
var _local5:Rectangle;
_local4 = new Rectangle();
_local5 = boundary.clone();
boundary.clone().x = (_local5.x + camera.x);
_local5.y = (_local5.y + camera.y);
_local4.x = _local5.left;
_local4.y = (_local5.top - _arg2);
_local4.width = _local5.width;
_local4.height = _arg2;
_arg1.fillRect(_local4, _arg3);
_local4.y = _local5.bottom;
_arg1.fillRect(_local4, _arg3);
_local4.x = (_local5.left - _arg2);
_local4.y = _local5.top;
_local4.width = _arg2;
_local4.height = _local5.height;
_arg1.fillRect(_local4, _arg3);
_local4.x = _local5.right;
_arg1.fillRect(_local4, _arg3);
}
public function _findDeadProjectile(){
var _local1:Projectile;
for each (_local1 in projectiles) {
if (_local1.life <= 0){
return (_local1);
};
};
return (null);
}
public function _drawGridLines(_arg1){
var _local2:uint;
var _local3:uint;
var _local4:Rectangle;
var _local5:Rectangle;
var _local6:Number;
var _local7:Number;
var _local8:uint;
_local2 = 32;
_local3 = 4279304243;
_local4 = new Rectangle();
_local5 = boundary.clone();
boundary.clone().x = (_local5.x + camera.x);
_local5.y = (_local5.y + camera.y);
_local6 = (_local5.width / _local2);
_local7 = (_local5.height / _local2);
_local8 = 0;
_local8 = 0;
while (_local8 < _local2) {
_local4.x = _local5.left;
_local4.width = _local5.width;
_local4.y = (_local5.y + (_local8 * _local7));
_local4.height = 2;
_arg1.fillRect(_local4, _local3);
_local8++;
};
_local8 = 0;
while (_local8 < _local2) {
_local4.x = (_local5.x + (_local8 * _local6));
_local4.width = 2;
_local4.y = _local5.y;
_local4.height = _local5.height;
_arg1.fillRect(_local4, _local3);
_local8++;
};
}
public function createDiamond(_arg1, _arg2){
var _local3:Entity;
_local3 = new Entity(new _mc_diamond(), 100, false);
_local3.position.x = _arg1;
_local3.position.y = _arg2;
_local3.hasWeapon = false;
_local3.type = "Diamond";
entities.push(_local3);
return (_local3);
}
}
}//package GWars
Section 4
//Input (GWars.Input)
package GWars {
import flash.events.*;
import flash.display.*;
public class Input {
public static var keys:Array;
public static var msdwn:Boolean;
public static var stage:Stage;
public function Input(_arg1:Stage){
keys = new Array(0x0100);
stage = _arg1;
stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpListener);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownListener);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpListener);
}
public static function getNormalizedMouseX(_arg1:int=550):Number{
return ((getMouseX(_arg1) / _arg1));
}
public static function getNormalizedMouseY(_arg1:int=400):Number{
return ((getMouseY(_arg1) / _arg1));
}
public static function mouseUpListener(_arg1:MouseEvent){
msdwn = false;
}
public static function keyDownListener(_arg1:KeyboardEvent){
keys[_arg1.keyCode] = true;
}
public static function getMouseX(_arg1:uint=550):Number{
return (Math.max(0, Math.min(stage.mouseX, _arg1)));
}
public static function getMouseY(_arg1:uint=400):Number{
return (Math.max(0, Math.min(stage.mouseY, _arg1)));
}
public static function keyUpListener(_arg1:KeyboardEvent){
keys[_arg1.keyCode] = false;
}
public static function keyDown(_arg1:uint):Boolean{
return (keys[_arg1]);
}
public static function mouseDownListener(_arg1:MouseEvent){
msdwn = true;
}
}
}//package GWars
Section 5
//Projectile (GWars.Projectile)
package GWars {
import flash.display.*;
public class Projectile {
public var life:Number;
public var isFromExplosion:Boolean;
public var position:Vector2;
public var colour:uint;
public var isFromPlayer:Boolean;
public var velocity:Vector2;
public var rotation:Number;
public function Projectile(_arg1, _arg2){
this.position = new Vector2();
this.velocity = new Vector2();
this.colour = _arg2;
this.isFromPlayer = _arg1;
this.isFromExplosion = false;
this.life = 1;
}
public function draw(_arg1:BitmapData, _arg2=null){
if (_arg2 == null){
_drawLine(_arg1, colour, this.position, this.velocity);
} else {
_drawLine(_arg1, colour, this.position.add(_arg2), this.velocity);
};
}
public function _drawLine(_arg1:BitmapData, _arg2, _arg3, _arg4){
var _local5:int;
var _local6:Vector2;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:uint;
var _local14:Number;
var _local15:uint;
var _local16:uint;
var _local17:uint;
if (life < 0){
return;
};
_local5 = (1 + this.velocity.lensq());
_local5 = Math.min(_local5, 25);
_local6 = _arg4.clone();
_local6.normalize();
_local7 = (_arg3.x - (_local6.x * _local5));
_local8 = (_arg3.y - (_local6.y * _local5));
_local9 = Math.max(_arg3.x, _local7);
_local10 = Math.min(_arg3.x, _local7);
if (_local9 < 0){
return;
};
if (_local10 >= 740){
return;
};
_local11 = Math.max(_arg3.y, _local8);
_local12 = Math.min(_arg3.y, _local8);
if (_local11 < 0){
return;
};
if (_local11 >= 480){
return;
};
_local13 = (_arg2 & 0xFFFFFF);
_local14 = 0;
while (_local14 < _local5) {
_local15 = (_arg3.x - (_local6.x * _local14));
_local16 = (_arg3.y - (_local6.y * _local14));
_local17 = _addBlendPixel(_arg1, _local15, _local16, _local13, 1);
_arg1.setPixel32((_local15 + 1), _local16, _local17);
_local17 = _addBlendPixel(_arg1, _local15, (_local16 + 1), _local13, 1);
_arg1.setPixel32(_local15, (_local16 + 2), _local17);
_local14++;
};
}
public function update(_arg1:Number, _arg2=null){
life = (((life * 0.85) + ((life * life) * 0.15)) - (0.0025 * _arg1));
this.position.addeq(this.velocity);
}
public function boundaryCollide(_arg1){
if (this.position.x < _arg1.left){
this.velocity.x = -(this.velocity.x);
this.position.x = _arg1.left;
life = (life - 0.1);
};
if (this.position.x > _arg1.right){
this.velocity.x = -(this.velocity.x);
this.position.x = _arg1.right;
life = (life - 0.1);
};
if (this.position.y > _arg1.bottom){
this.velocity.y = -(this.velocity.y);
this.position.y = _arg1.bottom;
life = (life - 0.1);
};
if (this.position.y < _arg1.top){
this.velocity.y = -(this.velocity.y);
this.position.y = _arg1.top;
life = (life - 0.1);
};
}
public function _addBlendPixel(_arg1:BitmapData, _arg2:uint, _arg3:uint, _arg4:uint, _arg5:Number){
var _local6:uint;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:uint;
var _local12:uint;
var _local13:uint;
var _local14:uint;
_local6 = _arg1.getPixel(_arg2, _arg3);
_local7 = (this.life * _arg5);
_local8 = ((_arg4 & 0xFF0000) >> 16);
_local9 = ((_arg4 & 0xFF00) >> 8);
_local10 = (_arg4 & 0xFF);
_local8 = (_local8 * _local7);
_local9 = (_local9 * _local7);
_local10 = (_local10 * _local7);
_local11 = (((_local6 & 0xFF0000) >> 16) + _local8);
_local12 = (((_local6 & 0xFF00) >> 8) + _local9);
_local13 = ((_local6 & 0xFF) + _local10);
_local11 = Math.min(_local11, 0xFF);
_local12 = Math.min(_local12, 0xFF);
_local13 = Math.min(_local13, 0xFF);
_local14 = ((((0xFF << 24) | (_local11 << 16)) | (_local12 << 8)) | _local13);
_arg1.setPixel32(_arg2, _arg3, _local14);
return (_local14);
}
public function entityCollide(_arg1:Entity){
var _local2:Vector2;
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local2 = _arg1.position.sub(this.position);
_local3 = _local2.len();
_local4 = this.velocity.len();
if (_local3 < _arg1.radius){
_local5 = (this.life * _arg1.bulletDamageMultiplier);
if (this.isFromExplosion){
_local5 = (_local5 * 0.2);
};
_arg1.health = (_arg1.health - _local5);
this.life = (this.life - 0.1);
this.velocity.normalize();
this.velocity.subeq(_local2);
this.velocity.normalize();
this.velocity.scaleeq(_local4);
return (true);
};
}
}
}//package GWars
Section 6
//Vector2 (GWars.Vector2)
package GWars {
public class Vector2 {
public var x:Number;// = 0
public var y:Number;// = 0
public function Vector2(_arg1=0, _arg2=0){
x = 0;
y = 0;
super();
this.x = _arg1;
this.y = _arg2;
}
public function sub(_arg1:Vector2):Vector2{
return (new Vector2((this.x - _arg1.x), (this.y - _arg1.y)));
}
public function set(_arg1:Number, _arg2:Number){
this.x = _arg1;
this.y = _arg2;
}
public function add(_arg1:Vector2):Vector2{
return (new Vector2((this.x + _arg1.x), (this.y + _arg1.y)));
}
public function dot(_arg1:Vector2):Number{
return (((this.x * _arg1.x) + (this.y * _arg1.y)));
}
public function scale(_arg1:Number){
return (new Vector2((this.x * _arg1), (this.y * _arg1)));
}
public function projectOnto(_arg1:Vector2):Vector2{
var _local2:Vector2;
var _local3:Number;
_local2 = _arg1.clone();
_local2.normalize();
_local3 = this.dot(_local2);
return (new Vector2((_local2.x * _local3), (_local2.y * _local3)));
}
public function subeq(_arg1:Vector2){
this.x = (this.x - _arg1.x);
this.y = (this.y - _arg1.y);
}
public function addeq(_arg1:Vector2){
this.x = (this.x + _arg1.x);
this.y = (this.y + _arg1.y);
}
public function lhn():Vector2{
return (new Vector2(this.y, -(this.x)));
}
public function len():Number{
return (Math.sqrt(this.lensq()));
}
public function scaleeq(_arg1:Number){
this.x = (this.x * _arg1);
this.y = (this.y * _arg1);
}
public function muleq(_arg1:Vector2){
this.x = (this.x * _arg1.x);
this.y = (this.y * _arg1.y);
}
public function lensq():Number{
return (((this.x * this.x) + (this.y * this.y)));
}
public function normalize(){
var _local1:Number;
_local1 = this.len();
if (_local1 != 0){
this.scaleeq((1 / _local1));
};
}
public function clone():Vector2{
return (new Vector2(this.x, this.y));
}
public function rhn():Vector2{
return (new Vector2(-(this.y), this.x));
}
}
}//package GWars
Section 7
//_mc_lives_5 (GWars_fla._mc_lives_5)
package GWars_fla {
import flash.display.*;
public dynamic class _mc_lives_5 extends MovieClip {
public function _mc_lives_5(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package GWars_fla
Section 8
//MainTimeline (GWars_fla.MainTimeline)
package GWars_fla {
import flash.events.*;
import flash.display.*;
import GWars.*;
import flash.geom.*;
import flash.media.*;
import flash.text.*;
import flash.net.*;
import flash.utils.*;
import flash.ui.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.printing.*;
import flash.system.*;
import flash.xml.*;
public dynamic class MainTimeline extends MovieClip {
public var game:Game;
public var _lives:MovieClip;
public var _load_count:TextField;
public var bestScore:Number;
public var screenData:BitmapData;
public var _health:MovieClip;
public var _new_game:SimpleButton;
public var screen:Bitmap;
public var _score:TextField;
public var bloomData:BitmapData;
public var mm:Number;
public var nexSharedObj:SharedObject;
public var globalState:String;
public var fc:Number;
public var _message:TextField;
public var _hiscore:TextField;
public function MainTimeline(){
addFrameScript(0, frame1, 1, frame2, 2, frame3, 4, frame5);
}
public function _changeState(_arg1){
game = null;
globalState = _arg1;
}
public function nr_dec(_arg1, _arg2){
var _local3:Number;
_local3 = Math.pow(10, _arg2);
return ((int((_arg1 * _local3)) / _local3));
}
public function loading(_arg1:ProgressEvent){
var _local2:Number;
var _local3:Number;
_local2 = ((_arg1.bytesTotal / 0x0400) / 0x0400);
_local3 = ((_arg1.bytesLoaded / 0x0400) / 0x0400);
if (_local3 == _local2){
play();
};
_local2 = nr_dec(_local2, 2);
_local3 = nr_dec(_local3, 2);
_load_count.text = (((_local3 + " / ") + _local2) + " MB");
}
public function _blurBitmapData(_arg1, _arg2:Number, _arg3:int=3){
var _local4:BlurFilter;
var _local5:Rectangle;
var _local6:Point;
_local4 = new BlurFilter();
_local5 = new Rectangle(0, 0, _arg1.width, _arg1.height);
_local6 = new Point();
_local4.blurX = _arg2;
_local4.blurY = _arg2;
_local4.quality = _arg3;
_arg1.applyFilter(_arg1, _local5, _local6, _local4);
}
function frame3(){
_hiscore.text = ("hiscore " + bestScore);
_new_game.addEventListener(MouseEvent.MOUSE_UP, function (_arg1:MouseEvent):void{
_changeState("game");
gotoAndStop(5);
});
stop();
}
function frame1(){
stop();
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, loading);
nexSharedObj = SharedObject.getLocal("nex_data");
}
function frame5(){
stop();
}
function frame2(){
stage.scaleMode = StageScaleMode.NO_SCALE;
globalState = "menu";
game = null;
bestScore = 0;
if (nexSharedObj.data.hiscore != null){
bestScore = nexSharedObj.data.hiscore;
};
new Input(stage);
new Audio();
Audio.addSound(new _sn_hit(), "hit");
Audio.addSound(new _sn_death(), "death");
Audio.addSound(new _sn_fire(), "fire");
Audio.addSound(new TheTubes(), "music");
Audio.playSound("music", 0.85, 99999);
screenData = new BitmapData(740, 480, true, 4278190080);
screen = new Bitmap(screenData);
bloomData = new BitmapData((740 / 2), (480 / 2), false, 4278190080);
mm = 1;
fc = 0;
addChild(screen);
addEventListener(Event.ENTER_FRAME, _onEnterFrame);
}
public function _onEnterFrame(_arg1:Event){
var _local2:Number;
fc++;
if ((((game == null)) && ((globalState == "menu")))){
game = new Game();
game._explosion((Math.random() * 500), (Math.random() * 500), (1 + (Math.random() * 160)));
};
if ((((game == null)) && ((globalState == "game")))){
game = new Game();
game.createPlayerShip(new _mc_player(), (game.boundary.width / 2), (game.boundary.height / 2));
};
if ((((globalState == "menu")) && (!((game == null))))){
game.camera.x = (-250 + (Math.sin((fc * 0.015)) * 180));
game.camera.y = (-250 + (Math.cos((fc * 0.021)) * 50));
if (Math.random() > 0.96){
game._explosion((250 + (Math.random() * 500)), (Math.random() * 500), (1 + (Math.random() * 160)));
};
};
if ((((globalState == "game")) && (!((game == null))))){
if (game.playerLives <= 0){
if (game.playerScore > bestScore){
bestScore = game.playerScore;
nexSharedObj.data.hiscore = bestScore;
};
gotoAndStop(3);
_changeState("menu");
};
};
if (game != null){
screenData.fillRect(new Rectangle(0, 0, 740, 480), 285212672);
game.update(0.25);
screenData.lock();
game.draw(screenData);
screenData.unlock();
_copyBitmapData(bloomData, screenData);
_blurBitmapData(bloomData, 8);
mm = (mm + Audio.beatDetect(85, 95, 0.62));
mm = (mm * 0.5);
mm = Math.max(mm, 1);
mm = Math.min(mm, 2);
if (game.playerShip != null){
_local2 = (Math.min(10, (3.5 + (game.playerCharge * 0.25))) * mm);
_copyBitmapData(screenData, bloomData, "add", new ColorTransform(_local2, _local2, _local2));
} else {
_copyBitmapData(screenData, bloomData, "add", new ColorTransform((6 * mm), (6 * mm), (6 * mm)));
};
if (_score != null){
_score.text = ("score " + game.playerScore.toString());
};
if (((!((_health == null))) && (!((game.playerShip == null))))){
_health.scaleX = (Math.max(0, game.playerShip.health) / 100);
};
if (_lives != null){
_lives.gotoAndStop(((3 - game.playerLives) + 1));
};
if (((!((_message == null))) && (!((game.playerShip == null))))){
if (game.playerShip.isDead){
_message.text = "You died. Hit space to respawn";
} else {
_message.text = "";
};
};
};
}
public function _copyBitmapData(_arg1, _arg2, _arg3:String=null, _arg4=null){
var _local5:Matrix;
_local5 = new Matrix();
_local5.scale((_arg1.width / _arg2.width), (_arg1.height / _arg2.height));
_arg1.draw(_arg2, _local5, _arg4, _arg3);
}
}
}//package GWars_fla
Section 9
//_mc_circle (_mc_circle)
package {
import flash.display.*;
public dynamic class _mc_circle extends MovieClip {
}
}//package
Section 10
//_mc_diamond (_mc_diamond)
package {
import flash.display.*;
public dynamic class _mc_diamond extends MovieClip {
}
}//package
Section 11
//_mc_player (_mc_player)
package {
import flash.display.*;
public dynamic class _mc_player extends MovieClip {
}
}//package
Section 12
//_mc_triangle (_mc_triangle)
package {
import flash.display.*;
public dynamic class _mc_triangle extends MovieClip {
}
}//package
Section 13
//_sn_death (_sn_death)
package {
import flash.media.*;
public dynamic class _sn_death extends Sound {
}
}//package
Section 14
//_sn_fire (_sn_fire)
package {
import flash.media.*;
public dynamic class _sn_fire extends Sound {
}
}//package
Section 15
//_sn_hit (_sn_hit)
package {
import flash.media.*;
public dynamic class _sn_hit extends Sound {
}
}//package
Section 16
//TheTubes (TheTubes)
package {
import flash.media.*;
public dynamic class TheTubes extends Sound {
}
}//package