Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Chadius/ClimbARope
Browse files Browse the repository at this point in the history
  • Loading branch information
JayArrrgh committed Apr 1, 2012
2 parents 41fc596 + d6f7e2d commit bd20e59
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
Binary file added assets/audio/Victory_1.mp3
Binary file not shown.
33 changes: 19 additions & 14 deletions src/Bird.as
Expand Up @@ -23,6 +23,7 @@ package
public static const FLY_SPEED:Number = 6.0;
public var crashed:Boolean = false;
public var flyToTheRight:Boolean;
public var hasCawed:Boolean;

public function Bird(x:int, y:int)
{
Expand All @@ -31,20 +32,7 @@ package
this.loadGraphic(bird_img, true, true, 64, 64);
this.addAnimation("Fly", [0, 1], 6, true);
this.addAnimation("Crash", [2, 3], 10, false);

switch (Math.floor(FlxG.random() * 3)) {
case 0:
FlxG.play(caw1);
break;
case 1:
FlxG.play(caw2);
break;
case 2:
FlxG.play(caw3);
break;
default:
break;
}
hasCawed = false;

//Determine facing
if (x < 270)
Expand Down Expand Up @@ -78,6 +66,23 @@ package
if (this.finished)
this.kill();
}

if (!hasCawed) {
hasCawed = true;
switch (Math.floor(FlxG.random() * 3)) {
case 0:
FlxG.play(caw1);
break;
case 1:
FlxG.play(caw2);
break;
case 2:
FlxG.play(caw3);
break;
default:
break;
}
}
super.update();
}

Expand Down
9 changes: 9 additions & 0 deletions src/Level.as
Expand Up @@ -19,6 +19,7 @@ package
public var events:EventList; //refers to all timed and positionally-cued events: enemy and projectile spawns, etc.
public var EnemyProjectiles:FlxGroup; //refers to all player and enemy projectiles
public var levelComplete:Boolean; //true if and only if player reaches the endpoint
public var victorySoundHasPlayed:Boolean;//true once the victory sound has played
public var endpoint:int; //the y-value the player needs to reach in order to complete the level

public var testTextField:FlxText;
Expand All @@ -33,6 +34,8 @@ package
public var resetTimerElapsed:Number; //the total time spent waiting for a reset

[Embed (source = "../assets/backgroundDay.png")] private var background_day_img:Class;
[Embed (source = "../assets/audio/Victory_1.mp3")] private var victorySound:Class;

public var background:FlxSprite; //Background image.

public var isVictoryLevel:Boolean;
Expand All @@ -44,6 +47,7 @@ package
events = theEvents;
testTextField = new FlxText(0, 0, 100, i.toString());
levelComplete = false;
victorySoundHasPlayed = false;
endpoint = 10;
rope = new Rope(270, 0);
player = thePlayer;
Expand Down Expand Up @@ -100,6 +104,11 @@ package
//Reset the level after waiting long enough.
if (resetTimerCountdown == true || isVictoryLevel == true)
{

if (!victorySoundHasPlayed) {
FlxG.play(victorySound);
victorySoundHasPlayed = true;
}
resetTimerElapsed += FlxG.elapsed;
if (resetTimerElapsed > resetTimerWait)
FlxG.switchState(new MenuState);
Expand Down

0 comments on commit bd20e59

Please sign in to comment.