1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-03-28 04:50:01 +00:00

new line support for text also camera shit

This commit is contained in:
Cameron Taylor 2020-10-26 02:16:05 -07:00
parent f6c83ba4bb
commit 02b751d8fb
4 changed files with 118 additions and 32 deletions

View file

@ -1,8 +1,11 @@
package; package;
import flixel.FlxG;
import flixel.FlxSprite; import flixel.FlxSprite;
import flixel.graphics.frames.FlxAtlasFrames; import flixel.graphics.frames.FlxAtlasFrames;
import flixel.group.FlxSpriteGroup; import flixel.group.FlxSpriteGroup;
import flixel.math.FlxMath;
import flixel.util.FlxTimer;
using StringTools; using StringTools;
@ -17,9 +20,14 @@ class Alphabet extends FlxSpriteGroup
var _finalText:String = ""; var _finalText:String = "";
var _curText:String = ""; var _curText:String = "";
public var widthOfWords:Float = FlxG.width;
var yMulti:Float = 1;
// custom shit // custom shit
// amp, backslash, question mark, apostrophy, comma, angry faic, period // amp, backslash, question mark, apostrophy, comma, angry faic, period
var lastSprite:AlphaCharacter; var lastSprite:AlphaCharacter;
var xPosResetted:Bool = false;
public function new(x:Float, y:Float, text:String = "", ?bold:Bool = false) public function new(x:Float, y:Float, text:String = "", ?bold:Bool = false)
{ {
@ -32,29 +40,67 @@ class Alphabet extends FlxSpriteGroup
var loopNum:Int = 0; var loopNum:Int = 0;
for (character in arrayShit) new FlxTimer().start(0.05, function(tmr:FlxTimer)
{ {
if (character == " ") var xPos:Float = 0;
// trace(_finalText.fastCodeAt(loopNum) + " " + _finalText.charAt(loopNum));
if (_finalText.fastCodeAt(loopNum) == "\n".code)
{ {
yMulti += 1;
xPosResetted = true;
// xPos = 0;
} }
if (AlphaCharacter.alphabet.contains(character.toLowerCase())) if (AlphaCharacter.alphabet.contains(arrayShit[loopNum].toLowerCase()))
{ {
var xPos:Float = 0; if (lastSprite != null && !xPosResetted)
if (lastSprite != null)
{ {
xPos = lastSprite.x + lastSprite.frameWidth - 40; xPos = lastSprite.x + lastSprite.frameWidth - 40;
} }
else
{
xPosResetted = false;
}
// trace(_finalText.fastCodeAt(loopNum) + " " + _finalText.charAt(loopNum));
// var letter:AlphaCharacter = new AlphaCharacter(30 * loopNum, 0); // var letter:AlphaCharacter = new AlphaCharacter(30 * loopNum, 0);
var letter:AlphaCharacter = new AlphaCharacter(xPos, 0); var letter:AlphaCharacter = new AlphaCharacter(xPos, 55 * yMulti);
letter.createBold(character); letter.createBold(arrayShit[loopNum]);
add(letter); add(letter);
lastSprite = letter; lastSprite = letter;
} }
loopNum += 1; loopNum += 1;
tmr.time = FlxG.random.float(0.03, 0.09);
}, arrayShit.length);
for (character in arrayShit)
{
// if (character.fastCodeAt() == " ")
// {
// }
if (AlphaCharacter.alphabet.contains(character.toLowerCase()))
{
/* var xPos:Float = 0;
if (lastSprite != null)
{
xPos = lastSprite.x + lastSprite.frameWidth - 40;
}
// var letter:AlphaCharacter = new AlphaCharacter(30 * loopNum, 0);
var letter:AlphaCharacter = new AlphaCharacter(xPos, 0);
letter.createBold(character);
add(letter);
lastSprite = letter; */
}
// loopNum += 1;
} }
} }

View file

@ -7,7 +7,7 @@ import flixel.text.FlxText;
class FreeplayState extends MusicBeatState class FreeplayState extends MusicBeatState
{ {
var songs:Array<String> = ["Bopeebo", "Dadbattle", "Fresh", "Tutorial"]; var songs:Array<String> = ["Bopeebo", "Dadbattle", "Fresh", "Tutorial\nlol"];
var selector:FlxText; var selector:FlxText;
var curSelected:Int = 0; var curSelected:Int = 0;

View file

@ -16,6 +16,8 @@ class PauseSubState extends FlxSubState
bg.alpha = 0.6; bg.alpha = 0.6;
bg.scrollFactor.set(); bg.scrollFactor.set();
add(bg); add(bg);
bg.cameras = [FlxG.cameras.list[1]];
} }
override function update(elapsed:Float) override function update(elapsed:Float)

View file

