perfornance and optimization

This commit is contained in:
Cameron Taylor 2020-10-05 02:48:30 -07:00
parent a75e543fb8
commit 3855c5ea9f
3 changed files with 183 additions and 6 deletions

BIN
assets/images/GF_assets.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 KiB

136
assets/images/GF_assets.xml Normal file
View File

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<TextureAtlas imagePath="GF_assets.png">
<!-- Created with Adobe Animate version 20.0.0.17400 -->
<!-- http://www.adobe.com/products/animate.html -->
<SubTexture name="GF Cheer0000" x="0" y="0" width="646" height="654"/>
<SubTexture name="GF Cheer0001" x="0" y="0" width="646" height="654"/>
<SubTexture name="GF Cheer0002" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Cheer0003" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Cheer0004" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Cheer0005" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Cheer0006" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Cheer0007" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Cheer0008" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Cheer0009" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Cheer0010" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Cheer0011" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Cheer0012" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Cheer0013" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Cheer0014" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Cheer0015" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Cheer0016" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Cheer0017" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Cheer0018" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Cheer0019" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Cheer0020" x="651" y="0" width="646" height="651" frameX="0" frameY="-3" frameWidth="646" frameHeight="654"/>
<SubTexture name="GF Dancing Beat0000" x="651" y="1933" width="646" height="631" frameX="0" frameY="-14" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0001" x="651" y="1933" width="646" height="631" frameX="0" frameY="-14" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0002" x="0" y="1936" width="646" height="629" frameX="0" frameY="-16" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0003" x="3255" y="2565" width="646" height="629" frameX="0" frameY="-16" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0004" x="3255" y="1928" width="646" height="632" frameX="0" frameY="-13" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0005" x="1953" y="1929" width="646" height="632" frameX="0" frameY="-13" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0006" x="2604" y="650" width="646" height="634" frameX="0" frameY="-11" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0007" x="1302" y="0" width="646" height="645"/>
<SubTexture name="GF Dancing Beat0008" x="1302" y="0" width="646" height="645"/>
<SubTexture name="GF Dancing Beat0009" x="1302" y="0" width="646" height="645"/>
<SubTexture name="GF Dancing Beat0010" x="1953" y="0" width="646" height="645"/>
<SubTexture name="GF Dancing Beat0011" x="1953" y="0" width="646" height="645"/>
<SubTexture name="GF Dancing Beat0012" x="1953" y="0" width="646" height="645"/>
<SubTexture name="GF Dancing Beat0013" x="2604" y="0" width="646" height="645"/>
<SubTexture name="GF Dancing Beat0014" x="2604" y="0" width="646" height="645"/>
<SubTexture name="GF Dancing Beat0015" x="651" y="1295" width="646" height="633" frameX="0" frameY="-12" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0016" x="651" y="1295" width="646" height="633" frameX="0" frameY="-12" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0017" x="0" y="1298" width="646" height="633" frameX="0" frameY="-12" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0018" x="2604" y="1928" width="646" height="633" frameX="0" frameY="-12" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0019" x="651" y="656" width="646" height="634" frameX="0" frameY="-11" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0020" x="0" y="659" width="646" height="634" frameX="0" frameY="-11" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0021" x="1953" y="650" width="646" height="635" frameX="0" frameY="-10" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0022" x="3255" y="0" width="646" height="640" frameX="0" frameY="-5" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0023" x="3255" y="0" width="646" height="640" frameX="0" frameY="-5" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0024" x="3255" y="0" width="646" height="640" frameX="0" frameY="-5" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0025" x="3255" y="645" width="646" height="639" frameX="0" frameY="-6" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0026" x="3255" y="645" width="646" height="639" frameX="0" frameY="-6" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0027" x="3255" y="645" width="646" height="639" frameX="0" frameY="-6" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0028" x="1302" y="650" width="646" height="639" frameX="0" frameY="-6" frameWidth="646" frameHeight="645"/>
<SubTexture name="GF Dancing Beat0029" x="1302" y="650" width="646" height="639" frameX="0" frameY="-6" frameWidth="646" frameHeight="645"/>
<SubTexture name="gf sad0000" x="1302" y="1933" width="646" height="631" frameX="0" frameY="-3" frameWidth="646" frameHeight="634"/>
<SubTexture name="gf sad0001" x="1302" y="1933" width="646" height="631" frameX="0" frameY="-3" frameWidth="646" frameHeight="634"/>
<SubTexture name="gf sad0002" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0003" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0004" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0005" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0006" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0007" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0008" x="1302" y="1294" width="646" height="634"/>
<SubTexture name="gf sad0009" x="1302" y="1294" width="646" height="634"/>
<SubTexture name="gf sad0010" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0011" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0012" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0013" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0014" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0015" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0016" x="1302" y="1294" width="646" height="634"/>
<SubTexture name="gf sad0017" x="1302" y="1294" width="646" height="634"/>
<SubTexture name="gf sad0018" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0019" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0020" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0021" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0022" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0023" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0024" x="1302" y="1294" width="646" height="634"/>
<SubTexture name="gf sad0025" x="1302" y="1294" width="646" height="634"/>
<SubTexture name="gf sad0026" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0027" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0028" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0029" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0030" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0031" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0032" x="1302" y="1294" width="646" height="634"/>
<SubTexture name="gf sad0033" x="1302" y="1294" width="646" height="634"/>
<SubTexture name="gf sad0034" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0035" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0036" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0037" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0038" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0039" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0040" x="1302" y="1294" width="646" height="634"/>
<SubTexture name="gf sad0041" x="1302" y="1294" width="646" height="634"/>
<SubTexture name="gf sad0042" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0043" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0044" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0045" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0046" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0047" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0048" x="1302" y="1294" width="646" height="634"/>
<SubTexture name="gf sad0049" x="1302" y="1294" width="646" height="634"/>
<SubTexture name="gf sad0050" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0051" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0052" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0053" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0054" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0055" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0056" x="1302" y="1294" width="646" height="634"/>
<SubTexture name="gf sad0057" x="1302" y="1294" width="646" height="634"/>
<SubTexture name="gf sad0058" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0059" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0060" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0061" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0062" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0063" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0064" x="1302" y="1294" width="646" height="634"/>
<SubTexture name="gf sad0065" x="1302" y="1294" width="646" height="634"/>
<SubTexture name="gf sad0066" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0067" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0068" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0069" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0070" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0071" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0072" x="1302" y="1294" width="646" height="634"/>
<SubTexture name="gf sad0073" x="1302" y="1294" width="646" height="634"/>
<SubTexture name="gf sad0074" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0075" x="2604" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0076" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0077" x="3255" y="1289" width="646" height="634"/>
<SubTexture name="gf sad0078" x="1953" y="1290" width="646" height="634"/>
<SubTexture name="gf sad0079" x="1953" y="1290" width="646" height="634"/>
</TextureAtlas>

