diff --git a/source/Character.hx b/source/Character.hx index 04a6dce24..356eb1639 100644 --- a/source/Character.hx +++ b/source/Character.hx @@ -73,6 +73,14 @@ class Character extends FlxSprite loadOffsetFile(curCharacter); playAnim('danceRight'); + case 'gf-tankmen': + frames = Paths.getSparrowAtlas('characters/gfTankmen'); + animation.addByIndices('sad', 'GF Crying at Gunpoint', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], "", 24, true); + animation.addByIndices('danceLeft', 'GF Dancing at Gunpoint', [30, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], "", 24, false); + animation.addByIndices('danceRight', 'GF Dancing at Gunpoint', [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29], "", 24, false); + + loadOffsetFile('gf'); + playAnim('danceRight'); case 'bf-holding-gf': frames = Paths.getSparrowAtlas('characters/bfAndGF'); @@ -449,25 +457,31 @@ class Character extends FlxSprite if (isPlayer) { - quickAnimAdd('singLEFT', 'Tankman Note Left0'); - quickAnimAdd('singRIGHT', 'Tankman Right Note0'); + quickAnimAdd('singLEFT', 'Tankman Note Left '); + quickAnimAdd('singRIGHT', 'Tankman Right Note '); quickAnimAdd('singLEFTmiss', 'Tankman Note Left MISS'); quickAnimAdd('singRIGHTmiss', 'Tankman Right Note MISS'); } else { // Need to be flipped! REDO THIS LATER - quickAnimAdd('singLEFT', 'Tankman Right Note0'); - quickAnimAdd('singRIGHT', 'Tankman Note Left0'); + quickAnimAdd('singLEFT', 'Tankman Right Note '); + quickAnimAdd('singRIGHT', 'Tankman Note Left '); quickAnimAdd('singLEFTmiss', 'Tankman Right Note MISS'); quickAnimAdd('singRIGHTmiss', 'Tankman Note Left MISS'); } - quickAnimAdd('singUP', 'Tankman UP note0'); - quickAnimAdd('singDOWN', 'Tankman DOWN note0'); + quickAnimAdd('singUP', 'Tankman UP note '); + quickAnimAdd('singDOWN', 'Tankman DOWN note '); quickAnimAdd('singUPmiss', 'Tankman UP note MISS'); quickAnimAdd('singDOWNmiss', 'Tankman DOWN note MISS'); + // PRETTY GOOD tankman + // TANKMAN UGH instanc + + quickAnimAdd('singDOWN-alt', 'PRETTY GOOD'); + quickAnimAdd('singUP-alt', 'TANKMAN UGH'); + loadOffsetFile(curCharacter); playAnim('idle'); @@ -614,7 +628,7 @@ class Character extends FlxSprite { switch (curCharacter) { - case 'gf' | 'gf-christmas' | 'gf-car' | 'gf-pixel': + case 'gf' | 'gf-christmas' | 'gf-car' | 'gf-pixel' | 'gf-tankmen': if (!animation.curAnim.name.startsWith('hair')) { danced = !danced; @@ -629,6 +643,10 @@ class Character extends FlxSprite // lol weed // playAnim('shoot' + FlxG.random.int(1, 4), true); + case 'tankman': + if (!animation.curAnim.name.endsWith('DOWN-alt')) + playAnim('idle'); + case 'spooky': danced = !danced; diff --git a/source/ChartingState.hx b/source/ChartingState.hx index 49ab32380..d36521a6b 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -478,6 +478,9 @@ class ChartingState extends MusicBeatState strumLine.y = getYfromStrum((Conductor.songPosition - sectionStartTime()) % (Conductor.stepCrochet * _song.notes[curSection].lengthInSteps)); + if (FlxG.keys.justPressed.X) + toggleAltAnimNote(); + if (curBeat % 4 == 0 && curStep >= 16 * (curSection + 1)) { trace(curStep); @@ -686,6 +689,21 @@ class ChartingState extends MusicBeatState updateGrid(); } + function toggleAltAnimNote():Void + { + if (curSelectedNote != null) + { + if (curSelectedNote[3] != null) + { + trace('ALT NOTE SHIT'); + curSelectedNote[3] = !curSelectedNote[3]; + trace(curSelectedNote[3]); + } + else + curSelectedNote[3] = true; + } + } + function recalculateSteps():Int { var lastChange:BPMChangeEvent = { @@ -945,14 +963,15 @@ class ChartingState extends MusicBeatState var noteStrum = getStrumTime(dummyArrow.y) + sectionStartTime(); var noteData = Math.floor(FlxG.mouse.x / GRID_SIZE); var noteSus = 0; + var noteAlt = false; - _song.notes[curSection].sectionNotes.push([noteStrum, noteData, noteSus]); + _song.notes[curSection].sectionNotes.push([noteStrum, noteData, noteSus, noteAlt]); curSelectedNote = _song.notes[curSection].sectionNotes[_song.notes[curSection].sectionNotes.length - 1]; if (FlxG.keys.pressed.CONTROL) { - _song.notes[curSection].sectionNotes.push([noteStrum, (noteData + 4) % 8, noteSus]); + _song.notes[curSection].sectionNotes.push([noteStrum, (noteData + 4) % 8, noteSus, noteAlt]); } trace(noteStrum); diff --git a/source/CutsceneCharacter.hx b/source/CutsceneCharacter.hx index 17f5e391b..c85d53b92 100644 --- a/source/CutsceneCharacter.hx +++ b/source/CutsceneCharacter.hx @@ -58,6 +58,7 @@ class CutsceneCharacter extends FlxTypedGroup { cutScene.kill(); cutScene.destroy(); + cutScene = null; if (daNum + 1 < arrayLMFAOOOO.length) createCutscene(daNum + 1); diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx index a64893bb2..f43334ffc 100644 --- a/source/FreeplayState.hx +++ b/source/FreeplayState.hx @@ -29,7 +29,16 @@ class FreeplayState extends MusicBeatState var lerpScore:Int = 0; var intendedScore:Int = 0; - var coolColors:Array = [0xff223344, 0xff123456, 0xFFFFFFFF, 0xFFADAD]; + var coolColors:Array = [ + 0xff9271fd, + 0xff9271fd, + 0xff223344, + 0xFF941653, + 0xFFfc96d7, + 0xFFa0d1ff, + 0xffff78bf, + 0xfff6b604 + ]; private var grpSongs:FlxTypedGroup; private var curPlaying:Bool = false; @@ -196,7 +205,7 @@ class FreeplayState extends MusicBeatState } lerpScore = Math.floor(FlxMath.lerp(lerpScore, intendedScore, 0.4)); - bg.color = FlxColor.interpolate(bg.color, coolColors[curSelected % coolColors.length], 0.045); + bg.color = FlxColor.interpolate(bg.color, coolColors[songs[curSelected].week % coolColors.length], 0.045); if (Math.abs(lerpScore - intendedScore) <= 10) lerpScore = intendedScore; diff --git a/source/MainMenuState.hx b/source/MainMenuState.hx index 88174cacc..6e8fb60ef 100644 --- a/source/MainMenuState.hx +++ b/source/MainMenuState.hx @@ -96,8 +96,11 @@ class MainMenuState extends MusicBeatState // addMenuItem('options', function () startExitState(new OptionMenu())); #if CAN_OPEN_LINKS var hasPopupBlocker = #if web true #else false #end; - menuItems.createItem('kickstarter', selectDonate, hasPopupBlocker); - // menuItems.createItem('donate', selectDonate, hasPopupBlocker); + + if (VideoState.seenVideo) + menuItems.createItem('kickstarter', selectDonate, hasPopupBlocker); + else + menuItems.createItem('donate', selectDonate, hasPopupBlocker); #end menuItems.createItem('options', function() startExitState(new OptionsState())); // #if newgrounds diff --git a/source/Note.hx b/source/Note.hx index 6e6eb127d..325529a2a 100644 --- a/source/Note.hx +++ b/source/Note.hx @@ -25,8 +25,12 @@ class Note extends FlxSprite public var tooLate:Bool = false; public var wasGoodHit:Bool = false; public var prevNote:Note; + private var willMiss:Bool = false; + public var altNote:Bool = false; + public var invisNote:Bool = false; + public var sustainLength:Float = 0; public var isSustainNote:Bool = false; @@ -210,11 +214,11 @@ class Note extends FlxSprite else { if (strumTime > Conductor.songPosition - Conductor.safeZoneOffset) - { // The * 0.5 is so that it's easier to hit them too late, instead of too early + { // The * 0.5 is so that it's easier to hit them too late, instead of too early if (strumTime < Conductor.songPosition + (Conductor.safeZoneOffset * 0.5)) canBeHit = true; } - else + else { canBeHit = true; willMiss = true; diff --git a/source/NoteSplash.hx b/source/NoteSplash.hx index 0b6295bba..59e5328c2 100644 --- a/source/NoteSplash.hx +++ b/source/NoteSplash.hx @@ -21,13 +21,21 @@ class NoteSplash extends FlxSprite animation.addByPrefix('note0-1', 'note impact 2 purple', 24, false); animation.addByPrefix('note3-1', 'note impact 2 red', 24, false); - animation.play('note' + noteData + '-' + FlxG.random.int(0, 1)); + setupNoteSplash(x, y, noteData); + + // alpha = 0.75; + } + + public function setupNoteSplash(x:Float, y:Float, noteData:Int = 0) + { + setPosition(x, y); + alpha = 0.6; + + animation.play('note' + noteData + '-' + FlxG.random.int(0, 1), true); animation.curAnim.frameRate += FlxG.random.int(-2, 2); updateHitbox(); offset.set(width * 0.3, height * 0.3); - - alpha = 0.75; } override function update(elapsed:Float) diff --git a/source/PlayState.hx b/source/PlayState.hx index 22e3c5922..25a4ffcae 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -133,6 +133,8 @@ class PlayState extends MusicBeatState var songScore:Int = 0; var scoreTxt:FlxText; + var grpNoteSplashes:FlxTypedGroup; + public static var campaignScore:Int = 0; var defaultCamZoom:Float = 1.05; @@ -170,8 +172,11 @@ class PlayState extends MusicBeatState FlxG.cameras.add(camHUD, false); // fake notesplash cache type deal so that it loads in the graphic? + + grpNoteSplashes = new FlxTypedGroup(); + var noteSplash:NoteSplash = new NoteSplash(100, 100, 0); - add(noteSplash); + grpNoteSplashes.add(noteSplash); noteSplash.alpha = 0.1; persistentUpdate = true; @@ -543,14 +548,14 @@ class PlayState extends MusicBeatState tankWatchtower = new BGSprite('tankWatchtower', 100, 50, 0.5, 0.5, ['watchtower gradient color']); add(tankWatchtower); + tankmanRun = new FlxTypedGroup(); + add(tankmanRun); + var tankGround:BGSprite = new BGSprite('tankGround', -420, -150); tankGround.setGraphicSize(Std.int(tankGround.width * 1.15)); tankGround.updateHitbox(); add(tankGround); - tankmanRun = new FlxTypedGroup(); - add(tankmanRun); - // smokeLeft.screenCenter(); var fgTank0:BGSprite = new BGSprite('tank0', -500, 650, 1.7, 1.5, ['fg']); @@ -609,6 +614,8 @@ class PlayState extends MusicBeatState gfVersion = 'gf-pixel'; case 'schoolEvil': gfVersion = 'gf-pixel'; + case 'tank': + gfVersion = 'gf-tankmen'; } if (SONG.song.toLowerCase() == 'stress') @@ -625,10 +632,12 @@ class PlayState extends MusicBeatState for (i in 0...TankmenBG.animationNotes.length) { - if (FlxG.random.bool(50)) + if (FlxG.random.bool(16)) { - var tankman:TankmenBG = new TankmenBG(500, 200 + FlxG.random.int(0, 150), TankmenBG.animationNotes[i][1] < 2); + var tankman:TankmenBG = tankmanRun.recycle(TankmenBG); + // new TankmenBG(500, 200 + FlxG.random.int(50, 100), TankmenBG.animationNotes[i][1] < 2); tankman.strumTime = TankmenBG.animationNotes[i][0]; + tankman.resetShit(500, 200 + FlxG.random.int(50, 100), TankmenBG.animationNotes[i][1] < 2); tankmanRun.add(tankman); } } @@ -730,7 +739,7 @@ class PlayState extends MusicBeatState if (gfVersion != 'pico-speaker') { - gf.x -= 80; + gf.x -= 170; gf.y -= 75; } } @@ -772,6 +781,8 @@ class PlayState extends MusicBeatState strumLineNotes = new FlxTypedGroup(); add(strumLineNotes); + add(grpNoteSplashes); + playerStrums = new FlxTypedGroup(); // startCountdown(); @@ -829,6 +840,7 @@ class PlayState extends MusicBeatState iconP2.y = healthBar.y - (iconP2.height / 2); add(iconP2); + grpNoteSplashes.cameras = [camHUD]; strumLineNotes.cameras = [camHUD]; notes.cameras = [camHUD]; healthBar.cameras = [camHUD]; @@ -903,8 +915,8 @@ class PlayState extends MusicBeatState switch (curSong.toLowerCase()) { // REMOVE THIS LATER - case 'stress': - stressIntro(); + // case 'stress': + // stressIntro(); default: startCountdown(); @@ -920,7 +932,7 @@ class PlayState extends MusicBeatState FlxG.sound.music.fadeIn(5, 0, 0.5); dad.visible = false; - var tankCutscene:FlxSprite = new FlxSprite(-20, 320); + var tankCutscene:TankCutscene = new TankCutscene(-20, 320); tankCutscene.frames = Paths.getSparrowAtlas('cutsceneStuff/tankTalkSong1'); tankCutscene.animation.addByPrefix('wellWell', 'TANK TALK 1 P1', 24, false); tankCutscene.animation.addByPrefix('killYou', 'TANK TALK 1 P2', 24, false); @@ -933,7 +945,7 @@ class PlayState extends MusicBeatState FlxG.camera.zoom *= 1.2; camFollow.y += 100; - FlxG.sound.play(Paths.sound('wellWellWell')); + tankCutscene.startSyncAudio = FlxG.sound.load(Paths.sound('wellWellWell')); new FlxTimer().start(3, function(tmr:FlxTimer) { @@ -990,14 +1002,14 @@ class PlayState extends MusicBeatState FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom * 1.3}, 4, {ease: FlxEase.quadInOut}); dad.visible = false; - var tankCutscene:FlxSprite = new FlxSprite(20, 320); + var tankCutscene:TankCutscene = new TankCutscene(20, 320); tankCutscene.frames = Paths.getSparrowAtlas('cutsceneStuff/tankTalkSong2'); tankCutscene.animation.addByPrefix('tankyguy', 'TANK TALK 2', 24, false); tankCutscene.animation.play('tankyguy'); tankCutscene.antialiasing = true; gfCutsceneLayer.add(tankCutscene); // add(); - FlxG.sound.play(Paths.sound('tankSong2')); + tankCutscene.startSyncAudio = FlxG.sound.load(Paths.sound('tankSong2')); new FlxTimer().start(4.1, function(ugly:FlxTimer) { @@ -1039,13 +1051,18 @@ class PlayState extends MusicBeatState // for story mode shit camFollow.setPosition(camPos.x, camPos.y); + var dummyLoaderShit:FlxGroup = new FlxGroup(); + + add(dummyLoaderShit); + for (i in 0...7) { var dummyLoader:FlxSprite = new FlxSprite(); dummyLoader.loadGraphic(Paths.image('cutsceneStuff/gfHoldup-' + i)); - add(dummyLoader); + dummyLoaderShit.add(dummyLoader); dummyLoader.alpha = 0.01; dummyLoader.y = FlxG.height - 20; + // dummyLoader.drawFrame(true); } dad.visible = false; @@ -1093,13 +1110,12 @@ class PlayState extends MusicBeatState add(bfCatchGf); bfCatchGf.visible = false; - var cutsceneSound:FlxSound = new FlxSound(); - if (PreferencesMenu.getPref('censor-naughty')) - cutsceneSound.loadEmbedded(Paths.sound('stressCutscene')); + tankCutscene.startSyncAudio = FlxG.sound.play(Paths.sound('stressCutscene')); else { - cutsceneSound.loadEmbedded(Paths.sound('song3censor')); + tankCutscene.startSyncAudio = FlxG.sound.play(Paths.sound('song3censor')); + // cutsceneSound.loadEmbedded(Paths.sound('song3censor')); var censor:FlxSprite = new FlxSprite(); censor.frames = Paths.getSparrowAtlas('cutsceneStuff/censor'); @@ -1156,7 +1172,7 @@ class PlayState extends MusicBeatState // new FlxTimer().start(0.01, function(tmr) cutsceneSound.play()); // cutsceneSound.play(); // cutsceneSound.play(); - tankCutscene.startSyncAudio = cutsceneSound; + // tankCutscene.startSyncAudio = cutsceneSound; // tankCutscene.animation.curAnim.curFrame FlxG.camera.zoom = defaultCamZoom * 1.15; @@ -1242,6 +1258,10 @@ class PlayState extends MusicBeatState dad.visible = true; bfTankCutsceneLayer.remove(alsoTankCutscene); startCountdown(); + remove(dummyLoaderShit); + dummyLoaderShit.destroy(); + dummyLoaderShit = null; + gfCutsceneLayer.remove(cutsceneShit); }); }); @@ -1250,7 +1270,7 @@ class PlayState extends MusicBeatState function initDiscord():Void { #if discord_rpc - storyDifficultyText = CoolUtil.difficultyString(); + storyDifficultyText = difficultyString(); iconRPC = SONG.player2; // To avoid having duplicate images in Discord assets @@ -1488,7 +1508,7 @@ class PlayState extends MusicBeatState lastReportedPlayheadPosition = 0; if (!paused) - FlxG.sound.playMusic(Paths.inst(PlayState.SONG.song), 1, false); + FlxG.sound.playMusic(Paths.inst(SONG.song), 1, false); FlxG.sound.music.onComplete = endSong; vocals.play(); @@ -1513,7 +1533,7 @@ class PlayState extends MusicBeatState curSong = songData.song; if (SONG.needsVoices) - vocals = new FlxSound().loadEmbedded(Paths.voices(PlayState.SONG.song)); + vocals = new FlxSound().loadEmbedded(Paths.voices(SONG.song)); else vocals = new FlxSound(); @@ -1558,6 +1578,7 @@ class PlayState extends MusicBeatState var swagNote:Note = new Note(daStrumTime, daNoteData, oldNote); swagNote.sustainLength = songNotes[2]; + swagNote.altNote = songNotes[3]; swagNote.scrollFactor.set(0, 0); var susLength:Float = swagNote.sustainLength; @@ -1958,9 +1979,9 @@ class PlayState extends MusicBeatState FlxG.switchState(new AnimationDebug(SONG.player2)); #end - if (generatedMusic && PlayState.SONG.notes[Std.int(curStep / 16)] != null) + if (generatedMusic && SONG.notes[Std.int(curStep / 16)] != null) { - cameraRightSide = PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection; + cameraRightSide = SONG.notes[Std.int(curStep / 16)].mustHitSection; cameraMovement(); } @@ -2033,6 +2054,8 @@ class PlayState extends MusicBeatState vocals.stop(); FlxG.sound.music.stop(); + // unloadAssets(); + deathCounter += 1; openSubState(new GameOverSubstate(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y)); @@ -2124,6 +2147,9 @@ class PlayState extends MusicBeatState altAnim = '-alt'; } + if (daNote.altNote) + altAnim = '-alt'; + switch (Math.abs(daNote.noteData)) { case 0: @@ -2147,7 +2173,7 @@ class PlayState extends MusicBeatState } // WIP interpolation shit? Need to fix the pause issue - // daNote.y = (strumLine.y - (songTime - daNote.strumTime) * (0.45 * PlayState.SONG.speed)); + // daNote.y = (strumLine.y - (songTime - daNote.strumTime) * (0.45 * SONG.speed)); var noteMiss:Bool = daNote.y < -daNote.height; @@ -2206,7 +2232,13 @@ class PlayState extends MusicBeatState transIn = FlxTransitionableState.defaultTransIn; transOut = FlxTransitionableState.defaultTransOut; - FlxG.switchState(new StoryMenuState()); + switch (PlayState.storyWeek) + { + case 7: + FlxG.switchState(new VideoState()); + default: + FlxG.switchState(new StoryMenuState()); + } // if () StoryMenuState.weekUnlocked[Std.int(Math.min(storyWeek + 1, StoryMenuState.weekUnlocked.length - 1))] = true; @@ -2231,7 +2263,7 @@ class PlayState extends MusicBeatState difficulty = '-hard'; trace('LOADING NEXT SONG'); - trace(PlayState.storyPlaylist[0].toLowerCase() + difficulty); + trace(storyPlaylist[0].toLowerCase() + difficulty); if (SONG.song.toLowerCase() == 'eggnog') { @@ -2248,7 +2280,7 @@ class PlayState extends MusicBeatState FlxTransitionableState.skipNextTransOut = true; prevCamFollow = camFollow; - PlayState.SONG = Song.loadFromJson(PlayState.storyPlaylist[0].toLowerCase() + difficulty, PlayState.storyPlaylist[0]); + SONG = Song.loadFromJson(storyPlaylist[0].toLowerCase() + difficulty, storyPlaylist[0]); FlxG.sound.music.stop(); LoadingState.loadAndSwitchState(new PlayState()); @@ -2257,6 +2289,7 @@ class PlayState extends MusicBeatState else { trace('WENT BACK TO FREEPLAY??'); + // unloadAssets(); FlxG.switchState(new FreeplayState()); } } @@ -2304,13 +2337,15 @@ class PlayState extends MusicBeatState if (isSick) { - var noteSplash:NoteSplash = new NoteSplash(daNote.x, daNote.y, daNote.noteData); - add(noteSplash); - - noteSplash.cameras = [camHUD]; + var noteSplash:NoteSplash = grpNoteSplashes.recycle(NoteSplash); + noteSplash.setupNoteSplash(daNote.x, daNote.y, daNote.noteData); + // new NoteSplash(daNote.x, daNote.y, daNote.noteData); + grpNoteSplashes.add(noteSplash); } - songScore += score; + // Only add the score if you're not on practice mode + if (!practiceMode) + songScore += score; /* if (combo > 60) daRating = 'sick'; @@ -2619,7 +2654,8 @@ class PlayState extends MusicBeatState } combo = 0; - songScore -= 10; + if (!practiceMode) + songScore -= 10; FlxG.sound.play(Paths.soundRandom('missnote', 1, 3), FlxG.random.float(0.1, 0.2)); // FlxG.sound.play(Paths.sound('missnote1'), 1, false); diff --git a/source/TankmenBG.hx b/source/TankmenBG.hx index de5bb66c7..37c56f061 100644 --- a/source/TankmenBG.hx +++ b/source/TankmenBG.hx @@ -28,9 +28,17 @@ class TankmenBG extends FlxSprite animation.play('run'); animation.curAnim.curFrame = FlxG.random.int(0, animation.curAnim.numFrames - 1); + updateHitbox(); + + setGraphicSize(Std.int(width * 0.8)); + updateHitbox(); + } + + public function resetShit(x:Float, y:Float, isGoingRight:Bool) + { + setPosition(x, y); goingRight = isGoingRight; endingOffset = FlxG.random.float(50, 200); - tankSpeed = FlxG.random.float(0.6, 1); if (goingRight) diff --git a/source/TitleState.hx b/source/TitleState.hx index f138521c0..5ec71ff27 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -109,29 +109,35 @@ class TitleState extends MusicBeatState FlxG.switchState(new FreeplayState()); #elseif CHARTING FlxG.switchState(new ChartingState()); - #elseif web - if (!initialized) - { - video = new Video(); - FlxG.stage.addChild(video); + /* + #elseif web - var netConnection = new NetConnection(); - netConnection.connect(null); - netStream = new NetStream(netConnection); - netStream.client = {onMetaData: client_onMetaData}; - netStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, netStream_onAsyncError); - netConnection.addEventListener(NetStatusEvent.NET_STATUS, netConnection_onNetStatus); - // netStream.addEventListener(NetStatusEvent.NET_STATUS) // netStream.play(Paths.file('music/kickstarterTrailer.mp4')); + if (!initialized) + { - overlay = new Sprite(); - overlay.graphics.beginFill(0, 0.5); - overlay.graphics.drawRect(0, 0, 1280, 720); - overlay.addEventListener(MouseEvent.MOUSE_DOWN, overlay_onMouseDown); + video = new Video(); + FlxG.stage.addChild(video); - overlay.buttonMode = true; - FlxG.stage.addChild(overlay); - } + var netConnection = new NetConnection(); + netConnection.connect(null); + + netStream = new NetStream(netConnection); + netStream.client = {onMetaData: client_onMetaData}; + netStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, netStream_onAsyncError); + netConnection.addEventListener(NetStatusEvent.NET_STATUS, netConnection_onNetStatus); + // netStream.addEventListener(NetStatusEvent.NET_STATUS) // netStream.play(Paths.file('music/kickstarterTrailer.mp4')); + + overlay = new Sprite(); + overlay.graphics.beginFill(0, 0.5); + overlay.graphics.drawRect(0, 0, 1280, 720); + overlay.addEventListener(MouseEvent.MOUSE_DOWN, overlay_onMouseDown); + + overlay.buttonMode = true; + // FlxG.stage.addChild(overlay); + + } + */ // netConnection.addEventListener(MouseEvent.MOUSE_DOWN, overlay_onMouseDown); #else @@ -157,6 +163,7 @@ class TitleState extends MusicBeatState video.width = video.videoWidth; video.height = video.videoHeight; + // video. } private function netStream_onAsyncError(event:AsyncErrorEvent):Void @@ -168,8 +175,8 @@ class TitleState extends MusicBeatState { if (event.info.code == 'NetStream.Play.Complete') { - netStream.dispose(); - FlxG.stage.removeChild(video); + // netStream.dispose(); + // FlxG.stage.removeChild(video); startIntro(); } @@ -179,7 +186,10 @@ class TitleState extends MusicBeatState private function overlay_onMouseDown(event:MouseEvent):Void { - netStream.play(Paths.file('music/kickstarterTrailer.mp4')); + netStream.soundTransform.volume = 0.2; + netStream.soundTransform.pan = -1; + // netStream.play(Paths.file('music/kickstarterTrailer.mp4')); + FlxG.stage.removeChild(overlay); } @@ -306,6 +316,9 @@ class TitleState extends MusicBeatState else initialized = true; + if (FlxG.sound.music != null) + FlxG.sound.music.onComplete = function() FlxG.switchState(new VideoState()); + // credGroup.add(credTextShit); } @@ -378,6 +391,9 @@ class TitleState extends MusicBeatState if (pressedEnter && !transitioning && skippedIntro) { + if (FlxG.sound.music != null) + FlxG.sound.music.onComplete = null; + // netStream.play(Paths.file('music/kickstarterTrailer.mp4')); NGio.unlockMedal(60960); // If it's Friday according to da clock @@ -423,16 +439,18 @@ class TitleState extends MusicBeatState { skipIntro(); } + /* + #if web + if (!initialized && controls.ACCEPT) + { + // netStream.dispose(); + // FlxG.stage.removeChild(video); - #if web - if (!initialized && controls.ACCEPT) - { - netStream.dispose(); - FlxG.stage.removeChild(video); - - startIntro(); - } - #end + startIntro(); + skipIntro(); + } + #end + */ // if (FlxG.keys.justPressed.SPACE) // swagShader.hasOutline = !swagShader.hasOutline; diff --git a/source/VideoState.hx b/source/VideoState.hx new file mode 100644 index 000000000..6fa93428c --- /dev/null +++ b/source/VideoState.hx @@ -0,0 +1,99 @@ +package; + +import flixel.FlxG; +import openfl.display.Sprite; +import openfl.events.AsyncErrorEvent; +import openfl.events.MouseEvent; +import openfl.events.NetStatusEvent; +import openfl.media.Video; +import openfl.net.NetConnection; +import openfl.net.NetStream; + +class VideoState extends MusicBeatState +{ + var video:Video; + var netStream:NetStream; + private var overlay:Sprite; + + public static var seenVideo:Bool = false; + + override function create() + { + super.create(); + + seenVideo = true; + + if (FlxG.sound.music != null) + FlxG.sound.music.stop(); + + video = new Video(); + FlxG.addChildBelowMouse(video); + + var netConnection = new NetConnection(); + netConnection.connect(null); + + netStream = new NetStream(netConnection); + netStream.client = {onMetaData: client_onMetaData}; + netStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, netStream_onAsyncError); + netConnection.addEventListener(NetStatusEvent.NET_STATUS, netConnection_onNetStatus); + // netStream.addEventListener(NetStatusEvent.NET_STATUS); + netStream.play(Paths.file('music/kickstarterTrailer.mp4')); + + overlay = new Sprite(); + overlay.graphics.beginFill(0, 0.5); + overlay.graphics.drawRect(0, 0, 1280, 720); + overlay.addEventListener(MouseEvent.MOUSE_DOWN, overlay_onMouseDown); + + overlay.buttonMode = true; + // FlxG.stage.addChild(overlay); + } + + override function update(elapsed:Float) + { + if (controls.ACCEPT) + finishVid(); + + super.update(elapsed); + } + + function finishVid():Void + { + netStream.dispose(); + FlxG.removeChild(video); + + FlxG.switchState(new TitleState()); + } + + private function client_onMetaData(metaData:Dynamic) + { + video.attachNetStream(netStream); + + video.width = video.videoWidth; + video.height = video.videoHeight; + // video. + } + + private function netStream_onAsyncError(event:AsyncErrorEvent):Void + { + trace("Error loading video"); + } + + private function netConnection_onNetStatus(event:NetStatusEvent):Void + { + if (event.info.code == 'NetStream.Play.Complete') + { + finishVid(); + } + + trace(event.toString()); + } + + private function overlay_onMouseDown(event:MouseEvent):Void + { + netStream.soundTransform.volume = 0.2; + netStream.soundTransform.pan = -1; + // netStream.play(Paths.file('music/kickstarterTrailer.mp4')); + + FlxG.stage.removeChild(overlay); + } +}