lunes, 17 de enero de 2011

highscore en fb

CHICOS AQUI PUEDEN JUGAR

http://apps.facebook.com/gatoscanibales/

CODIGOS

Ship extends MovieClip
{
var velocity;
var shootLimiter;
var enemyTimer;
var miniBossTimer;
var powerUpTimer;
var bossCountdown;
var enemies;
var score;
var finalScore;
var health;
var kills;
var misses;
var shaking;
var shakeDuration;
var shield:MovieClip;
function onLoad()
{
_root.kongregateServices.connect();
_root.soundFX = new Sound();
_root.soundFX.attachSound("very_big_explosion.wav");
_root.soundFX.start();
_visible = false;
_root.gameOverMenu._visible = false;
_root.healthMeter._visible = false;
_root.enemyHealthMeter._visible = false;
_root.playMenu.playButton.onPress = function()
{
_root.ship.newGame();
}
}
function newGame()
{
_root.playMenu._visible = false;
_root.gameOverMenu._visible = false;
_root.enemyHealthMeter._visible = false;
kills = 0;
misses = 0;
velocity = 10;
shootLimiter = 0;
powerUpTimer = 0;
enemyTimer = 0;
miniBossTimer = 0;
bossCountdown = 2;
enemies = [];
score = 0;
_root.scoreText.text = score;
health = 100;
_root.healthMeter._visible = true;
_root.healthMeter.bar._xscale = 100;
_x = 300;
_y = 150;
_visible = true;
shield._visible = false;
shaking = false;
shakeDuration = 10;
_rotation = 0;
}
function onEnterFrame()
{
if(_visible == true)
{
if( Key.isDown(Key.LEFT) && _x > 40){ _x -= velocity; }
if( Key.isDown(Key.RIGHT) && _x < 560){ _x += velocity; }
if( Key.isDown(Key.UP) && _y > 20){ _y -= velocity; }
if( Key.isDown(Key.DOWN) && _y < 280){ _y += velocity; }
shootLimiter += 1;
if( Key.isDown(Key.SPACE) && shootLimiter > 8)
{
var missile = _root.attachMovie("Missile","Missile" + _root.getNextHighestDepth(), _root.getNextHighestDepth());
missile._x = _x + 50;
missile._y = _y + 2;
shootLimiter = 0;
}
if(shaking == true){ shake(); }
if(shield._visible == true)
{
shield._alpha-= .5;
if(shield._alpha < 0)
{
shield._visible = false;
shield._alpha = 100;
}
}
enemyTimer += 1;
if(enemyTimer > 30)
{
enemyTimer = 0;
_root.attachMovie("EnemyShip", "EnemyShip" + _root.getNextHighestDepth(), _root.getNextHighestDepth());
}
powerUpTimer += 1;
if(powerUpTimer > 30 * 10)
{
powerUpTimer = 0;
_root.attachMovie("PowerUp", "PowerUp" + _root.getNextHighestDepth(), _root.getNextHighestDepth());
}
miniBossTimer += 1;
if(miniBossTimer == (30 * 30))
{
if(!_root.miniBoss)
{
if( bossCountdown == 0)
{
_root.attachMovie("Boss", "boss", _root.getNextHighestDepth());
}
else
{
_root.attachMovie("MiniBoss", "miniBoss", _root.getNextHighestDepth());

bossCountdown -= 1;
}
}
}
}
}
function updateScore(points)
{
score += points;
_root.scoreText.text = score;
}
function updateHealth(points)
{
if(_visible == true)
{
health += points;
_root.healthMeter.bar._xscale = health;
_root.soundFX.attachSound("small_explosion.wav");
_root.soundFX.start();
if(health <= 0)
{
health = 0;
_root.healthMeter.bar._xscale = health;
explode();
}
}
}
function explode()
{
var explosion = _root.attachMovie("Explosion","Explosion" + _root.getNextHighestDepth(),_root.getNextHighestDepth());
explosion._x = _x;
explosion._y = _y;
this._visible = false;
_root.soundFX.attachSound("very_big_explosion.wav");
_root.soundFX.start();
destroyAllEnemies();
gameOver();
}
function destroyAllEnemies()
{
for(var i = 0; i< enemies.length; i++)
{
enemies[i].explode();
}
}
function damageAllEnemies()
{
for(var i = 0; i< enemies.length; i++)
{
enemies[i].takeDamage();
}
}
function winGame()
{
_root.kongregateStats.submit("GameWon", 1);
_root.missionCompletedBanner.gotoAndPlay(2);
this._visible = false;
destroyAllEnemies();
gameOver();
}
function gameOver()
{
_root.gameOverMenu._visible=true;
_root.gameOverMenu.killBonus.text = kills + " x " + 100;
_root.gameOverMenu.hitBonus.text = Math.floor((kills/(misses + kills))*100) + " x " + 100;
finalScore = score + (kills * 100) + (Math.floor((kills/(misses + kills))*100)*100);
_root.gameOverMenu.finalScore.text = finalScore;
_root.kongregateScores.submit(finalScore);
_root.kongregateStats.submit("Kills", kills); /
_root.gameOverMenu.playAgainButton.onPress = function()
{
getURL("http://www.facebook.com/connect/prompt_feed.php?&message=Hice%20"+_root.gameOverMenu.finalScore.text+"%20puntos%20en%20el%20juego%20gatos%20canibales%20intenta%20superar%20mi%20puntaje: http://apps.facebook.com/gatoscanibales", "_blank");
}
_root.gameOverMenu.playAgainButton2.onPress = function()
{
_root.ship.newGame();
}
}
function initShake()
{
shaking = true;
shakeDuration = 10;
_rotation = 5;
}
function shake()
{
_rotation *= -1;
shakeDuration -= 1;
if(shakeDuration == 0)
{
shaking = false;
_rotation = 0;
}
}
}


EQUIPO Facebook
Andrea Arias
Josue Brito
Jorge Cucalon

No hay comentarios:

Publicar un comentario