diff --git a/Arcade/FlxInvaders/assets/alien_die0.wav b/Arcade/FlxInvaders/assets/alien_die0.wav new file mode 100644 index 000000000..d614140e5 Binary files /dev/null and b/Arcade/FlxInvaders/assets/alien_die0.wav differ diff --git a/Arcade/FlxInvaders/assets/alien_die1.wav b/Arcade/FlxInvaders/assets/alien_die1.wav new file mode 100644 index 000000000..13c8c9f3e Binary files /dev/null and b/Arcade/FlxInvaders/assets/alien_die1.wav differ diff --git a/Arcade/FlxInvaders/assets/lose.wav b/Arcade/FlxInvaders/assets/lose.wav new file mode 100644 index 000000000..59858c5a2 Binary files /dev/null and b/Arcade/FlxInvaders/assets/lose.wav differ diff --git a/Arcade/FlxInvaders/assets/player_shoot.wav b/Arcade/FlxInvaders/assets/player_shoot.wav new file mode 100644 index 000000000..affa8bf5a Binary files /dev/null and b/Arcade/FlxInvaders/assets/player_shoot.wav differ diff --git a/Arcade/FlxInvaders/assets/theme.ogg b/Arcade/FlxInvaders/assets/theme.ogg new file mode 100644 index 000000000..8626c0207 Binary files /dev/null and b/Arcade/FlxInvaders/assets/theme.ogg differ diff --git a/Arcade/FlxInvaders/assets/wall_break.wav b/Arcade/FlxInvaders/assets/wall_break.wav new file mode 100644 index 000000000..14552b2ce Binary files /dev/null and b/Arcade/FlxInvaders/assets/wall_break.wav differ diff --git a/Arcade/FlxInvaders/source/Alien.hx b/Arcade/FlxInvaders/source/Alien.hx index b44917a13..b82aa7bce 100644 --- a/Arcade/FlxInvaders/source/Alien.hx +++ b/Arcade/FlxInvaders/source/Alien.hx @@ -47,6 +47,12 @@ class Alien extends FlxSprite velocity.x = 10; } + override function kill() { + var snd:String = FlxG.random.getObject(["assets/alien_die0.wav", "assets/alien_die1.wav"]); + FlxG.sound.play(snd, 0.9); + super.kill(); + } + /** * Basic game loop is BACK y'all */ diff --git a/Arcade/FlxInvaders/source/PlayState.hx b/Arcade/FlxInvaders/source/PlayState.hx index 31a81eabc..46c17e657 100644 --- a/Arcade/FlxInvaders/source/PlayState.hx +++ b/Arcade/FlxInvaders/source/PlayState.hx @@ -1,5 +1,6 @@ package; +import flixel.sound.FlxSound; import flixel.FlxG; import flixel.FlxObject; import flixel.FlxSprite; @@ -60,9 +61,17 @@ class PlayState extends FlxState * Inside this function we will create and orient all the important game objects. */ override public function create():Void - { + { + if (FlxG.sound.music == null) + FlxG.sound.playMusic("assets/theme.ogg"); + FlxG.mouse.visible = false; + if (statusMessage == "YOU LOST") + { + FlxG.sound.play("assets/lose.wav", 0.9); + } + // First we will instantiate the bullets you fire at your enemies. var numPlayerBullets:Int = 8; // Initializing the array is very important and easy to forget! @@ -187,6 +196,8 @@ class PlayState extends FlxState // Player died, so set our label to YOU LOST statusMessage = "YOU LOST"; FlxG.resetState(); + + } else if (_aliens.getFirstExisting() == null) { @@ -201,6 +212,8 @@ class PlayState extends FlxState */ function stuffHitStuff(Object1:FlxObject, Object2:FlxObject):Void { + var wallSound:FlxSound = FlxG.sound.play("assets/wall_break.wav"); + wallSound.pitch = FlxG.random.float(0.9, 1.1); Object1.kill(); Object2.kill(); } diff --git a/Arcade/FlxInvaders/source/PlayerShip.hx b/Arcade/FlxInvaders/source/PlayerShip.hx index 5ed7c7d86..cbb04c4f4 100644 --- a/Arcade/FlxInvaders/source/PlayerShip.hx +++ b/Arcade/FlxInvaders/source/PlayerShip.hx @@ -1,5 +1,6 @@ package; +import flixel.sound.FlxSound; import flixel.FlxG; import flixel.FlxSprite; @@ -62,6 +63,9 @@ class PlayerShip extends FlxSprite // space bar was just pressed (no autofire in space invaders you guys) if (FlxG.keys.justPressed.SPACE) { + // Play a sound effect when the player shoots with slight random pitch + var shootSound:FlxSound = FlxG.sound.play("assets/player_shoot.wav", 0.5); + shootSound.pitch = FlxG.random.float(0.9, 1.1); // Space bar was pressed! FIRE A BULLET var playState:PlayState = cast FlxG.state; var bullet:FlxSprite = playState.playerBullets.recycle();