Here is my final which is combined with my narrative of 5-6 scenes. Added more scenes and two games. Even though the games were just variations on Miles' demos, it was harder tweaking them than I thought it would be! If I had a little more time, I'd clean up the artwork a bit more and add some music. But alas, it is what it is.
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
//add'l imports from DollarBillGame
import flash.events.Event;
import flash.display.*;
import flash.events.*;
import flash.geom.Rectangle; // new
import flash.media.Sound; //new
import flash.text.*; //new
//import for BSGame
public class FinalAnimation extends MovieClip
{
//declare all variables
//from main narrative
var futureScene:FutureScene;
var sweetShopScene:SweetShopScene;
var snailScene:SnailScene;
var magicalScene:MagicalScene;
var unicornScene:UnicornScene;
var deadUnicornScene:DeadUnicornScene;
var cityScene:CityScene;
var crackScene:CrackScene;
var hellScene:HellScene;
var anotherScene:AnotherScene;
//var partyScene:PartyScene;
var endBillScene:EndBillScene;
var redeemScene:RedeemScene;
var britneyGame:BritneyGame;
//from DollarBillGame
public static const STATE_INIT:int = 10;
public static const STATE_PLAY:int = 20;
public static const STATE_END_GAME:int = 30;
public var gameState:int = 0;
public var score:int = 0; //chnaged from clicks to score
public var chances:int = 0; //new
public var partyGameBG:MovieClip; //new
public var dollarBills:Array; //new
public var player:MovieClip; //new
public var level:Number = 0; //new
//public var endBillScene:MovieClip; //TEST
public var scoreLabel:TextField = new TextField();
public var levelLabel:TextField = new TextField();
public var chancesLabel:TextField = new TextField();
public var scoreText:TextField = new TextField();
public var levelText:TextField = new TextField();
public var chancesText:TextField = new TextField();
public const SCOREBOARD_Y:Number =380;
//from BSGame
private static const boardWidth:uint = 6;
private static const boardHeight:uint = 6;
private static const cardHorizontalSpacing:Number = 60;
private static const cardVerticalSpacing:Number = 60;
private static const boardOffsetX:Number = 50;
private static const boardOffsetY:Number = 50;
private static const pointsForMatch:int = 50;
private static const pointsForMiss:int = -5;
private var firstCard:Card;
private var secondCard:Card;
private var cardsLeft:uint;
private var playerGuesses:uint;
private var gameScoreField:TextField;
private var gameScore:int;
public function FinalAnimation()
{
futureScene = new FutureScene();
sweetShopScene = new SweetShopScene();
snailScene = new SnailScene();
magicalScene = new MagicalScene();
unicornScene = new UnicornScene();
deadUnicornScene = new DeadUnicornScene();
cityScene = new CityScene();
crackScene = new CrackScene();
hellScene = new HellScene();
anotherScene = new AnotherScene();
endBillScene = new EndBillScene();
redeemScene = new RedeemScene();
britneyGame = new BritneyGame();
addChild(futureScene);
futureScene.button21.addEventListener(MouseEvent.CLICK, onFutureSceneButton21Click);
sweetShopScene.cupcakeButtonA.addEventListener(MouseEvent.CLICK, onSweetShopSceneCupcakeButtonAClick);
sweetShopScene.cupcakeButtonB.addEventListener(MouseEvent.CLICK, onSweetShopSceneCupcakeButtonBClick);
sweetShopScene.cupcakeButtonC.addEventListener(MouseEvent.CLICK, onSweetShopSceneCupcakeButtonCClick);
snailScene.gameOverButton.addEventListener(MouseEvent.CLICK, onSnailSceneGameOverButtonClick);
magicalScene.sparkleButton.addEventListener(MouseEvent.CLICK, onMagicalSceneSparkleButtonClick);
unicornScene.abortButton.addEventListener(MouseEvent.CLICK, onUnicornSceneAbortButtonClick);
unicornScene.helpButton.addEventListener(MouseEvent.CLICK, onUnicornSceneHelpButtonClick);
deadUnicornScene.okButton.addEventListener(MouseEvent.CLICK, onDeadUnicornSceneOkButtonClick);
cityScene.niceButton.addEventListener(MouseEvent.CLICK, onCitySceneNiceButtonClick);
crackScene.followButton.addEventListener(MouseEvent.CLICK, onCrackSceneFollowButtonClick);
hellScene.repentButton.addEventListener(MouseEvent.CLICK, onHellSceneRepentButtonClick);
hellScene.sinButton.addEventListener(MouseEvent.CLICK, onHellSceneSinButtonClick);
anotherScene.allRightButton.addEventListener(MouseEvent.CLICK, onAnotherSceneAllRightButtonClick);
anotherScene.oneMoreTimeButton.addEventListener(MouseEvent.CLICK, onAnotherSceneOneMoreTimeButtonClick);
endBillScene.againButton.addEventListener(MouseEvent.CLICK, onEndBillSceneAgainButtonClick);
endBillScene.enoughButton.addEventListener(MouseEvent.CLICK, onEndBillSceneEnoughButtonClick);
redeemScene.redemptionButton.addEventListener(MouseEvent.CLICK, onRedeemSceneRedemptionButtonClick);
}
//Event Handlers: what happens onSceneButtonClicks (move between scenes)
function onFutureSceneButton21Click(event:MouseEvent):void
{
addChild(sweetShopScene);
removeChild(futureScene);
}
function onSweetShopSceneCupcakeButtonAClick(event:MouseEvent):void
{
addChild(snailScene);
removeChild(sweetShopScene);
}
function onSweetShopSceneCupcakeButtonBClick(event:MouseEvent):void
{
addChild(magicalScene);
removeChild(sweetShopScene);
}
function onSweetShopSceneCupcakeButtonCClick(event:MouseEvent):void
{
addChild(cityScene);
removeChild(sweetShopScene);
}
function onSnailSceneGameOverButtonClick(event:MouseEvent):void
{
addChild(futureScene);
removeChild(snailScene);
}
function onMagicalSceneSparkleButtonClick(event:MouseEvent):void
{
addChild(unicornScene);
removeChild(magicalScene);
}
function onUnicornSceneAbortButtonClick(event:MouseEvent):void
{
addChild(hellScene);
removeChild(unicornScene);
}
function onUnicornSceneHelpButtonClick(event:MouseEvent):void
{
addChild(deadUnicornScene);
removeChild(unicornScene);
}
function onDeadUnicornSceneOkButtonClick(event:MouseEvent):void
{
addChild(futureScene);
removeChild(deadUnicornScene);
}
function onCitySceneNiceButtonClick(event:MouseEvent):void
{
addChild(crackScene);
removeChild(cityScene);
}
function onCrackSceneFollowButtonClick(event:MouseEvent):void
{
addChild(hellScene);
removeChild(crackScene);
}
function onHellSceneSinButtonClick(event:MouseEvent):void
{
//addChild(partyScene);
removeChild(hellScene);
//want it to go to DollarBillGame
addEventListener(Event.ENTER_FRAME, gameLoop);
partyGameBG = new PartyGameBG();
addChild(partyGameBG); //new
scoreLabel.text = "Tips:";
levelLabel.text = "Level:";
chancesLabel.text ="Boos:"
scoreText.text ="0";
levelText.text ="1";
chancesText.text ="0";
scoreLabel.y = SCOREBOARD_Y;
levelLabel.y = SCOREBOARD_Y;
chancesLabel.y = SCOREBOARD_Y;
scoreText.y = SCOREBOARD_Y;
levelText.y = SCOREBOARD_Y;
chancesText.y = SCOREBOARD_Y;
scoreLabel.x = 5;
scoreText.x = 50;
chancesLabel.x = 105;
chancesText.x = 155;
levelLabel.x = 205;
levelText.x = 260;
addChild(scoreLabel);
addChild(levelLabel);
addChild(chancesLabel);
addChild(scoreText);
addChild(levelText);
addChild(chancesText);
gameState = STATE_INIT;
}
public function gameLoop(e:Event):void
{
switch(gameState)
{
case STATE_INIT :
initGame();
break
case STATE_PLAY:
playGame();
break;
case STATE_END_GAME:
endGame();
break;
}
}
public function initGame():void
{
score = 0;
chances = 0;
player = new Player();
dollarBills = new Array();
level = 1;
levelText.text = level.toString();
addChild(player);
player.y=340;
player.startDrag(true,new flash.geom.Rectangle(0,340,550,340));
gameState = STATE_PLAY;
}
public function playGame():void
{
//player.rotation+=8;
makeDollarBills();
moveDollarBills();
testCollisions();
testForEnd();
}
public function makeDollarBills():void
{
var chance:Number = Math.ceil(Math.random() *100);
var tempDollarBills:MovieClip;
if (chance < 2 + level)
{
tempDollarBills = new DollarBills()
tempDollarBills.speed = -3 - level; //increases speed each level up
tempDollarBills.gotoAndStop(Math.ceil(Math.random()*5)+1);
tempDollarBills.y = -10;
tempDollarBills.x = Math.ceil(Math.random()*515)
addChild(tempDollarBills);
dollarBills.push(tempDollarBills);
}
}
public function moveDollarBills():void
{
var tempDollarBills:MovieClip;
for (var i:int = dollarBills.length-1;i>=0;i--)
{
tempDollarBills = dollarBills[i];
tempDollarBills.y-=tempDollarBills.speed;
tempDollarBills.rotation+=5;
if (tempDollarBills.y > 410)
{
chances++;
chancesText.text = chances.toString();
dollarBills.splice(i,1);
removeChild(tempDollarBills);
}
}
}
public function testCollisions():void
{
//var sound:Sound = new Pop();
var tempDollarBills:MovieClip;
for (var i:int =dollarBills.length-1;i>=0;i--)
{
tempDollarBills = dollarBills[i];
if (tempDollarBills.hitTestObject(player))
{
score++;
scoreText.text = score.toString();
//sound.play();
dollarBills.splice(i,1);
removeChild(tempDollarBills);
}
}
}
public function testForEnd():void
{
if (chances>= 5)
{
gameState = STATE_END_GAME;
}
else if(score > level*20)
{
level ++;
levelText.text = level.toString();
}
}
public function endGame():void
{
for(var i:int = 0; i< dollarBills.length; i++)
{
removeChild(dollarBills[i]);
dollarBills =[];
removeChild(player);
addChild(endBillScene);
removeChild(partyGameBG);
}
}
function onEndBillSceneEnoughButtonClick(event:MouseEvent):void
{
addChild(futureScene);
removeChild(endBillScene);
}
function onEndBillSceneAgainButtonClick(event:MouseEvent):void
{
addChild(hellScene);
removeChild(endBillScene);
}
function onHellSceneRepentButtonClick(event:MouseEvent):void
{
addChild(redeemScene);
removeChild(hellScene);
}
function onRedeemSceneRedemptionButtonClick(event:MouseEvent):void
{
removeChild(redeemScene);
addChild(britneyGame);
var gameScoreFormat:TextFormat = new TextFormat();
gameScoreFormat.font = "Helvetica";
gameScoreFormat.size = 30;
gameScoreFormat.color = 0xFFFFFF;
gameScoreFormat.bold = true;
gameScore = 0;
gameScoreField = new TextField();
gameScoreField.x = 450;
gameScoreField.y = 315;
gameScoreField.width = 80;
gameScoreField.height = 50;
gameScoreField.border = false;
gameScoreField.selectable = false;
gameScoreField.defaultTextFormat = gameScoreFormat;
addChild(gameScoreField);
gameScoreField.text = String(gameScore);
var cardlist:Array = new Array();
for(var i:uint=0; i< boardWidth*boardHeight/2;i++)
{
cardlist.push(i);
cardlist.push(i);
}
cardsLeft = 0;
for(var x:uint=0;x
{
for(var y:uint=0;y
{
trace("x = " + x + " y = " + y);
var c:Card = new Card();
c.stop();
c.x = x*cardHorizontalSpacing + boardOffsetX;
c.y = y*cardVerticalSpacing + boardOffsetY;
var r:uint =Math.floor(Math.random()*cardlist.length);
c.cardface = cardlist[r];
cardlist.splice(r,1);
c.addEventListener(MouseEvent.CLICK,clickCard);
addChild(c);
cardsLeft++;
trace("cardsLeft = " + cardsLeft);
}
}
}
public function clickCard(event:MouseEvent)
{
var thisCard:Card = (event.currentTarget as Card);
if (firstCard == null)
{
firstCard = thisCard;
firstCard.gotoAndStop(thisCard.cardface+2);
}
else if (firstCard == thisCard && secondCard != null)
{
secondCard.gotoAndStop(1);
firstCard = thisCard; // put this card into the firstCard
secondCard = null;//set the second card = null
}
else if(firstCard == thisCard && secondCard == null)
{
trace("stop clicking me, ya idjit!");
}
else if (secondCard == null)
{
secondCard = thisCard; // Place thisCard into secondCard.
secondCard.gotoAndStop(thisCard.cardface+2);
playerGuesses ++;
trace("playerGuesses = " + playerGuesses);
if (firstCard.cardface == secondCard.cardface)
{
removeChild(firstCard);
removeChild(secondCard);
cardsLeft -= 2;
gameScore += 15;
trace("Right - have 15");
trace("gameScore = "+ gameScore);
gameScoreField.text = String(gameScore);
trace("cardsLeft = "+cardsLeft);
if (cardsLeft == 0)
{
trace("Here's the value of gameScore in frame 2: " + gameScore);
MovieClip(root).gameScore = gameScore;
removeChild(britneyGame);
addChild(anotherScene);
}
firstCard = null;
secondCard = null;
}
else
{
gameScore -= 5;
gameScoreField.text = String(gameScore);
trace("Wrong - I took 5");
trace("gameScore = "+ gameScore);
}
}
else
{
firstCard.gotoAndStop(1);
secondCard.gotoAndStop(1);
secondCard = null;
firstCard = thisCard;
firstCard.gotoAndStop(thisCard.cardface+2);
}
}
function onAnotherSceneOneMoreTimeButtonClick(event:MouseEvent):void
{
addChild(redeemScene);
removeChild(anotherScene);
}
function onAnotherSceneAllRightButtonClick(event:MouseEvent):void
{
addChild(futureScene);
removeChild(anotherScene);
}
}
}

No comments:
Post a Comment