early misses counter

This commit is contained in:
Yoshman29
2022-10-12 13:24:56 +02:00
parent 413cf6e2c0
commit 79d4f7cdbc
7 changed files with 23 additions and 73 deletions
+12 -12
View File
@@ -52,6 +52,7 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom
public var globalOffset:FlxPoint = new FlxPoint(0, 0);
public var script:Script;
public var xml:Access;
public inline function getCameraPosition() {
var midpoint = getMidpoint();
@@ -97,29 +98,28 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom
}
var plainXML = Assets.getText(xmlPath);
var character:Access;
try {
var charXML = Xml.parse(plainXML).firstElement();
if (charXML == null) throw new Exception("Missing \"character\" node in XML.");
character = new Access(charXML);
xml = new Access(charXML);
} catch(e) {
trace(e);
curCharacter = "bf";
continue;
}
if (character.has.isPlayer) playerOffsets = (character.att.isPlayer == "true");
if (character.has.isGF) isGF = (character.att.isGF == "true");
if (character.has.x) globalOffset.x = Std.parseFloat(character.att.x);
if (character.has.y) globalOffset.y = Std.parseFloat(character.att.y);
if (character.has.camx) cameraOffset.x = Std.parseFloat(character.att.camx);
if (character.has.camy) cameraOffset.y = Std.parseFloat(character.att.camy);
if (character.has.holdTime) holdTime = CoolUtil.getDefault(Std.parseFloat(character.att.holdTime), 4);
if (character.has.flipX) flipX = (character.att.flipX == "true");
if (character.has.icon) icon = character.att.icon;
if (xml.has.isPlayer) playerOffsets = (xml.att.isPlayer == "true");
if (xml.has.isGF) isGF = (xml.att.isGF == "true");
if (xml.has.x) globalOffset.x = Std.parseFloat(xml.att.x);
if (xml.has.y) globalOffset.y = Std.parseFloat(xml.att.y);
if (xml.has.camx) cameraOffset.x = Std.parseFloat(xml.att.camx);
if (xml.has.camy) cameraOffset.y = Std.parseFloat(xml.att.camy);
if (xml.has.holdTime) holdTime = CoolUtil.getDefault(Std.parseFloat(xml.att.holdTime), 4);
if (xml.has.flipX) flipX = (xml.att.flipX == "true");
if (xml.has.icon) icon = xml.att.icon;
frames = Paths.getSparrowAtlas('characters/$curCharacter');
for(anim in character.nodes.anim) {
for(anim in xml.nodes.anim) {
XMLUtil.addXMLAnimation(this, anim);
}
+4 -1
View File
@@ -106,6 +106,7 @@ class PlayState extends MusicBeatState
public var health:Float = 1;
public var combo:Int = 0;
public var comboBreaks:Bool = false;
public var healthBarBG:FlxSprite;
public var healthBar:FlxBar;
@@ -119,6 +120,7 @@ class PlayState extends MusicBeatState
public var songScore:Int = 0;
public var misses:Int = 0;
public var scoreTxt:FlxText;
public static var campaignScore:Int = 0;
@@ -789,7 +791,7 @@ class PlayState extends MusicBeatState
super.update(elapsed);
scripts.call("update", [elapsed]);
scoreTxt.text = "Score:" + songScore;
scoreTxt.text = 'Score:$songScore\n${comboBreaks ? "Combo Breaks" : "Misses"}:$misses';
if (FlxG.keys.justPressed.ENTER && startedCountdown && canPause)
pauseGame();
@@ -1324,6 +1326,7 @@ class PlayState extends MusicBeatState
combo = 0;
songScore -= 10;
misses++;
FlxG.sound.play(Paths.soundRandom('missnote', 1, 3), FlxG.random.float(0.1, 0.2));
// FlxG.sound.play(Paths.sound('missnote1'), 1, false);
+2 -1
View File
@@ -117,7 +117,8 @@ class Stage extends FlxBasic implements IBeatReceiver {
}
if (sprite != null) {
for(e in node.nodes.property) {
trace(XMLUtil.applyXMLProperty(sprite, e));
// TODO: Proper logging system
XMLUtil.applyXMLProperty(sprite, e);
}
}
}
+2 -33
View File
@@ -26,47 +26,16 @@ class CoolUtil
return FlxMath.lerp(v1, v2, getFPSRatio(ratio));
}
/**
* Lerps from color1 into color2 in a cool way 😎
* Lerps from color1 into color2 (Shortcut to `FlxColor.interpolate`)
* @param color1 Color 1
* @param color2 Color 2
* @param ratio Ratio
* @param fpsSensitive Whenever the ratio should be case sentivive (adapted when game is running at 120 instead of 60)
*/
public static function lerpColor(color1:FlxColor, color2:FlxColor, ratio:Float, fpsSensitive:Bool = false) {
var h1 = color1.hue;
var s1 = color1.saturation;
var b1 = color1.brightness;
var h2 = color2.hue;
var s2 = color2.saturation;
var b2 = color2.brightness;
if (!fpsSensitive)
ratio = getFPSRatio(ratio);
if (Math.abs(h1-h2) > 180) h1 += 360;
if (Math.abs(h1 - h2) > 180 || (s2 < 0.125 || s1 < 0.125)) {
// classic r,g,b lerp
var r1 = color1.redFloat;
var g1 = color1.greenFloat;
var b1 = color1.blueFloat;
var r2 = color2.redFloat;
var g2 = color2.greenFloat;
var b2 = color2.blueFloat;
return FlxColor.fromRGBFloat(
FlxMath.lerp(r1, r2, ratio),
FlxMath.lerp(g1, g2, ratio),
FlxMath.lerp(b1, b2, ratio));
}
return FlxColor.fromHSB(
FlxMath.lerp(h1, h2, ratio),
FlxMath.lerp(s1, s2, ratio),
FlxMath.lerp(b1, b2, ratio));
return FlxColor.interpolate(color1, color2, ratio);
}
/**