View File

@ -8,6 +8,7 @@ import flixel.addons.display.FlxGridOverlay;
import flixel.graphics.atlas.FlxAtlas;
import flixel.graphics.frames.FlxAtlasFrames;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.math.FlxMath;
import flixel.system.FlxSound;
import flixel.text.FlxText;
import flixel.tweens.FlxTween;
@ -38,6 +39,7 @@ class PlayState extends FlxState
private var boyfriend:Boyfriend;
private var notes:FlxTypedGroup<Note>;
private var unspawnNotes:Array<Note> = [];
private var strumLine:FlxSprite;
private var curSection:Int = 0;
@ -49,6 +51,9 @@ class PlayState extends FlxState
private var strumLineNotes:FlxTypedGroup<FlxSprite>;
private var playerStrums:FlxTypedGroup<FlxSprite>;
private var camZooming:Bool = false;
private var curSong:String = "";
override public function create()
{
var bg:FlxSprite = new FlxSprite(-600, -200).loadGraphic(AssetPaths.bg__png);
@ -106,6 +111,8 @@ class PlayState extends FlxState
Conductor.changeBPM(songData.bpm);
FlxG.sound.playMusic("assets/music/" + songData.song + "_Inst.mp3");
curSong = songData.song;
vocals = new FlxSound().loadEmbedded("assets/music/" + songData.song + "_Voices.mp3");
FlxG.sound.list.add(vocals);
vocals.play();
@ -149,14 +156,16 @@ class PlayState extends FlxState
+ ((Conductor.crochet * coolSection) * playerCounter);
var oldNote:Note;
if (notes.members.length > 0)
oldNote = notes.members[notes.members.length - 1];
if (unspawnNotes.length > 0)
oldNote = unspawnNotes[Std.int(unspawnNotes.length - 1)];
else
oldNote = null;
var swagNote:Note = new Note(daStrumTime, songNotes, oldNote);
swagNote.scrollFactor.set(0, 0);
unspawnNotes.push(swagNote);
swagNote.x += ((FlxG.width / 2) * playerCounter); // general offset
if (playerCounter == 1) // is the player
@ -167,8 +176,6 @@ class PlayState extends FlxState
{
sectionScores[0][daBeats] += swagNote.noteScore;
}
notes.add(swagNote);
}
daStep += 1;
@ -181,8 +188,17 @@ class PlayState extends FlxState
daBeats += 1;
}
trace(unspawnNotes.length);
playerCounter += 1;
}
unspawnNotes.sort(sortByShit);
trace('FIRST NOTE ' + unspawnNotes[0]);
}
function sortByShit(Obj1:Note, Obj2:Note):Int
{
return FlxSort.byValues(FlxSort.ASCENDING, Obj1.strumTime, Obj2.strumTime);
}
var sortedNotes:Bool = false;
@ -275,15 +291,37 @@ class PlayState extends FlxState
camFollow.setPosition(boyfriend.getGraphicMidpoint().x - 100, boyfriend.getGraphicMidpoint().y - 100);
}
if (camZooming)
{
FlxG.camera.zoom = FlxMath.lerp(1.05, FlxG.camera.zoom, 0.96);
}
if (playerTurn < 4)
{
sectionScored = false;
}
FlxG.watch.addQuick("beatShit", playerTurn);
FlxG.watch.addQuick("beatShit", totalBeats);
if (curSong == 'Fresh' && totalBeats == 16)
{
camZooming = true;
}
everyBeat();
everyStep();
// better streaming of shit
FlxG.watch.addQuick('spsa', unspawnNotes[0].strumTime);
FlxG.watch.addQuick('weed', Conductor.songPosition);
if (unspawnNotes[0].strumTime - Conductor.songPosition < 5 * 1000)
{
var dunceNote:Note = unspawnNotes[0];
notes.add(dunceNote);
var index:Int = unspawnNotes.indexOf(dunceNote);
unspawnNotes.splice(index, 1);
}
notes.forEachAlive(function(daNote:Note)
{
@ -488,7 +526,7 @@ class PlayState extends FlxState
if (!boyfriend.stunned)
{
trace('badNote');
FlxG.sound.play('assets/sounds/missnote' + FlxG.random.int(1, 3) + ".mp3", 0.2);
FlxG.sound.play('assets/sounds/missnote' + FlxG.random.int(1, 3) + ".mp3", FlxG.random.float(0.05, 0.2));
boyfriend.stunned = true;
@ -581,6 +619,9 @@ class PlayState extends FlxState
lastBeat += Conductor.crochet;
canHitText.text += "\nWEED\nWEED";
if (camZooming && FlxG.camera.zoom < 1.35 && totalBeats % 4 == 0)
FlxG.camera.zoom += 0.025;
totalBeats += 1;
dad.animation.play('idle');