Symbol 12 MovieClip Frame 31
stop();
Symbol 15 MovieClip Frame 1
function randomize(min, max) {
var _local1 = Math.floor(Math.random() * ((max - min) + 1)) + min;
return(_local1);
}
_rotation = randomize(150, 359);
_xscale = randomize(50, 100);
_yscale = _xscale;
Symbol 15 MovieClip Frame 30
if (_parent.halt) {
stop();
}
Symbol 16 MovieClip [CrashAnimBlack] Frame 25
var halt = true;
Symbol 16 MovieClip [CrashAnimBlack] Frame 43
stop();
Symbol 17 MovieClip [CrashAnimWhite] Frame 25
var halt = true;
Symbol 17 MovieClip [CrashAnimWhite] Frame 43
stop();
Symbol 18 MovieClip [CrashAnimRed] Frame 25
var halt = true;
Symbol 18 MovieClip [CrashAnimRed] Frame 43
stop();
Symbol 25 MovieClip [LObject] Frame 1
#initclip 25
Object.registerClass("LObject", com.king.SuperBall.LObject);
#endinitclip
Symbol 30 MovieClip [SObject] Frame 1
#initclip 20
Object.registerClass("SObject", com.king.SuperBall.SObject);
#endinitclip
Symbol 51 MovieClip [CObject] Frame 1
#initclip 21
Object.registerClass("CObject", com.king.SuperBall.CObject);
#endinitclip
Symbol 103 MovieClip Frame 1
stop();
Symbol 109 MovieClip [Ball] Frame 1
#initclip 22
Object.registerClass("Ball", com.king.SuperBall.Ball);
#endinitclip
stop();
Symbol 109 MovieClip [Ball] Frame 7
stop();
Symbol 115 MovieClip [Game] Frame 1
#initclip 23
Object.registerClass("Game", com.king.SuperBall.Game);
#endinitclip
Symbol 147 MovieClip Frame 1
stop();
Symbol 147 MovieClip Frame 96
stop();
Symbol 175 MovieClip [SuperBall] Frame 1
#initclip 24
Object.registerClass("SuperBall", com.king.SuperBall.SuperBall);
#endinitclip
Symbol 176 MovieClip [__Packages.com.king.SuperBall.SObject] Frame 0
class com.king.SuperBall.SObject extends MovieClip
{
var ifloat, currentTick, _height, yPos, _parent, sObjNum, _y, _x, removeMovieClip;
function SObject () {
super();
ifloat = new com.king.timing.IFloat();
}
function tick(tick, tps) {
currentTick = tick;
if (yPos >= Number(480 + (_height / 2))) {
_parent.removeCObject(sObjNum);
}
yPos = yPos + _parent.ballSpeed;
ifloat.set(yPos);
}
function render(tick, alpha) {
_y = ifloat.get(alpha);
}
function init(xP, num) {
_x = xP;
yPos = -(_height / 2);
ifloat.setTo(yPos);
sObjNum = num;
}
function removeMe() {
removeMovieClip();
}
var type = "deceleration";
}
Symbol 177 MovieClip [__Packages.com.king.timing.IFloat] Frame 0
class com.king.timing.IFloat
{
static var alpha;
var ivalue, lastValue;
function IFloat (initial) {
ivalue = initial;
lastValue = initial;
alpha = 0;
}
function setTo(initial) {
ivalue = initial;
lastValue = initial;
}
function set(newValue) {
lastValue = ivalue;
ivalue = newValue;
}
function get(lalpha) {
return(lastValue + ((ivalue - lastValue) * lalpha));
}
static function setAlpha(na) {
alpha = na;
}
function get value() {
return(lastValue + ((ivalue - lastValue) * alpha));
}
function set value(v) {
ivalue = v;
lastValue = v;
//return(value);
}
}
Symbol 178 MovieClip [__Packages.com.king.SuperBall.CObject] Frame 0
class com.king.SuperBall.CObject extends MovieClip
{
var ifloat, currentTick, _height, yPos, _parent, _y, _x, cObjNum, gotoAndStop, removeMovieClip;
function CObject () {
super();
ifloat = new com.king.timing.IFloat();
}
function tick(tick, tps) {
currentTick = tick;
if (yPos >= Number(480 + (_height / 2))) {
_parent.removeCObject(this);
}
yPos = yPos + _parent.ballSpeed;
ifloat.set(yPos);
}
function render(tick, alpha) {
_y = ifloat.get(alpha);
}
function init(xP, num, objType) {
_x = xP;
yPos = -(_height / 2);
ifloat.setTo(yPos);
cObjNum = num;
gotoAndStop(objType);
}
function removeMe() {
removeMovieClip();
}
var objArr = new Array();
var type = "collision";
}
Symbol 179 MovieClip [__Packages.com.king.SuperBall.Ball] Frame 0
class com.king.SuperBall.Ball extends MovieClip
{
var xPos, _x, ballAnimPos, ifloat, ballFloat, gameState, currentTick, mcTheBall, _parent;
function Ball () {
super();
xPos = 210;
_x = xPos;
ballAnimPos = 1;
ifloat = new com.king.timing.IFloat();
ballFloat = new com.king.timing.IFloat();
ifloat.setTo(xPos);
ballFloat.setTo(ballAnimPos);
gameState = STATE_RUNNING;
}
function tick(tick, tps) {
if (!(gameState === STATE_RUNNING)) {
} else {
currentTick = tick;
if (xPos < _root._xmouse) {
xPos = Math.min(380, xPos + ((_root._xmouse - xPos) * 0.2));
} else if (xPos > _root._xmouse) {
xPos = Math.max(30, xPos - ((xPos - _root._xmouse) * 0.2));
}
mcTheBall._rotation = xPos - _x;
ballAnimPos = ballAnimPos + Math.min(_parent.ballSpeed / 8, 2);
ifloat.set(xPos);
ballFloat.set(ballAnimPos);
}
}
function render(tick, alpha) {
if (!(gameState === STATE_RUNNING)) {
} else {
_x = ifloat.get(alpha);
var _local2 = Math.round((ballFloat.get(alpha) % 25) + 1);
mcTheBall.gotoAndStop(_local2);
}
}
function killBall() {
gameState = STATE_NOT_RUNNING;
}
function init() {
}
static var STATE_RUNNING = 0;
static var STATE_NOT_RUNNING = 1;
}
Symbol 180 MovieClip [__Packages.com.king.SuperBall.Game] Frame 0
class com.king.SuperBall.Game extends MovieClip
{
var bg1Float, bg2Float, bg1Pos, bg2Pos, ballSpeed, delay, gameState, currentTick, mcBackGround, playerBreak, ballSpeedCounter, breaking, breakBallSpeed, level, random, cObjectsCounter, noOfCObj, lastDist, playerLife, minSpeed, maxSpeed, _parent, attachMovie, getNextHighestDepth, mcBall, lastCrashAnim;
function Game () {
super();
bg1Float = new com.king.timing.IFloat();
bg2Float = new com.king.timing.IFloat();
bg1Pos = 0;
bg2Pos = 490;
bg1Float.setTo(bg1Pos);
bg2Float.setTo(bg2Pos);
ballSpeed = 0;
delay = new com.king.util.Delay();
}
function tick(tick, tps) {
switch (gameState) {
case STATE_RUNNING :
currentTick = tick;
cDetect();
createObject();
controllBallSpeed();
calcDistance();
var _local2 = 0;
while (_local2 < cObjectsArr.length) {
cObjectsArr[_local2].tick(tick, tps);
_local2++;
}
bg1Pos = bg1Pos + ballSpeed;
bg2Pos = bg2Pos + ballSpeed;
bg1Float.set(bg1Pos);
bg2Float.set(bg2Pos);
case STATE_NOT_RUNNING :
}
}
function render(tick, alpha) {
switch (gameState) {
case STATE_RUNNING :
var _local2 = 0;
while (_local2 < cObjectsArr.length) {
cObjectsArr[_local2].render(tick, alpha);
_local2++;
}
mcBackGround.mcSand1._y = (bg1Float.get(alpha) % 980) + 1;
mcBackGround.mcSand2._y = (bg2Float.get(alpha) % 980) + 1;
case STATE_NOT_RUNNING :
}
}
function onPress() {
if ((playerBreak > 0) && (gameState != STATE_NOT_RUNNING)) {
ballSpeedCounter = 14;
breaking = true;
com.king.util.SoundManager.play("brake", 75, true);
breakBallSpeed = Math.max(ballSpeed, breakBallSpeed);
}
}
function onRelease() {
breaking = false;
com.king.util.SoundManager.stop("brake");
}
function onDragOut() {
breaking = false;
com.king.util.SoundManager.stop("brake");
}
function startRound(lvl, rnd) {
level = lvl;
random = rnd;
cObjectsCounter = 0;
ballSpeedCounter = 0;
ballSpeed = 10;
noOfCObj = 0;
distance = 0;
lastDist = 0;
playerLife = 100;
playerBreak = 100;
minSpeed = 10;
maxSpeed = 50;
breakBallSpeed = 0;
gameState = STATE_RUNNING;
}
function endRound() {
_parent.endGame();
}
function clearLevel() {
}
function createObject() {
if ((distance - lastDist) >= 250) {
if (random.nextInt(4) == 0) {
if (noOfCObj < 4) {
lastDist = distance;
var _local3 = random.nextInt(20);
if (_local3 == 0) {
var _local2 = attachMovie("SObject", "sObject_" + cObjectsCounter, getNextHighestDepth());
} else if (_local3 == 1) {
var _local2 = attachMovie("LObject", "lObject_" + cObjectsCounter, getNextHighestDepth());
} else {
var _local2 = attachMovie("CObject", "cObject_" + cObjectsCounter, getNextHighestDepth());
}
var _local4 = 25 + random.nextInt(330);
_local2.init(_local4, cObjectsArr.length, random.nextInt(10) + 1);
cObjectsCounter++;
noOfCObj++;
cObjectsArr.push(_local2);
}
}
}
}
function removeCObject(theObj) {
theObj.removeMovieClip();
noOfCObj--;
}
function cDetect() {
var _local3 = "";
var _local2 = 0;
while (_local2 < cObjectsArr.length) {
if (cObjectsArr[_local2].hitTest(mcBall._x, mcBall._y, true)) {
_local3 = cObjectsArr[_local2];
} else if (cObjectsArr[_local2].hitTest(mcBall._x, mcBall._y + 32.5, true)) {
_local3 = cObjectsArr[_local2];
} else if (cObjectsArr[_local2].hitTest(mcBall._x + 22.4, mcBall._y - 22.75, true)) {
_local3 = cObjectsArr[_local2];
} else if (cObjectsArr[_local2].hitTest(mcBall._x + 32, mcBall._y, true)) {
_local3 = cObjectsArr[_local2];
} else if (cObjectsArr[_local2].hitTest(mcBall._x + 22.4, mcBall._y + 22.75, true)) {
_local3 = cObjectsArr[_local2];
} else if (cObjectsArr[_local2].hitTest(mcBall._x, mcBall._y - 32.5, true)) {
_local3 = cObjectsArr[_local2];
} else if (cObjectsArr[_local2].hitTest(mcBall._x - 22.4, mcBall._y + 22.75, true)) {
_local3 = cObjectsArr[_local2];
} else if (cObjectsArr[_local2].hitTest(mcBall._x - 32, mcBall._y, true)) {
_local3 = cObjectsArr[_local2];
} else if (cObjectsArr[_local2].hitTest(mcBall._x - 22.4, mcBall._y - 22.75, true)) {
_local3 = cObjectsArr[_local2];
}
_local2++;
}
switch (_local3.type) {
case "collision" :
com.king.util.SoundManager.play("krash", 100, false);
updateLife(-25);
removeCObject(_local3);
lastCrashAnim = attachMovie("CrashAnimRed", "crashAnim_" + crashAnimCounter, getNextHighestDepth());
lastCrashAnim._y = mcBall._y;
lastCrashAnim._x = mcBall._x;
crashAnimCounter++;
break;
case "deceleration" :
updateBreak(10);
removeCObject(_local3);
com.king.util.SoundManager.play("newBrake", 100, false);
lastCrashAnim = attachMovie("CrashAnimWhite", "crashAnim_" + crashAnimCounter, getNextHighestDepth());
lastCrashAnim._y = mcBall._y;
lastCrashAnim._x = mcBall._x;
crashAnimCounter++;
break;
case "life" :
updateLife(10);
removeCObject(_local3);
com.king.util.SoundManager.play("newBrake", 100, false);
lastCrashAnim = attachMovie("CrashAnimWhite", "crashAnim_" + crashAnimCounter, getNextHighestDepth());
lastCrashAnim._y = mcBall._y;
lastCrashAnim._x = mcBall._x;
crashAnimCounter++;
}
}
function controllBallSpeed() {
ballSpeedCounter++;
if (breaking) {
if (ballSpeedCounter == 15) {
ballSpeed = Math.max(ballSpeed - 2, minSpeed);
updateBreak(-1);
if (playerBreak <= 0) {
com.king.util.SoundManager.stop("brake");
breaking = false;
ballSpeedCounter = 0;
} else {
ballSpeedCounter = 14;
}
}
} else if (ballSpeed < breakBallSpeed) {
if (ballSpeedCounter == 15) {
ballSpeed = Math.min(ballSpeed + 1, maxSpeed);
ballSpeedCounter = 14;
}
} else if (ballSpeedCounter == 15) {
ballSpeed = Math.min(ballSpeed + 1, maxSpeed);
trace(ballSpeed);
if (ballSpeed > 25) {
ballSpeedCounter = -60;
} else if (ballSpeed > 20) {
ballSpeedCounter = -30;
} else {
ballSpeedCounter = 0;
}
}
}
function calcDistance() {
distance = distance + ballSpeed;
_parent.mcDistance.txtDistance.text = Math.round(Number(distance / 100));
}
function updateLife(num) {
playerLife = playerLife + num;
if (playerLife > 100) {
playerLife = 100;
}
if (playerLife <= 0) {
ballDead();
} else {
_parent.mcLifeBar.mcBar._width = playerLife;
}
}
function ballDead() {
_parent.mcLifeBar.mcBar._width = 0;
com.king.util.SoundManager.stop("krash");
com.king.util.SoundManager.stop("brake");
com.king.util.SoundManager.play("krash2", 100, false);
com.king.util.SoundManager.stop("loop");
_parent.endGamePressed = true;
lastCrashAnim.removeMovieClip();
lastCrashAnim = attachMovie("CrashAnimBlack", "crashAnim_" + crashAnimCounter, getNextHighestDepth());
lastCrashAnim._y = mcBall._y;
lastCrashAnim._x = mcBall._x;
mcBall.gotoAndPlay(2);
mcBall.killBall();
gameState = STATE_NOT_RUNNING;
com.king.util.Delay.oneShot(this, endRound, 5000);
}
function updateBreak(num) {
playerBreak = playerBreak + num;
if (playerBreak > 100) {
playerBreak = 100;
}
if (playerBreak <= 0) {
_parent.mcBreakBar.mcBar._width = 0;
} else {
_parent.mcBreakBar.mcBar._width = playerBreak;
}
}
static var STATE_RUNNING = 0;
static var STATE_NOT_RUNNING = 1;
static var TICKS_PER_SEC = 25;
var distance = 0;
var cObjectsArr = new Array();
var crashAnimCounter = 0;
}
Symbol 181 MovieClip [__Packages.com.king.util.Delay] Frame 0
class com.king.util.Delay
{
var m_fn, m_param, m_context, m_delay, m_started, m_timerId;
function Delay (context, fn, delay) {
m_fn = fn;
m_param = new Array();
var _local3 = 3;
while (_local3 < arguments.length) {
m_param.push(arguments[_local3]);
_local3++;
}
m_context = context;
m_delay = delay;
m_started = getTimer();
m_timerId = setInterval(mx.utils.Delegate.create(this, onEvent), delay);
}
function onEvent() {
if (getTimer() >= (m_delay + m_started)) {
clearInterval(m_timerId);
m_fn.apply(m_context, m_param);
m_fn = undefined;
m_param = undefined;
}
}
static function oneShot(context, fn, delay) {
var _local3 = new com.king.util.Delay(context, fn, delay);
_local3.m_param = new Array();
var _local2 = 3;
while (_local2 < arguments.length) {
_local3.m_param.push(arguments[_local2]);
_local2++;
}
}
}
Symbol 182 MovieClip [__Packages.mx.utils.Delegate] Frame 0
class mx.utils.Delegate extends Object
{
var func;
function Delegate (f) {
super();
func = f;
}
static function create(obj, func) {
var _local2 = function () {
var _local2 = arguments.callee.target;
var _local3 = arguments.callee.func;
return(_local3.apply(_local2, arguments));
};
_local2.target = obj;
_local2.func = func;
return(_local2);
}
function createDelegate(obj) {
return(create(obj, func));
}
}
Symbol 183 MovieClip [__Packages.com.king.util.Map] Frame 0
class com.king.util.Map
{
var map, lastSize;
function Map (init) {
map = new Object();
for (var _local3 in init) {
map["" + _local3] = init[_local3];
}
lastSize = -1;
}
function put(key, value) {
map["" + key] = value;
lastSize = -1;
}
function get(key) {
return(map["" + key]);
}
function remove(key) {
var _local2 = "" + key;
var _local3 = map[_local2];
delete map[_local2];
lastSize = -1;
return(_local3);
}
function contains(key) {
return(map["" + key] != undefined);
}
function count() {
if (lastSize < 0) {
lastSize = 0;
for (var _local2 in map) {
lastSize++;
}
}
return(lastSize);
}
function size() {
return(count());
}
function clear() {
map = {};
lastSize = 0;
}
function dump() {
var _local2 = "";
for (var _local3 in map) {
_local2 = _local2 + (((_local3 + "=>") + map[_local3]) + newline);
}
trace(_local2);
}
function toArray() {
var _local2 = [];
for (var _local3 in map) {
_local2[_local2.length] = map[_local3];
}
return(_local2);
}
function keySet() {
var _local2 = [];
for (var _local3 in map) {
_local2[_local2.length] = _local3;
}
return(_local2);
}
function get iterator() {
return(new com.king.util.MapIterator(this));
}
function get valueIterator() {
return(new com.king.util.MapValueIterator(this));
}
function foreach(fn) {
var _local3 = arguments.slice(1);
if (_local3.length > 0) {
do {
if ((in map) == null) {
break;
}
var _local5 = in map;
} while (fn(_local5, map[_local5], _local3[0], _local3[1], _local3[2], _local3[3], _local3[4]) != false);
do {
} while ("foreach" != null);
} else {
do {
if ((in map) == null) {
break;
}
var _local5 = in map;
} while (fn(_local5, map[_local5]) != false);
do {
} while (_local2 != null);
}
lastSize = -1;
}
function get _content() {
return(map);
}
}
Symbol 184 MovieClip [__Packages.com.king.util.Iterator] Frame 0
interface com.king.util.Iterator
{
}
Symbol 185 MovieClip [__Packages.com.king.util.MapIterator] Frame 0
class com.king.util.MapIterator implements com.king.util.Iterator
{
var map, keys, ptr;
function MapIterator (map) {
this.map = map;
keys = map.keySet();
ptr = 0;
}
function next() {
if (ptr < keys.length) {
return(keys[ptr++]);
}
return(undefined);
}
function hasNext() {
return(ptr != keys.length);
}
function remove() {
if (ptr == 0) {
return(undefined);
}
map.remove(keys[ptr - 1]);
}
}
Symbol 186 MovieClip [__Packages.com.king.util.MapValueIterator] Frame 0
class com.king.util.MapValueIterator implements com.king.util.Iterator
{
var map, mapRef, keys, ptr;
function MapValueIterator (map) {
this.map = map;
mapRef = map._content;
keys = map.keySet();
ptr = 0;
}
function next() {
return(mapRef[keys[ptr++]]);
}
function hasNext() {
return(ptr != keys.length);
}
function remove() {
if (ptr == 0) {
return(undefined);
}
map.remove(keys[ptr - 1]);
}
}
Symbol 187 MovieClip [__Packages.com.king.util.SoundManager] Frame 0
class com.king.util.SoundManager
{
static var globalSound;
function SoundManager () {
}
static function isSoundEnabled() {
return(soundEnabled);
}
static function enableSounds(enabled) {
soundEnabled = enabled;
if (!enabled) {
muteAll();
} else {
restoreMuteAll();
}
}
static function toggleSound() {
if (globalSound == undefined) {
globalSound = new Sound(_root);
}
soundOn = !soundOn;
globalSound.setVolume((soundOn ? 100 : 0));
}
static function stopAll() {
sounds.foreach(function (name, soundEntry) {
soundEntry.sound.stop();
soundEntry.playStatus = false;
});
}
static function muteAll() {
sounds.foreach(function (name, soundEntry) {
soundEntry.sound.setVolume(0);
soundEntry.isMuted = true;
});
}
static function restoreMuteAll() {
sounds.foreach(function (name, soundEntry) {
soundEntry.sound.setVolume(soundEntry.realVol);
soundEntry.isMuted = false;
});
}
static function stop(resource) {
var _local1 = sounds.get(resource);
if (_local1 != undefined) {
_local1.sound.stop();
_local1.playStatus = false;
}
}
static function getCalibratedVolume(flashVolume) {
flashVolume = Math.min(100, flashVolume);
flashVolume = Math.max(0, flashVolume);
return(Math.ceil(Math.pow(flashVolume / 100, 1.46) * 100));
}
static function setVolume(resource, percent) {
var _local1 = sounds.get(resource);
if ((_local1 != undefined) && (_local1.playStatus == true)) {
var _local2 = getCalibratedVolume(percent);
if (!_local1.isMuted) {
_local1.sound.setVolume(_local2);
}
_local1.realVol = _local2;
}
}
static function isPlaying(resource) {
var _local1 = sounds.get(resource);
return((_local1 != undefined) && (_local1.playStatus == true));
}
static function initialize(list) {
for (var _local9 in list) {
var resource = list[_local9];
var _local3 = _root.getNextHighestDepth();
var _local2 = new Sound(_root.createEmptyMovieClip("sm_sndhold_" + _local3, _local3));
_local2.attachSound(resource);
_local2.onSoundComplete = function () {
var _local1 = com.king.util.SoundManager.sounds.get(resource);
_local1.playStatus = false;
};
sounds.put(resource, {realVol:100, sound:_local2, playStatus:false});
}
}
static function play(resource, volume, isLoop, fn) {
if (volume == undefined) {
volume = 100;
}
if (isLoop == undefined) {
isLoop = false;
}
volume = getCalibratedVolume(volume);
var _local2 = sounds.get(resource);
if (_local2 != undefined) {
_local2.sound.setVolume((soundEnabled ? (volume) : 0));
_local2.realVol = volume;
_local2.isMuted = !soundEnabled;
_local2.playStatus = true;
_local2.onPlayedFn = fn;
_local2.sound.start(0, (isLoop ? 32767 : 1));
} else {
var _local6 = _root.getNextHighestDepth();
var _local4 = new Sound(_root.createEmptyMovieClip("sm_sndhold_" + _local6, _local6));
_local4.attachSound(resource);
_local4.onSoundComplete = function () {
var _local1 = com.king.util.SoundManager.sounds.get(resource);
_local1.playStatus = false;
com.king.util.SoundManager.onPlayed_(resource);
};
_local4.setVolume((soundEnabled ? (volume) : 0));
_local4.start(0, (isLoop ? 32767 : 1));
sounds.put(resource, {isMuted:!soundEnabled, realVol:volume, onPlayedFn:fn, sound:_local4, playStatus:true});
}
}
static function onPlayed_(name) {
var _local1 = sounds.get(name);
if ((_local1 != undefined) && (_local1.onPlayedFn != undefined)) {
_local1.onPlayedFn();
}
}
static var sounds = new com.king.util.Map();
static var soundEnabled = true;
static var soundOn = true;
}
Symbol 188 MovieClip [__Packages.com.king.timing.Timeable] Frame 0
interface com.king.timing.Timeable
{
}
Symbol 189 MovieClip [__Packages.com.king.SuperBall.SuperBall] Frame 0
class com.king.SuperBall.SuperBall extends MovieClip implements com.king.timing.Timeable
{
var m_mainTimer, onEnterFrame, communicator, delay, fpsCounter, fpsTimer, mcClick, mcGameOverScreen, mcExit, mcSound, gameState, currentTick, mcGame, random, mcIntroScreen, mcDistance, mcLifeBar, mcBreakBar, ticksLeft, mcCounter, txtFPS;
function SuperBall () {
super();
m_mainTimer = new com.king.timing.Timer(this, TICKS_PER_SEC);
onEnterFrame = mx.utils.Delegate.create(this, drive);
communicator = new com.king.util.Communicator();
delay = new com.king.util.Delay();
fpsCounter = 0;
fpsTimer = 0;
mcClick.onPress = function () {
this._parent.ticksLeft = 0;
this._visible = false;
};
mcGameOverScreen._visible = false;
mcExit.onPress = function () {
if (!this.endGamePressed) {
this._parent.mcGame.endRound();
this.endGamePressed = true;
}
};
mcSound.onPress = function () {
com.king.util.SoundManager.toggleSound();
if (this._parent.soundOn) {
this.txtSound.text = _global.textMappings.sound_on;
this._parent.soundOn = false;
} else {
this.txtSound.text = _global.textMappings.sound_off;
this._parent.soundOn = true;
}
};
gameState = STATE_WAIT_FOR_GAMEDATA;
}
function drive() {
m_mainTimer.advanceTime2();
}
function tick(tick) {
currentTick = tick;
mcGame.mcBall.tick(tick, TICKS_PER_SEC);
switch (gameState) {
case STATE_WAIT_FOR_GAMEDATA :
if (DEBUG_MODE) {
_root.gameData = DEBUG_GAME_DATA;
}
if (_root.gameData != undefined) {
communicator.gameStarted();
communicator.parseGameData(_root.gameData);
random = new com.king.util.Random(Math.random() * 1000);
mcIntroScreen.txtHeader.text = _global.textMappings.instructions_header;
mcIntroScreen.txtInstructions1.text = _global.textMappings.instructions1;
mcIntroScreen.txtInstructions2.text = _global.textMappings.instructions2;
mcIntroScreen.txtInstructions3.text = _global.textMappings.instructions3;
mcIntroScreen.txtClickToCont.text = _global.textMappings.click_to_cont;
mcGameOverScreen.txtHeader.text = _global.textMappings.game_over;
mcGameOverScreen.txtGameOverText.text = _global.textMappings.game_over_text;
mcGameOverScreen.txtClickToCont.text = _global.textMappings.click_to_end;
mcGameOverScreen.mcDistance.txtDistanceLable.text = _global.textMappings.distance;
mcDistance.txtDistanceLable.text = _global.textMappings.distance;
mcLifeBar.txtLife.text = _global.textMappings.life;
mcBreakBar.txtBrake.text = _global.textMappings.brake;
mcExit.txtExit.text = _global.textMappings.exit;
mcSound.txtSound.text = _global.textMappings.sound_off;
showInfoScreen();
}
break;
case STATE_SHOW_INFO_SCREEN :
ticksLeft = ticksLeft - 1;
if (ticksLeft <= 0) {
startCounter();
}
mcIntroScreen.txtCountDown.text = _global.textMappings.game_starts_in.split("[0]").join("" + Math.round(ticksLeft / 25));
break;
case STATE_COUNTER :
cTicks++;
mcCounter.gotoAndStop(cTicks);
switch (cTicks) {
case 9 :
com.king.util.SoundManager.play("ready", 100, false);
break;
case 37 :
com.king.util.SoundManager.play("steady", 100, false);
break;
case 63 :
com.king.util.SoundManager.play("go", 100, false);
break;
case 96 :
startRound();
}
break;
case STATE_PLAY_GAME :
mcGame.tick(tick, TICKS_PER_SEC);
break;
case STATE_BETWEEN_ROUNDS :
ticksLeft = ticksLeft - 1;
if (ticksLeft == 0) {
ticksLeft = 10 * TICKS_PER_SEC;
}
break;
case STATE_END_GAME :
ticksLeft = ticksLeft - 1;
if (ticksLeft <= 0) {
gamePreQuit();
}
mcGameOverScreen.txtCountDown.text = _global.textMappings.game_ends_in.split("[0]").join("" + Math.round(ticksLeft / 25));
case STATE_NOT_RUNNING :
}
}
function render(tick, alpha) {
fpsCounter++;
if ((getTimer() - fpsTimer) >= 1000) {
txtFPS.text = fpsCounter;
fpsCounter = 0;
fpsTimer = getTimer();
}
mcGame.mcBall.render(tick, alpha);
if (!(gameState === STATE_PLAY_GAME)) {
} else {
mcGame.render(tick, alpha);
}
}
function startCounter() {
com.king.util.SoundManager.stop("intro");
mcIntroScreen._visible = false;
mcGame.mcBall._y = 391;
gameState = STATE_COUNTER;
}
function showInfoScreen() {
ticksLeft = TICKS_PER_SEC * 15;
com.king.util.SoundManager.play("intro", 70, true);
mcIntroScreen._visible = true;
gameState = STATE_SHOW_INFO_SCREEN;
}
function endGame(num) {
com.king.util.SoundManager.stop("loop");
com.king.util.SoundManager.play("outro", 70, false);
ticksLeft = TICKS_PER_SEC * 15;
mcGameOverScreen._visible = true;
mcGameOverScreen.mcDistance.txtDistance.text = Math.round(Number(mcGame.distance / 100));
mcClick._visible = true;
gameState = STATE_END_GAME;
}
function startRound() {
level++;
com.king.util.SoundManager.stop("intro");
com.king.util.SoundManager.play("loop", 70, true);
mcClick._visible = false;
gameState = STATE_PLAY_GAME;
mcGame.startRound(level, random);
}
function endRound() {
}
function gamePreQuit() {
communicator.gameEnd(Math.round(mcGame.distance / 100));
com.king.util.Delay.oneShot(this, gameQuit, 1500);
gameState = STATE_NOT_RUNNING;
}
function gameQuit() {
communicator.gameQuit();
}
static var STATE_WAIT_FOR_GAMEDATA = 0;
static var STATE_SHOW_INFO_SCREEN = 1;
static var STATE_PLAY_GAME = 2;
static var STATE_COUNTER = 3;
static var STATE_BETWEEN_ROUNDS = 4;
static var STATE_END_GAME = 5;
static var STATE_NOT_RUNNING = 6;
static var TICKS_PER_SEC = 25;
var soundOn = true;
var score = 0;
var level = 0;
var cTicks = 0;
var endGamePressed = false;
static var DEBUG_MODE = true;
static var DEBUG_GAME_DATA = ("<gamedata randomseed=\"" + Math.round(5000 * Math.random())) + "\" timelimit=\"660\" lang=\"de\"><text id=\"game_starts_in\">The game starts in [0] seconds!</text><text id=\"instructions_header\">Instructions</text><text id=\"instructions1\">Game instructions ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... </text><text id=\"instructions2\">Instructions ... ... ... ... </text><text id=\"instructions3\">Instructions ... ... ... ... </text><text id=\"click_to_cont\">Click to continue</text><text id=\"click_to_end\">Click to end game</text><text id=\"brake\">Brake</text><text id=\"life\">Life</text><text id=\"distance\">Distance</text><text id=\"sound_on\">Sound On</text><text id=\"sound_off\">Sound Off</text><text id=\"exit\">Exit</text><text id=\"game_over\">Game Over</text><text id=\"game_over_text\">Game over ... ... ... .... ... ... ... ..</text><text id=\"game_ends_in\">Game ends in [0] seconds</text><userType id=\"0\">1</userType></gamedata>";
}
Symbol 190 MovieClip [__Packages.com.king.timing.Timer] Frame 0
class com.king.timing.Timer
{
var timeable;
function Timer (timeable, gameTicksPerSecond) {
millisPerGameTick = 1000 / gameTicksPerSecond;
this.timeable = timeable;
maxTickTime = 500;
}
function getMillisPerTick() {
return(millisPerGameTick);
}
function setMaxTickTime(millis) {
maxTickTime = millis;
}
function advanceTime2() {
var _local3 = getTimer();
if (startTime < 0) {
startTime = _local3;
unprocessedTime = millisPerGameTick;
}
time = _local3 - startTime;
var _local5 = time - lastTime;
lastTime = time;
unprocessedTime = unprocessedTime + _local5;
if (unprocessedTime >= millisPerGameTick) {
var _local2 = maxTickTime + _local3;
do {
timeable.tick(tick);
tick++;
unprocessedTime = unprocessedTime - millisPerGameTick;
} while ((unprocessedTime >= millisPerGameTick) && (getTimer() < _local2));
}
var _local4 = (unprocessedTime % millisPerGameTick) / millisPerGameTick;
com.king.timing.IFloat.setAlpha(_local4);
timeable.render(tick, _local4);
}
function advanceTime() {
time = getTimer();
var _local3 = time - lastTime;
lastTime = time;
unprocessedTime = unprocessedTime + _local3;
var _local2 = 0;
while (unprocessedTime > millisPerGameTick) {
unprocessedTime = unprocessedTime - millisPerGameTick;
timeable.tick(tick);
tick++;
_local2++;
if (_local2 >= 10) {
unprocessedTime = 0;
}
}
var _local4 = unprocessedTime / millisPerGameTick;
timeable.render(tick, _local4);
}
var time = 0;
var startTime = -1;
var lastTime = 0;
var unprocessedTime = 0;
var tick = 0;
var millisPerGameTick = 0;
var maxTickTime = -1;
}
Symbol 191 MovieClip [__Packages.com.king.util.Communicator] Frame 0
class com.king.util.Communicator
{
var levelDatas, randomSeed, lang;
function Communicator () {
levelDatas = new Array();
}
function gameStarted() {
trace("GAME START");
if (!hasSentGameStart) {
hasSentGameStart = true;
fscommand ("gameStart");
}
}
function gameQuit() {
trace("GAME QUIT");
if (!hasSentGameOver) {
hasSentGameOver = true;
fscommand ("gameQuit");
}
}
function gameEnd(score) {
trace("GAME ENDS");
if (!hasSentGameEnd) {
hasSentGameEnd = true;
fscommand ("gameEnd", score);
}
}
function startFirstRound(tick) {
fscommand ("playData", (CMD_START_FIRST_ROUND + ",") + tick);
}
function sendModelClicked(tick, modelNum) {
fscommand ("playData", (((CMD_MODEL_CLICKED + ",") + tick) + " ") + modelNum);
}
function sendModelMove(tick, modelNum, stationNum) {
fscommand ("playData", (((((CMD_MODEL_MOVE + ",") + tick) + " ") + modelNum) + " ") + stationNum);
}
function sendModelReleased(tick, modelNum) {
fscommand ("playData", (((CMD_MODEL_RELEASED + ",") + tick) + " ") + modelNum);
}
function latteClick(tick) {
fscommand ("playData", (CMD_LATTE_CLICKED + ",") + tick);
}
function latteMugReleased(tick, modelNum) {
fscommand ("playData", (((CMD_LATTE_MUG_RELEASED + ",") + tick) + " ") + modelNum);
}
function barClicked(tick, stationNum) {
fscommand ("playData", (((CMD_BAR_CLICKED + ",") + tick) + " ") + stationNum);
}
function barTargetClicked(tick, stationNum) {
fscommand ("playData", (((CMD_BARTARGET_CLICKED + ",") + tick) + " ") + stationNum);
}
function barPoseClicked(tick, stationNum) {
fscommand ("playData", (((CMD_BARPOSE_CLICKED + ",") + tick) + " ") + stationNum);
}
function sendEndRound(tick) {
fscommand ("playData", (CMD_END_ROUND + ",") + tick);
}
function gameLastTick(tick) {
if (!hasSentLastTick) {
hasSentLastTick = true;
fscommand ("playData", (CMD_LAST_TICK + ",") + tick);
}
}
function sendScore(tick, score) {
fscommand ("playData", (((CMD_SEND_SCORE + ",") + tick) + " ") + score);
}
function scoreUpdate(tick, score) {
fscommand ("playData", (((CMD_SCORE_UPDATE + ",") + tick) + " ") + score);
}
function sendClientSpawn(tick) {
fscommand ("playData", (CMD_CLIENT_SPAWN + ",") + tick);
}
function sendRandomNum(tick, rndNum) {
fscommand ("playData", (((CMD_SEND_RANDOM_NUM + ",") + tick) + " ") + rndNum);
}
function parseGameData(gameData) {
var _local6 = new XML(_root.gameData);
_global.textMappings = new Object();
_global.userType = new Object();
var _local5 = _local6.childNodes[0].childNodes;
randomSeed = new Number(_local6.childNodes[0].attributes.randomseed).valueOf();
lang = _local6.childNodes[0].attributes.lang.valueOf();
var _local4 = 0;
while (_local4 < _local5.length) {
_root.debugText.text = _root.debugText.text + ("\r" + _local5[_local4].nodeName);
if (_local5[_local4].nodeName == "text") {
_global.textMappings[_local5[_local4].attributes.id] = new String(_local5[_local4].firstChild.nodeValue);
}
if (_local5[_local4].nodeName == "level") {
levelDatas[_local5[_local4].attributes.id] = new String(_local5[_local4].firstChild.nodeValue);
}
if (_local5[_local4].nodeName == "userType") {
_global.userType[_local5[_local4].attributes.id] = new String(_local5[_local4].firstChild.nodeValue);
}
_local4++;
}
}
static var CMD_START_FIRST_ROUND = 266;
static var CMD_MODEL_CLICKED = 389;
static var CMD_MODEL_MOVE = 222;
static var CMD_MODEL_RELEASED = 212;
static var CMD_LATTE_CLICKED = 554;
static var CMD_LATTE_MUG_RELEASED = 696;
static var CMD_BAR_CLICKED = 774;
static var CMD_BARTARGET_CLICKED = 757;
static var CMD_BARPOSE_CLICKED = 159;
static var CMD_END_ROUND = 853;
static var CMD_LAST_TICK = 912;
static var CMD_SEND_SCORE = 428;
static var CMD_SCORE_UPDATE = 397;
static var CMD_CLIENT_SPAWN = 13;
static var CMD_SEND_RANDOM_NUM = 99;
var hasSentGameStart = false;
var hasSentGameEnd = false;
var hasSentGameOver = false;
var hasSentLastTick = false;
}
Symbol 192 MovieClip [__Packages.com.king.util.Random] Frame 0
class com.king.util.Random
{
var mta, mti, lastSeed;
function Random (aSeed) {
mta = new Array(N);
mti = N + 1;
if (aSeed != undefined) {
init_genrand(aSeed);
}
}
function set seed(s) {
init_genrand(s);
//return(seed);
}
function get seed() {
return(lastSeed);
}
function nextInt(n) {
return((genrand_int32() & 2147483647) % n);
}
function nextFloat() {
return(next(24) / 16777216);
}
function next(bits) {
if (bits < 32) {
return(genrand_int32() & ((1 << bits) - 1));
}
return(genrand_int32());
}
function init_genrand(s) {
s = int(s);
var _local5 = getTimer();
lastSeed = s;
mta[0] = s;
var _local2 = s;
var _local3 = new com.king.util.Integer64();
mti = 1;
while (mti < N) {
_local3.init32((_local2 >>> 30) ^ _local2);
_local3.mulu32(1812433253);
_local2 = (mta[mti] = int(_local3.lsb + mti));
mti++;
}
var _local6 = getTimer();
}
function genrand_int32() {
var _local3 = 0;
if (mti >= N) {
if (mti == (N + 1)) {
init_genrand(5489);
}
var _local4 = getTimer();
var _local2 = 0;
_local2 = 0;
while (_local2 < (N - M)) {
_local3 = (mta[_local2] & UPPER_MASK) | (mta[_local2 + 1] & LOWER_MASK);
mta[_local2] = (mta[_local2 + M] ^ (_local3 >>> 1)) ^ mag01[_local3 & 1];
_local2++;
}
while (_local2 < (N - 1)) {
_local3 = (mta[_local2] & UPPER_MASK) | (mta[_local2 + 1] & LOWER_MASK);
mta[_local2] = (mta[_local2 + (M - N)] ^ (_local3 >>> 1)) ^ mag01[_local3 & 1];
_local2++;
}
_local3 = (mta[N - 1] & UPPER_MASK) | (mta[0] & LOWER_MASK);
mta[N - 1] = (mta[M - 1] ^ (_local3 >>> 1)) ^ mag01[_local3 & 1];
mti = 0;
var _local5 = getTimer();
}
_local3 = mta[mti++];
_local3 = _local3 ^ (_local3 >>> 11);
_local3 = _local3 ^ ((_local3 << 7) & 2636928640);
_local3 = _local3 ^ ((_local3 << 15) & 4022730752);
_local3 = _local3 ^ (_local3 >>> 18);
return(_local3);
}
static var N = 624;
static var M = 397;
static var MATRIX_A = 2567483615;
static var UPPER_MASK = 2147483648;
static var LOWER_MASK = 2147483647;
static var mag01 = [0, 2567483615];
}
Symbol 193 MovieClip [__Packages.com.king.util.Integer64] Frame 0
class com.king.util.Integer64
{
var r, p, s;
function Integer64 (lowInt) {
r = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]];
p = [0, 0, 0, 0, 0];
s = [0, 0, 0];
if (lowInt != undefined) {
merge(lowInt);
}
}
function init(v) {
var _local2 = 0;
while (_local2 < p.length) {
p[_local2] = v.p[_local2];
_local2++;
}
}
function init32(n) {
p[0] = n & 32767;
n = n >>> 15;
p[1] = n & 32767;
n = n >>> 15;
p[2] = n & 3;
p[3] = 0;
p[4] = 0;
}
function get lsb() {
return((p[0] | (p[1] << SH)) | ((p[2] & 3) << 30));
}
function get msb() {
return((((p[2] >> 2) | ((p[3] << SH) >> 2)) | ((p[4] << (SH * 2)) >> 2)) & 2147483647);
}
function binaryShiftLeft(step) {
var _local2 = 0;
while (_local2 < step) {
shl();
_local2++;
}
}
function binaryShiftRight(step) {
var _local4 = (step / SH) >> 0;
var _local5 = step - (_local4 * SH);
var _local2 = p.length - 1;
while (_local2 > 0) {
var _local3 = 0;
while (_local3 < _local4) {
p[_local3] = p[_local3 + 1];
_local3++;
}
p[_local2--] = 0;
}
if (_local5 > 0) {
var _local3 = 0;
while (_local3 < _local5) {
shr();
_local3++;
}
}
}
function binaryNot(o) {
p[0] = p[0] ^ o.p[0];
p[1] = p[1] ^ o.p[1];
p[2] = p[2] ^ o.p[2];
p[3] = p[3] ^ o.p[3];
p[4] = p[4] ^ o.p[4];
}
function add64(o) {
var _local4 = 0;
var _local3 = 1;
var _local2 = 0;
while ((_local3 < p.length) && (o.p[_local2] != 0)) {
_local3++;
}
_local2 = 0;
while (_local2 < _local3) {
_local4 = _local4 + (p[_local2] + o.p[_local2]);
p[_local2] = _local4 & MASK;
_local4 = _local4 >> SH;
_local2++;
}
}
function add32(num) {
var _local2 = 0;
var _local5 = num & MASK;
num = num >> SH;
var _local6 = num & MASK;
num = num >> SH;
var _local4 = num & 3;
_local2 = _local2 + (p[0] + _local5);
p[0] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + (p[1] + _local6);
p[1] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + (p[2] + _local4);
p[2] = _local2 & MASK;
}
function mulu32(num) {
var _local3 = 0;
s[0] = num & MASK;
num = num >>> 15;
s[1] = num & MASK;
num = num >>> 15;
s[2] = num & 3;
var _local2 = 0;
while (_local2 < 3) {
var _local4 = s[_local2];
_local3 = _local4 * p[0];
r[_local2][0] = _local3 & MASK;
_local3 = _local3 >> SH;
_local3 = _local3 + (_local4 * p[1]);
r[_local2][1] = _local3 & MASK;
_local3 = _local3 >> SH;
_local3 = _local3 + (_local4 * p[2]);
r[_local2][2] = _local3 & 3;
_local2++;
}
_local3 = r[0][0];
p[0] = _local3 & MASK;
_local3 = _local3 >> SH;
_local3 = _local3 + (r[0][1] + r[1][0]);
p[1] = _local3 & MASK;
_local3 = _local3 >> SH;
_local3 = _local3 + ((r[0][2] + r[1][1]) + r[2][0]);
p[2] = _local3 & 3;
p[3] = 0;
p[4] = 0;
}
function mul64(o) {
var _local2 = 0;
var _local3 = 0;
while (_local3 < 5) {
var _local4 = o.p[_local3];
_local2 = _local4 * p[0];
r[_local3][0] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + (_local4 * p[1]);
r[_local3][1] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + (_local4 * p[2]);
r[_local3][2] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + (_local4 * p[3]);
r[_local3][3] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + (_local4 * p[4]);
r[_local3][4] = _local2 & MASK;
_local3++;
}
_local2 = r[0][0];
p[0] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + (r[0][1] + r[1][0]);
p[1] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + ((r[0][2] + r[1][1]) + r[2][0]);
p[2] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + (((r[0][3] + r[1][2]) + r[2][1]) + r[3][0]);
p[3] = _local2 & MASK;
_local2 = _local2 >> SH;
_local2 = _local2 + ((((r[0][4] + r[1][3]) + r[2][2]) + r[3][1]) + r[4][0]);
p[4] = _local2 & 7;
}
function mul32(value) {
mul64(new com.king.util.Integer64(value));
}
function merge(a) {
var _local2 = 0;
while (_local2 < 3) {
p[_local2] = p[_local2] + (a & 32767);
a = a >>> 15;
_local2++;
}
return(a);
}
function shl() {
var _local5 = 0;
var _local4 = 0;
var _local2 = 0;
var _local3 = p.length;
while (_local2 < _local3) {
_local5 = (p[_local2] & 16384) >> 14;
p[_local2] = p[_local2] << 1;
p[_local2] = (p[_local2] | _local4) & 32767;
_local2++;
_local4 = _local5;
}
}
function shr() {
var _local4 = 0;
var _local3 = 0;
var _local2 = p.length - 1;
while (_local2 >= 0) {
_local4 = (p[_local2] & 1) << 14;
p[_local2] = p[_local2] >> 1;
p[_local2] = (p[_local2] | _local3) & 32767;
_local2--;
_local3 = _local4;
}
}
static var MASK = 32767;
static var SH = 15;
}
Symbol 194 MovieClip [__Packages.com.king.SuperBall.LObject] Frame 0
class com.king.SuperBall.LObject extends MovieClip
{
var ifloat, currentTick, _height, yPos, _parent, lObjNum, _y, _x, removeMovieClip;
function LObject () {
super();
ifloat = new com.king.timing.IFloat();
}
function tick(tick, tps) {
currentTick = tick;
if (yPos >= Number(480 + (_height / 2))) {
_parent.removeCObject(lObjNum);
}
yPos = yPos + _parent.ballSpeed;
ifloat.set(yPos);
}
function render(tick, alpha) {
_y = ifloat.get(alpha);
}
function init(xP, num) {
_x = xP;
yPos = -(_height / 2);
ifloat.setTo(yPos);
lObjNum = num;
}
function removeMe() {
removeMovieClip();
}
var type = "life";
}