mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-15 03:35:18 -05:00
new line support for text also camera shit
This commit is contained in:
parent
f6c83ba4bb
commit
02b751d8fb
4 changed files with 118 additions and 32 deletions
|
@ -1,8 +1,11 @@
|
|||
package;
|
||||
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
import flixel.group.FlxSpriteGroup;
|
||||
import flixel.math.FlxMath;
|
||||
import flixel.util.FlxTimer;
|
||||
|
||||
using StringTools;
|
||||
|
||||
|
@ -17,9 +20,14 @@ class Alphabet extends FlxSpriteGroup
|
|||
var _finalText:String = "";
|
||||
var _curText:String = "";
|
||||
|
||||
public var widthOfWords:Float = FlxG.width;
|
||||
|
||||
var yMulti:Float = 1;
|
||||
|
||||
// custom shit
|
||||
// amp, backslash, question mark, apostrophy, comma, angry faic, period
|
||||
var lastSprite:AlphaCharacter;
|
||||
var xPosResetted: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;
|
||||
|
||||
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)
|
||||
if (lastSprite != null && !xPosResetted)
|
||||
{
|
||||
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(xPos, 0);
|
||||
letter.createBold(character);
|
||||
var letter:AlphaCharacter = new AlphaCharacter(xPos, 55 * yMulti);
|
||||
letter.createBold(arrayShit[loopNum]);
|
||||
add(letter);
|
||||
|
||||
lastSprite = letter;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import flixel.text.FlxText;
|
|||
|
||||
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 curSelected:Int = 0;
|
||||
|
|
|
@ -16,6 +16,8 @@ class PauseSubState extends FlxSubState
|
|||
bg.alpha = 0.6;
|
||||
bg.scrollFactor.set();
|
||||
add(bg);
|
||||
|
||||
bg.cameras = [FlxG.cameras.list[1]];
|
||||
}
|
||||
|
||||
override function update(elapsed:Float)
|
||||
|
|
|
@ -69,7 +69,8 @@ class PlayState extends MusicBeatState
|
|||
private var startingSong:Bool = false;
|
||||
|
||||
private var healthHeads:FlxSprite;
|
||||
private var UI_camera:FlxCamera;
|
||||
private var camHUD:FlxCamera;
|
||||
private var camGame:FlxCamera;
|
||||
|
||||
var controls(get, never):Controls;
|
||||
|
||||
|
@ -78,6 +79,16 @@ class PlayState extends MusicBeatState
|
|||
|
||||
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();
|
||||
|
||||
persistentUpdate = true;
|
||||
|
@ -134,10 +145,6 @@ class PlayState extends MusicBeatState
|
|||
strumLine = new FlxSprite(0, 50).makeGraphic(FlxG.width, 10);
|
||||
strumLine.scrollFactor.set();
|
||||
|
||||
var gameCam:FlxCamera = FlxG.camera;
|
||||
|
||||
UI_camera = new FlxCamera(0, 0, FlxG.width, FlxG.height, 1);
|
||||
|
||||
strumLineNotes = new FlxTypedGroup<FlxSprite>();
|
||||
add(strumLineNotes);
|
||||
|
||||
|
@ -185,13 +192,17 @@ class PlayState extends MusicBeatState
|
|||
healthHeads.antialiasing = true;
|
||||
add(healthHeads);
|
||||
|
||||
// strumLineNotes.camera = UI_camera;
|
||||
// camera = FlxG.camera;
|
||||
// FlxG.cameras.add(UI_camera);
|
||||
strumLineNotes.cameras = [camHUD];
|
||||
notes.cameras = [camHUD];
|
||||
// UI_camera.zoom = 1;
|
||||
|
||||
// cameras = [FlxG.cameras.list[1]];
|
||||
|
||||
super.create();
|
||||
}
|
||||
|
||||
var startTimer:FlxTimer;
|
||||
|
||||
function startCountdown():Void
|
||||
{
|
||||
startedCountdown = true;
|
||||
|
@ -200,7 +211,7 @@ class PlayState extends MusicBeatState
|
|||
|
||||
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)
|
||||
{
|
||||
|
@ -466,8 +477,14 @@ class PlayState extends MusicBeatState
|
|||
{
|
||||
if (paused)
|
||||
{
|
||||
FlxG.sound.music.pause();
|
||||
vocals.pause();
|
||||
if (FlxG.sound.music != null)
|
||||
{
|
||||
FlxG.sound.music.pause();
|
||||
vocals.pause();
|
||||
}
|
||||
|
||||
if (!startTimer.finished)
|
||||
startTimer.active = false;
|
||||
}
|
||||
|
||||
super.openSubState(SubState);
|
||||
|
@ -477,10 +494,16 @@ class PlayState extends MusicBeatState
|
|||
{
|
||||
if (paused)
|
||||
{
|
||||
vocals.time = FlxG.sound.music.time;
|
||||
if (FlxG.sound.music != null)
|
||||
{
|
||||
vocals.time = FlxG.sound.music.time;
|
||||
|
||||
FlxG.sound.music.play();
|
||||
vocals.play();
|
||||
FlxG.sound.music.play();
|
||||
vocals.play();
|
||||
}
|
||||
|
||||
if (!startTimer.finished)
|
||||
startTimer.active = true;
|
||||
paused = false;
|
||||
}
|
||||
|
||||
|
@ -540,16 +563,19 @@ class PlayState extends MusicBeatState
|
|||
{
|
||||
Conductor.songPosition = FlxG.sound.music.time;
|
||||
|
||||
songTime += FlxG.game.ticks - previousFrameTime;
|
||||
previousFrameTime = FlxG.game.ticks;
|
||||
|
||||
// Interpolation type beat
|
||||
if (Conductor.lastSongPos != Conductor.songPosition)
|
||||
if (!paused)
|
||||
{
|
||||
songTime = (songTime + Conductor.songPosition) / 2;
|
||||
Conductor.lastSongPos = Conductor.songPosition;
|
||||
// Conductor.songPosition += FlxG.elapsed * 1000;
|
||||
// trace('MISSED FRAME');
|
||||
songTime += FlxG.game.ticks - previousFrameTime;
|
||||
previousFrameTime = FlxG.game.ticks;
|
||||
|
||||
// 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;
|
||||
|
@ -576,11 +602,21 @@ class PlayState extends MusicBeatState
|
|||
{
|
||||
camFollow.setPosition(dad.getMidpoint().x + 150, dad.getMidpoint().y - 100);
|
||||
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)
|
||||
{
|
||||
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.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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue