From 3db5184b71995827731fbec1f49171a56e366252 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 6 Apr 2021 18:12:31 -0400 Subject: [PATCH] cutscene character work in progress --- source/CutsceneAnimTestState.hx | 96 +++++++++++++++++++++++++++++++++ source/CutsceneCharacter.hx | 65 ++++++++++++++++++++++ source/TitleState.hx | 9 ++-- 3 files changed, 166 insertions(+), 4 deletions(-) create mode 100644 source/CutsceneAnimTestState.hx create mode 100644 source/CutsceneCharacter.hx diff --git a/source/CutsceneAnimTestState.hx b/source/CutsceneAnimTestState.hx new file mode 100644 index 000000000..8057ecc44 --- /dev/null +++ b/source/CutsceneAnimTestState.hx @@ -0,0 +1,96 @@ +package; + +import flixel.FlxG; +import flixel.FlxSprite; +import flixel.FlxState; +import flixel.addons.display.FlxGridOverlay; +import flixel.group.FlxGroup.FlxTypedGroup; +import flixel.math.FlxPoint; +import flixel.text.FlxText; +import flixel.util.FlxColor; + +class CutsceneAnimTestState extends FlxState +{ + var animShit:Array = [ + 'GF STARTS TO TURN PART 1', + 'GF STARTS TO TURN PART 2', + 'PICO ARRIVES PART 1', + 'PICO ARRIVES PART 2', + 'PICO ARRIVES PART 2 POINT FIVE' + ]; + + var coolPosition:FlxPoint = FlxPoint.get(0, 100); + + var cutsceneGroup:CutsceneCharacter; + + var curSelected:Int = 0; + var debugTxt:FlxText; + + public function new() + { + super(); + + var gridBG:FlxSprite = FlxGridOverlay.create(10, 10); + gridBG.scrollFactor.set(0.5, 0.5); + add(gridBG); + + debugTxt = new FlxText(1000, 20, 0, "", 24); + debugTxt.color = FlxColor.BLUE; + add(debugTxt); + + for (i in 0...animShit.length) + { + var dummyLoader:FlxSprite = new FlxSprite(); + dummyLoader.loadGraphic(Paths.image('cutsceneStuff/gfHoldup-' + i)); + add(dummyLoader); + dummyLoader.alpha = 0.01; + dummyLoader.y = FlxG.height - 20; + } + + cutsceneGroup = new CutsceneCharacter(0, 100, 'gfHoldup'); + add(cutsceneGroup); + + // createCutscene(0); + // createCutscene(1); + // createCutscene(2); + // createCutscene(3); + // createCutscene(4); + } + + override function update(elapsed:Float) + { + if (FlxG.keys.pressed.SHIFT) + { + if (FlxG.keys.justPressed.UP) + curSelected -= 1; + if (FlxG.keys.justPressed.DOWN) + curSelected += 1; + } + else + { + var valueMulti:Float = 1; + + if (FlxG.keys.pressed.SPACE) + valueMulti = 10; + + if (FlxG.keys.justPressed.UP) + cutsceneGroup.members[curSelected].y -= valueMulti; + if (FlxG.keys.justPressed.DOWN) + cutsceneGroup.members[curSelected].y += valueMulti; + if (FlxG.keys.justPressed.LEFT) + cutsceneGroup.members[curSelected].x -= valueMulti; + if (FlxG.keys.justPressed.RIGHT) + cutsceneGroup.members[curSelected].x += valueMulti; + } + + debugTxt.text = curSelected + " : " + cutsceneGroup.members[curSelected].getPosition(); + + if (curSelected < 0) + curSelected = animShit.length - 1; + + if (curSelected >= animShit.length) + curSelected = 0; + + super.update(elapsed); + } +} diff --git a/source/CutsceneCharacter.hx b/source/CutsceneCharacter.hx new file mode 100644 index 000000000..0073007b1 --- /dev/null +++ b/source/CutsceneCharacter.hx @@ -0,0 +1,65 @@ +package; + +import flixel.FlxSprite; +import flixel.group.FlxGroup.FlxTypedGroup; +import flixel.math.FlxPoint; + +using StringTools; + +class CutsceneCharacter extends FlxTypedGroup +{ + public var coolPos:FlxPoint = FlxPoint.get(); + public var animShit:Map = new Map(); + + private var imageShit:String; + + public function new(x:Float, y:Float, imageShit:String) + { + super(); + + coolPos.set(x, y); + + this.imageShit = imageShit; + parseOffsets(); + createCutscene(0); + } + + // shitshow, oh well + var arrayLMFAOOOO:Array = []; + + function parseOffsets() + { + var splitShit:Array = CoolUtil.coolTextFile(Paths.file('images/cutsceneStuff/' + imageShit + "CutsceneOffsets.txt")); + + for (i in splitShit) + { + var xAndY:FlxPoint = FlxPoint.get(); + var dumbSplit:Array = i.split('---')[1].trim().split(' '); + xAndY.set(Std.parseFloat(dumbSplit[0]), Std.parseFloat(dumbSplit[1])); + + animShit.set(i.split('---')[0].trim(), xAndY); + arrayLMFAOOOO.push(i.split('---')[0].trim()); + } + + trace(animShit); + } + + public function createCutscene(daNum:Int = 0) + { + var cutScene:FlxSprite = new FlxSprite(coolPos.x + animShit.get(arrayLMFAOOOO[daNum]).x, coolPos.y + animShit.get(arrayLMFAOOOO[daNum]).y); + cutScene.frames = Paths.getSparrowAtlas('cutsceneStuff/' + imageShit + "-" + daNum); + cutScene.animation.addByPrefix('weed', arrayLMFAOOOO[daNum], 24, false); + cutScene.animation.play('weed'); + + cutScene.animation.finishCallback = function(anim:String) + { + cutScene.kill(); + cutScene.destroy(); + + if (daNum + 1 < arrayLMFAOOOO.length) + createCutscene(daNum + 1); + }; + + add(cutScene); + } +} diff --git a/source/TitleState.hx b/source/TitleState.hx index 84b6b9269..09fdb1ad2 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -44,13 +44,9 @@ class TitleState extends MusicBeatState var ngSpr:FlxSprite; var curWacky:Array = []; - var wackyImage:FlxSprite; - var lastBeat:Int = 0; - var swagShader:ColorSwap; - var thingie:FlxSprite; override public function create():Void @@ -59,6 +55,7 @@ class TitleState extends MusicBeatState polymod.Polymod.init({modRoot: "mods", dirs: ['introMod'], framework: OPENFL}); // FlxG.bitmap.clearCache(); #end + /* FlxG.stage.window.onDropFile.add(function(path:String) @@ -177,6 +174,7 @@ class TitleState extends MusicBeatState logoBl.antialiasing = true; logoBl.animation.addByPrefix('bump', 'logo bumpin', 24); logoBl.animation.play('bump'); + logoBl.updateHitbox(); logoBl.shader = swagShader.shader; @@ -271,6 +269,9 @@ class TitleState extends MusicBeatState override function update(elapsed:Float) { + if (FlxG.keys.justPressed.EIGHT) + FlxG.switchState(new CutsceneAnimTestState()); + /* if (FlxG.keys.justPressed.R) {