questo e tutto il codice principale:
codice:
stop();
startLevel = 1;
theScore = 0;
if (useMouseOn == undefined)
useMouseOn = 1;
gBallBaseLoc = [208, 329];
gThePaddle = [_level0["paddle"]];
gGameRect = [19, 15, 397, 372];
gHMax = pGameRect[2]-5;
maxLevels = 10; // Livelli Max
TileCountx = 13;
TileCounty = 17;
theNumberOfBalls = 1;
theCurBallNum = 1;
ballsLeft = 2;
pauseBall = 0;
setPause = 0;
if (playsound != 1)
soundbg.gotoAndStop(2);
function moveTheBalls () {
for (x=1; x<=theNumberOfBalls; x++) {
thisBall = theBallsList["ball"+x];
if (!thisBall == 0) {
thisBall.moveBall();
}
}
}
function newBallList (startBallNum) {
this["ball"+startBallNum] = new newBall("ball"+startBallNum);
}
function addNewBall () {
theCurBallNum++;
theBallsList["ball"+theNumberOfBalls] = new newBall("ball"+theNumberOfBalls);
resetPaddleandBall();
}
function newBall (instName) {
duplicateMovieClip ("ball", instName, theNumberOfBalls);
this.name = instName;
this.MovieClip = _level0[instName];
this.MovieClip._x = gBallBaseLoc[0];
this.MovieClip._y = gBallBaseLoc[1];
this.deltaX = getRandom(-5, 5);
this.deltaY = -5;
this.HitNum = 0;
}
newBall.prototype.moveBall = function () {
if (pauseBall == 0)
{
this.MovieClip._x += this.deltaX;
this.MovieClip._y += this.deltaY;
for (i=0; i<=aktTiles; i++) {
thisTile = gTargetList[i];
if (this.MovieClip.hitTest(_level0[thisTile]))
{
obj1_hwidth = (getProperty(this.MovieClip, _width)/2);
obj1_hheight = (getProperty(this.MovieClip, _height)/2);
obj2_hwidth = (getProperty(_level0[thisTile], _width)/2);
obj2_hheight = (getProperty(_level0[thisTile], _height)/2);
obj1_x1 = getProperty(this.MovieClip, _x)-obj1_hwidth;
obj1_x2 = Number(getProperty(this.MovieClip, _x))+Number(obj1_hwidth);
obj1_y1 = getProperty(this.MovieClip, _y)-obj1_hheight;
obj1_y2 = Number(getProperty(this.MovieClip, _y))+Number(obj1_hheight);
obj2_x1 = getProperty(_level0[thisTile], _x)-obj2_hwidth;
obj2_x2 = Number(getProperty(_level0[thisTile], _x))+Number(obj2_hwidth);
obj2_y1 = getProperty(_level0[thisTile], _y)-obj2_hheight;
obj2_y2 = Number(getProperty(_level0[thisTile], _y))+Number(obj2_hheight);
if ((Number(obj2_x1)<=Number(obj1_x2)) && (Number(obj2_x1)>=Number(obj1_x1))) {
this.deltaX = -5;
}
if ((Number(obj2_y1)>=Number(obj1_y1)) && (Number(obj2_y1)<=Number(obj1_y2))) {
this.deltaY = -5;
}
if ((Number(obj2_x2)<=Number(obj1_x2)) && (Number(obj2_x2)>=Number(obj1_x1))) {
this.deltaX = 5;
}
if ((Number(obj2_y2)>=Number(obj1_y1)) && (Number(obj2_y2)<=Number(obj1_y2))) {
this.deltaY = 5;
}
_level0[thisTile].play();
}
}
if (this.MovieClip.hitTest(_level0.paddle) && this.deltaY > 0) {
this.paddleHit(_level0.paddle);
_level0.soundbalken.play();
}
if (this.MovieClip._y>(gGameRect[3]+20)) {
theBallsList[this.name] = 0;
removeMovieClip(this.MovieClip);
theCurBallNum--;
if (theCurBallNum<=0) {
ballsLeft--;
_level0.soundaus.play();
if (ballsLeft<0) {
// Game over
ballsLeft = 0;
gotoAndStop (5);
} else {
addNewBall();
checkLives();
pauseBall = 1;
ball1.deltaX = getRandom(-5, 5);
ball1.deltaY = -5;
}
}
}
if (this.MovieClip._x<=gGameRect[0] || this.MovieClip._x>=gGameRect[2]) {
this.flipX();
}
if (this.MovieClip._y <= gGameRect[1])
{
this.flipY();
}
}
}
newBall.prototype.serveBall = function () {
this.MovieClip._x = gBallBaseLoc[0];
this.MovieClip._y = gBallBaseLoc[1];
this.deltaX = getRandom(-5, 5);
this.deltaY = -5;
}
newBall.prototype.flipY = function () {
this.deltaY *= -1;
}
newBall.prototype.flipX = function () {
this.deltaX *= -1;
}
newBall.prototype.paddleHit = function (thePaddle) {
this.deltaX = (this.MovieClip._x - thePaddle._x)/4;
this.flipY();
this.MovieClip._y = Math.min(this.MovieClip._y, (thePaddle._y)+10);
}
newBall.prototype.increaseSpeed = function(){
if(this.deltaY < -18 || this.deltaY > 18){
}else{
this.hitNum ++;
if(this.hitNum > 3){
this.hitNum = 0;
if(this.deltaY > 0){
this.deltaY ++;
}else{
this.deltaY --;
}
}
}
}
function resetGame ()
{
pauseBall = 1;
maxTiles = 0;
aktTiles = 0;
hitTiles = 0;
TilestoHit = 0;
gTargetList = [];
brickArray=new Array();
clearAllTiles();
checkLives()
ball1._x = gBallBaseLoc[0];
ball1._y = gBallBaseLoc[1];
ball1.deltaX = getRandom(-5, 5);
ball1.deltaY = -5;
paddle._x = gBallBaseLoc[0];
// Load File Asp
loadVariables("Livello.asp?level="+startLevel,dataloader);
level_movie.strlevel = "Level " + startLevel;
level_movie._visible = true;
}
function checkForXtraBall (theBallName) {
var xtraBallNum = xtraBallList.length;
for (i=0; i<xtraBallNum; i++) {
if (theBallName eq xtraBallList[i]) {
return 1;
}
}
}
function getRandom (x, y) {
return Math.round(Math.random()*(y-x))+x;
}
function checkLevel()
{
if (Number(_level0.hitTiles) >= Number(_level0.TilestoHit))
{
if (startLevel < maxLevels)
{
startLevel += 1;
_level0.resetGame();
} else {
_level0.level_movie.strlevel = "DURCHGESPIELT ;)";
_level0.level_movie._visible = true;
}
}
}
function clearAllTiles()
{
for (i=0; i<=aktTiles; i++)
{
removeMovieClip("tile"+i);
}
}
function checkLives()
{
for (i=1; i<=ballsLeft+1; i++)
{
removeMovieClip("lebenball"+i);
}
for (i=1; i<=ballsLeft; i++)
{
lebenName = "lebenball"+i;
duplicateMovieClip("lebenball0",lebenName,999+i);
_level0[lebenName]._x = 12+i*12;
}
}