@ -69,7 +69,8 @@ class PlayState extends MusicBeatState
private var startingSong:Bool = false; private var startingSong:Bool = false;
private var healthHeads:FlxSprite; private var healthHeads:FlxSprite;
private var UI_camera:FlxCamera; private var camHUD:FlxCamera;
private var camGame:FlxCamera;
var controls(get, never):Controls; var controls(get, never):Controls;
@ -78,6 +79,16 @@ class PlayState extends MusicBeatState
override public function create() override public function create()
{ {
// var gameCam:FlxCamera = FlxG.camera;
camGame = new FlxCamera();
camHUD = new FlxCamera();
camHUD.bgColor.alpha = 0;
FlxG.cameras.reset(camGame);
FlxG.cameras.add(camHUD);
FlxCamera.defaultCameras = [camGame];
PlayerSettings.init(); PlayerSettings.init();
persistentUpdate = true; persistentUpdate = true;
@ -134,10 +145,6 @@ class PlayState extends MusicBeatState
strumLine = new FlxSprite(0, 50).makeGraphic(FlxG.width, 10); strumLine = new FlxSprite(0, 50).makeGraphic(FlxG.width, 10);
strumLine.scrollFactor.set(); strumLine.scrollFactor.set();
var gameCam:FlxCamera = FlxG.camera;
UI_camera = new FlxCamera(0, 0, FlxG.width, FlxG.height, 1);
strumLineNotes = new FlxTypedGroup<FlxSprite>(); strumLineNotes = new FlxTypedGroup<FlxSprite>();
add(strumLineNotes); add(strumLineNotes);
@ -185,13 +192,17 @@ class PlayState extends MusicBeatState
healthHeads.antialiasing = true; healthHeads.antialiasing = true;
add(healthHeads); add(healthHeads);
// strumLineNotes.camera = UI_camera; strumLineNotes.cameras = [camHUD];
// camera = FlxG.camera; notes.cameras = [camHUD];
// FlxG.cameras.add(UI_camera); // UI_camera.zoom = 1;
// cameras = [FlxG.cameras.list[1]];
super.create(); super.create();
} }
var startTimer:FlxTimer;
function startCountdown():Void function startCountdown():Void
{ {
startedCountdown = true; startedCountdown = true;
@ -200,7 +211,7 @@ class PlayState extends MusicBeatState
var swagCounter:Int = 0; var swagCounter:Int = 0;
new FlxTimer().start(Conductor.crochet / 1000, function(tmr:FlxTimer) startTimer = new FlxTimer().start(Conductor.crochet / 1000, function(tmr:FlxTimer)
{ {
switch (swagCounter) switch (swagCounter)
{ {
@ -466,8 +477,14 @@ class PlayState extends MusicBeatState
{ {
if (paused) if (paused)
{ {
FlxG.sound.music.pause(); if (FlxG.sound.music != null)
vocals.pause(); {
FlxG.sound.music.pause();
vocals.pause();
}
if (!startTimer.finished)
startTimer.active = false;
} }
super.openSubState(SubState); super.openSubState(SubState);
@ -477,10 +494,16 @@ class PlayState extends MusicBeatState
{ {
if (paused) if (paused)
{ {
vocals.time = FlxG.sound.music.time; if (FlxG.sound.music != null)
{
vocals.time = FlxG.sound.music.time;
FlxG.sound.music.play(); FlxG.sound.music.play();
vocals.play(); vocals.play();
}
if (!startTimer.finished)
startTimer.active = true;
paused = false; paused = false;
} }
@ -540,16 +563,19 @@ class PlayState extends MusicBeatState
{ {
Conductor.songPosition = FlxG.sound.music.time; Conductor.songPosition = FlxG.sound.music.time;
songTime += FlxG.game.ticks - previousFrameTime; if (!paused)
previousFrameTime = FlxG.game.ticks;
// Interpolation type beat
if (Conductor.lastSongPos != Conductor.songPosition)
{ {
songTime = (songTime + Conductor.songPosition) / 2; songTime += FlxG.game.ticks - previousFrameTime;
Conductor.lastSongPos = Conductor.songPosition; previousFrameTime = FlxG.game.ticks;
// Conductor.songPosition += FlxG.elapsed * 1000;
// trace('MISSED FRAME'); // Interpolation type beat
if (Conductor.lastSongPos != Conductor.songPosition)
{
songTime = (songTime + Conductor.songPosition) / 2;
Conductor.lastSongPos = Conductor.songPosition;
// Conductor.songPosition += FlxG.elapsed * 1000;
// trace('MISSED FRAME');
}
} }
// Conductor.lastSongPos = FlxG.sound.music.time; // Conductor.lastSongPos = FlxG.sound.music.time;
@ -576,11 +602,21 @@ class PlayState extends MusicBeatState
{ {
camFollow.setPosition(dad.getMidpoint().x + 150, dad.getMidpoint().y - 100); camFollow.setPosition(dad.getMidpoint().x + 150, dad.getMidpoint().y - 100);
vocals.volume = 1; vocals.volume = 1;
if (SONG.song.toLowerCase() == 'tutorial')
{
FlxTween.tween(FlxG.camera, {zoom: 1.3}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut});
}
} }
if (PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection && camFollow.x != boyfriend.getMidpoint().x - 100) if (PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection && camFollow.x != boyfriend.getMidpoint().x - 100)
{ {
camFollow.setPosition(boyfriend.getMidpoint().x - 100, boyfriend.getMidpoint().y - 100); camFollow.setPosition(boyfriend.getMidpoint().x - 100, boyfriend.getMidpoint().y - 100);
if (SONG.song.toLowerCase() == 'tutorial')
{
FlxTween.tween(FlxG.camera, {zoom: 1}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut});
}
} }
} }
@ -680,7 +716,9 @@ class PlayState extends MusicBeatState
daNote.destroy(); daNote.destroy();
} }
daNote.y = (strumLine.y - (songTime - daNote.strumTime) * (0.45 * PlayState.SONG.speed)); daNote.y = (strumLine.y - (Conductor.songPosition - daNote.strumTime) * (0.45 * PlayState.SONG.speed));
// WIP interpolation shit? Need to fix the pause issue
// daNote.y = (strumLine.y - (songTime - daNote.strumTime) * (0.45 * PlayState.SONG.speed));
if (daNote.y < -daNote.height) if (daNote.y < -daNote.height)
{ {