Gameplay Customization
This commit is contained in:
176
source/GameplayCustomizeState.hx
Normal file
176
source/GameplayCustomizeState.hx
Normal file
@ -0,0 +1,176 @@
|
||||
import flixel.math.FlxPoint;
|
||||
import flixel.FlxObject;
|
||||
#if desktop
|
||||
import Discord.DiscordClient;
|
||||
import sys.thread.Thread;
|
||||
#end
|
||||
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
import openfl.ui.Keyboard;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxG;
|
||||
|
||||
class GameplayCustomizeState extends MusicBeatState
|
||||
{
|
||||
|
||||
var defaultX:Float = FlxG.width * 0.55 - 135;
|
||||
var defaultY:Float = FlxG.height / 2 - 50;
|
||||
|
||||
var background:FlxSprite = new FlxSprite(-600, -200).loadGraphic(Paths.image('stageback','shared'));
|
||||
var curt:FlxSprite = new FlxSprite(-500, -300).loadGraphic(Paths.image('stagecurtains','shared'));
|
||||
var front:FlxSprite = new FlxSprite(-650, 600).loadGraphic(Paths.image('stagefront','shared'));
|
||||
|
||||
var sick:FlxSprite = new FlxSprite().loadGraphic(Paths.image('sick','shared'));
|
||||
|
||||
var bf:Boyfriend = new Boyfriend(770, 450, 'bf');
|
||||
var dad:Character;
|
||||
|
||||
var strumLine:FlxSprite;
|
||||
var strumLineNotes:FlxTypedGroup<FlxSprite>;
|
||||
var playerStrums:FlxTypedGroup<FlxSprite>;
|
||||
|
||||
override function create() {
|
||||
#if desktop
|
||||
// Updating Discord Rich Presence
|
||||
DiscordClient.changePresence("Customizing Gameplay", null);
|
||||
#end
|
||||
|
||||
background.scrollFactor.set(0.9,0.9);
|
||||
curt.scrollFactor.set(0.9,0.9);
|
||||
front.scrollFactor.set(0.9,0.9);
|
||||
|
||||
add(background);
|
||||
add(front);
|
||||
add(curt);
|
||||
|
||||
|
||||
add(sick);
|
||||
|
||||
bf.playAnim('idle');
|
||||
|
||||
var camFollow = new FlxObject(0, 0, 1, 1);
|
||||
|
||||
dad = new Character(100, 100, 'dad');
|
||||
|
||||
var camPos:FlxPoint = new FlxPoint(dad.getGraphicMidpoint().x + 400, dad.getGraphicMidpoint().y);
|
||||
|
||||
camFollow.setPosition(camPos.x, camPos.y);
|
||||
|
||||
add(bf);
|
||||
add(dad);
|
||||
|
||||
add(camFollow);
|
||||
|
||||
FlxG.camera.follow(camFollow, LOCKON, 0.01);
|
||||
// FlxG.camera.setScrollBounds(0, FlxG.width, 0, FlxG.height);
|
||||
FlxG.camera.zoom = 0.9;
|
||||
FlxG.camera.focusOn(camFollow.getPosition());
|
||||
|
||||
strumLine = new FlxSprite(0, 25).makeGraphic(FlxG.width, 10);
|
||||
strumLine.scrollFactor.set();
|
||||
|
||||
if (FlxG.save.data.downscroll)
|
||||
strumLine.y = FlxG.height - 165;
|
||||
|
||||
strumLineNotes = new FlxTypedGroup<FlxSprite>();
|
||||
add(strumLineNotes);
|
||||
|
||||
playerStrums = new FlxTypedGroup<FlxSprite>();
|
||||
|
||||
generateStaticArrows(0);
|
||||
generateStaticArrows(1);
|
||||
|
||||
if (!FlxG.save.data.changedHit)
|
||||
{
|
||||
FlxG.save.data.changedHitX = defaultX;
|
||||
FlxG.save.data.changedHitY = defaultY;
|
||||
}
|
||||
|
||||
sick.x = FlxG.save.data.changedHitX;
|
||||
sick.y = FlxG.save.data.changedHitY;
|
||||
|
||||
FlxG.mouse.visible = true;
|
||||
}
|
||||
|
||||
override function update(elapsed:Float) {
|
||||
bf.playAnim('idle');
|
||||
dad.dance();
|
||||
|
||||
if (FlxG.mouse.overlaps(sick) && FlxG.mouse.pressed)
|
||||
{
|
||||
sick.x = FlxG.mouse.x - sick.width / 2;
|
||||
sick.y = FlxG.mouse.y - sick.height / 2;
|
||||
}
|
||||
|
||||
if (FlxG.mouse.overlaps(sick) && FlxG.mouse.justReleased)
|
||||
{
|
||||
FlxG.save.data.changedHitX = sick.x;
|
||||
FlxG.save.data.changedHitY = sick.y;
|
||||
FlxG.save.data.changedHit = true;
|
||||
}
|
||||
|
||||
if (controls.BACK)
|
||||
{
|
||||
FlxG.mouse.visible = false;
|
||||
FlxG.sound.play(Paths.sound('cancelMenu'));
|
||||
FlxG.switchState(new OptionsMenu());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ripped from play state cuz im lazy
|
||||
|
||||
private function generateStaticArrows(player:Int):Void
|
||||
{
|
||||
for (i in 0...4)
|
||||
{
|
||||
// FlxG.log.add(i);
|
||||
var babyArrow:FlxSprite = new FlxSprite(0, strumLine.y);
|
||||
babyArrow.frames = Paths.getSparrowAtlas('NOTE_assets', 'shared');
|
||||
babyArrow.animation.addByPrefix('green', 'arrowUP');
|
||||
babyArrow.animation.addByPrefix('blue', 'arrowDOWN');
|
||||
babyArrow.animation.addByPrefix('purple', 'arrowLEFT');
|
||||
babyArrow.animation.addByPrefix('red', 'arrowRIGHT');
|
||||
babyArrow.antialiasing = true;
|
||||
babyArrow.setGraphicSize(Std.int(babyArrow.width * 0.7));
|
||||
switch (Math.abs(i))
|
||||
{
|
||||
case 0:
|
||||
babyArrow.x += Note.swagWidth * 0;
|
||||
babyArrow.animation.addByPrefix('static', 'arrowLEFT');
|
||||
babyArrow.animation.addByPrefix('pressed', 'left press', 24, false);
|
||||
babyArrow.animation.addByPrefix('confirm', 'left confirm', 24, false);
|
||||
case 1:
|
||||
babyArrow.x += Note.swagWidth * 1;
|
||||
babyArrow.animation.addByPrefix('static', 'arrowDOWN');
|
||||
babyArrow.animation.addByPrefix('pressed', 'down press', 24, false);
|
||||
babyArrow.animation.addByPrefix('confirm', 'down confirm', 24, false);
|
||||
case 2:
|
||||
babyArrow.x += Note.swagWidth * 2;
|
||||
babyArrow.animation.addByPrefix('static', 'arrowUP');
|
||||
babyArrow.animation.addByPrefix('pressed', 'up press', 24, false);
|
||||
babyArrow.animation.addByPrefix('confirm', 'up confirm', 24, false);
|
||||
case 3:
|
||||
babyArrow.x += Note.swagWidth * 3;
|
||||
babyArrow.animation.addByPrefix('static', 'arrowRIGHT');
|
||||
babyArrow.animation.addByPrefix('pressed', 'right press', 24, false);
|
||||
babyArrow.animation.addByPrefix('confirm', 'right confirm', 24, false);
|
||||
}
|
||||
babyArrow.updateHitbox();
|
||||
babyArrow.scrollFactor.set();
|
||||
|
||||
babyArrow.ID = i;
|
||||
|
||||
if (player == 1)
|
||||
{
|
||||
playerStrums.add(babyArrow);
|
||||
}
|
||||
|
||||
babyArrow.animation.play('static');
|
||||
babyArrow.x += 50;
|
||||
babyArrow.x += ((FlxG.width / 2) * player);
|
||||
|
||||
strumLineNotes.add(babyArrow);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user