finally fixed offsets for opponent player + icons

This commit is contained in:
Yoshman29
2022-10-08 12:20:49 +02:00
parent fa681da310
commit d94d7dc92f
21 changed files with 101 additions and 116 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
<!DOCTYPE codename-engine-character>
<character isPlayer="false" flipX="true" x="-200" y="300" cam_x="600" >
<character isPlayer="false" flipX="true" x="-200" y="300" camx="200">
<anim name="idle" anim="Pico Idle Dance" fps="24" loop="false" x="0" y="0" />
<!-- Sing Animations -->
@@ -10,7 +10,7 @@
<!-- Miss Animations -->
<anim name="singLEFTmiss" anim="Pico Note Right Miss" fps="24" loop="false" x="62" y="64" />
<anim name="singDOWNmiss" anim="Pico Down Note MISS" fps="24" loop="false" x="210" y="-28" />
<anim name="singDOWNmiss" anim="Pico Down Note MISS" fps="24" loop="false" x="-86" y="-28" />
<anim name="singUPmiss" anim="pico Up note miss" fps="24" loop="false" x="-19" y="67" />
<anim name="singRIGHTmiss" anim="Pico NOTE LEFT miss" fps="24" loop="false" x="-60" y="41" />
</character>
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

+1 -1
View File
@@ -1 +1 @@
209
221
+4 -4
View File
@@ -178,13 +178,13 @@ class AnimationDebug extends FlxState
{
updateTexts();
if (upP)
char.animOffsets.get(animList[curAnim])[1] += 1 * multiplier;
char.animOffsets.get(animList[curAnim]).y += 1 * multiplier;
if (downP)
char.animOffsets.get(animList[curAnim])[1] -= 1 * multiplier;
char.animOffsets.get(animList[curAnim]).y -= 1 * multiplier;
if (leftP)
char.animOffsets.get(animList[curAnim])[0] += 1 * multiplier;
char.animOffsets.get(animList[curAnim]).x += 1 * multiplier;
if (rightP)
char.animOffsets.get(animList[curAnim])[0] -= 1 * multiplier;
char.animOffsets.get(animList[curAnim]).x -= 1 * multiplier;
updateTexts();
genBoyOffsets(false);
+47 -55
View File
@@ -9,6 +9,7 @@ import flixel.FlxSprite;
import flixel.FlxCamera;
import flixel.animation.FlxBaseAnimation;
import flixel.graphics.frames.FlxAtlasFrames;
import flixel.math.FlxRect;
import openfl.utils.Assets;
import haxe.xml.Access;
@@ -19,9 +20,15 @@ using StringTools;
class Character extends FlxSprite implements IBeatReceiver implements IOffsetCompatible
{
public var stunned:Bool = false;
private var __stunnedTime:Float = 0;
public var stunned(default, set):Bool = false;
public var animOffsets:Map<String, Array<Dynamic>>;
private function set_stunned(b:Bool) {
__stunnedTime = 0;
return stunned = b;
}
public var animOffsets:Map<String, FlxPoint>;
public var debugMode:Bool = false;
public var isPlayer:Bool = false;
@@ -33,13 +40,20 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom
public var playerOffsets:Bool = false;
public var cameraOffset:FlxPoint = new FlxPoint(0, 0);
public var globalOffset:FlxPoint = new FlxPoint(0, 0);
public inline function getCameraPosition() {
var midpoint = getMidpoint();
return FlxPoint.get(
midpoint.x + (isPlayer ? -100 : 150) + globalOffset.x + cameraOffset.x,
midpoint.y - 100 + globalOffset.y + cameraOffset.y);
}
public function new(x:Float, y:Float, ?character:String = "bf", ?isPlayer:Bool = false)
{
super(x, y);
animOffsets = new Map<String, Array<Dynamic>>();
animOffsets = new Map<String, FlxPoint>();
curCharacter = character;
this.isPlayer = isPlayer;
@@ -73,7 +87,9 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom
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.x) globalOffset.y = Std.parseFloat(character.att.y);
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.flipX) flipX = (character.att.flipX == "true");
frames = Paths.getSparrowAtlas('characters/$curCharacter');
@@ -589,6 +605,11 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom
override function update(elapsed:Float)
{
super.update(elapsed);
if (stunned) {
__stunnedTime += elapsed;
if (__stunnedTime > 5 / 60)
stunned = false;
}
}
private var danced:Bool = false;
@@ -627,52 +648,28 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom
// nothing
}
// /**
// * DO NOT TOUCH!! FOR DRAWING STUFF
// */
// public override function isOnScreen() {
// if (flipX) {
// return super.isOnScreen();
// } else {
// return super.isOnScreen();
// }
// }
// public override function draw() {
// // doing this cause flixel have a bug with frameX not being applied correctly when sprite is flipped
// if (flipX) {
// isOnScreen
// // setting up variables
// flipX = false;
// scale.x = -scale.x;
// // drawing
// super.draw();
// // resetting variables
// scale.x = -scale.x;
// flipX = true;
// } else
// super.draw();
// }
public override function isOnScreen(?Camera:FlxCamera):Bool
{
if (Camera == null)
Camera = FlxG.camera;
getScreenPosition(_point, Camera);
return Camera.containsPoint(_point, width, height);
var __reverseDrawProcedure:Bool = false;
public override function getScreenBounds(?newRect:FlxRect, ?camera:FlxCamera):FlxRect {
if (__reverseDrawProcedure) {
scale.x *= -1;
var bounds = super.getScreenBounds(newRect, camera);
scale.x *= -1;
return bounds;
}
return super.getScreenBounds(newRect, camera);
}
public override function draw() {
if (flipX) {
dirty = true;
__reverseDrawProcedure = true;
flipX = false;
scale.x *= -1;
super.draw();
flipX = true;
scale.x *= -1;
__reverseDrawProcedure = false;
} else
super.draw();
}
@@ -682,21 +679,12 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom
animation.play(AnimName, Force, Reversed, Frame);
var daOffset = animOffsets.get(AnimName);
if (animOffsets.exists(AnimName))
{
if (isPlayer != playerOffsets) {
offset.set(-daOffset[0], daOffset[1]);
var anim = animation.getByName(AnimName);
// if (anim != null && anim.frames.length > 0) {
// offset.x -= frames.frames[anim.frames[0]].offset.x * 2;
// }
} else {
offset.set(daOffset[0], daOffset[1]);
}
}
if (daOffset != null)
offset.set(daOffset.x * (isPlayer != playerOffsets ? -1 : 1), daOffset.y);
else
offset.set(0, 0);
offset.x -= globalOffset.x;
offset.x += globalOffset.x - (isPlayer != playerOffsets ? 1 : -1);
offset.y -= globalOffset.y;
if (AnimName.startsWith("sing"))
@@ -720,8 +708,12 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom
}
}
public override function destroy() {
super.destroy();
}
public function addOffset(name:String, x:Float = 0, y:Float = 0)
{
animOffsets[name] = [x, y];
animOffsets[name] = new FlxPoint(x, y);
}
}
+43 -52
View File
@@ -90,6 +90,8 @@ class PlayState extends MusicBeatState
public var playerStrums:FlxTypedGroup<Strum>;
public var cpuStrums:FlxTypedGroup<Strum>;
public var muteVocalsOnMiss:Bool = true;
public var camZooming:Bool = false;
public var camZoomingInterval:Int = 4;
public var curSong:String = "";
@@ -843,46 +845,10 @@ class PlayState extends MusicBeatState
if (generatedMusic && PlayState.SONG.notes[Std.int(curStep / 16)] != null)
{
if (curBeat % 4 == 0)
if (PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection)
{
// trace(PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection);
}
if (camFollow.x != dad.getMidpoint().x + 150 + dad.globalOffset.x && !PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection)
{
camFollow.setPosition(dad.getMidpoint().x + 150, dad.getMidpoint().y - 100);
// camFollow.setPosition(lucky.getMidpoint().x - 120, lucky.getMidpoint().y + 210);
switch (dad.curCharacter)
{
case 'mom':
camFollow.y = dad.getMidpoint().y;
case 'senpai':
camFollow.y = dad.getMidpoint().y - 430;
camFollow.x = dad.getMidpoint().x - 100;
case 'senpai-angry':
camFollow.y = dad.getMidpoint().y - 430;
camFollow.x = dad.getMidpoint().x - 100;
}
camFollow.x += dad.globalOffset.x;
camFollow.y += dad.globalOffset.y;
if (dad.curCharacter == 'mom')
vocals.volume = 1;
if (SONG.song.toLowerCase() == 'tutorial')
{
tweenCamIn();
}
}
// TODO: redo this god forsaken system
if (PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection && camFollow.x != boyfriend.getMidpoint().x - 100 + boyfriend.globalOffset.x)
{
camFollow.setPosition(boyfriend.getMidpoint().x - 100, boyfriend.getMidpoint().y - 100);
var pos = boyfriend.getCameraPosition();
camFollow.setPosition(pos.x, pos.y);
// switch (curStage)
// {
@@ -897,14 +863,37 @@ class PlayState extends MusicBeatState
// camFollow.x = boyfriend.getMidpoint().x - 200;
// camFollow.y = boyfriend.getMidpoint().y - 200;
// }
camFollow.x += boyfriend.globalOffset.x;
camFollow.y += boyfriend.globalOffset.y;
if (SONG.song.toLowerCase() == 'tutorial')
{
FlxTween.tween(FlxG.camera, {zoom: 1}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut});
}
} else {
var pos = dad.getCameraPosition();
camFollow.setPosition(pos.x, pos.y);
// camFollow.setPosition(dad.getMidpoint().x + 150, dad.getMidpoint().y - 100);
// camFollow.setPosition(lucky.getMidpoint().x - 120, lucky.getMidpoint().y + 210);
// switch (dad.curCharacter)
// {
// case 'mom':
// camFollow.y = dad.getMidpoint().y;
// case 'senpai':
// camFollow.y = dad.getMidpoint().y - 430;
// camFollow.x = dad.getMidpoint().x - 100;
// case 'senpai-angry':
// camFollow.y = dad.getMidpoint().y - 430;
// camFollow.x = dad.getMidpoint().x - 100;
// }
if (dad.curCharacter == 'mom')
vocals.volume = 1;
if (SONG.song.toLowerCase() == 'tutorial')
{
tweenCamIn();
}
}
}
@@ -996,7 +985,11 @@ class PlayState extends MusicBeatState
if (daNote.wasGoodHit && daNote.isSustainNote && daNote.strumTime + (Conductor.stepCrochet) < Conductor.songPosition) {
deleteNote(daNote);
return;
}
}
if (daNote.tooLate) {
noteMiss(daNote);
return;
}
var strum:Strum = null;
for(e in (daNote.mustPress ? playerStrums : cpuStrums).members) {
@@ -1019,6 +1012,8 @@ class PlayState extends MusicBeatState
if (FlxG.keys.justPressed.ONE)
endSong();
#end
scripts.call("updatePost", [elapsed]);
}
function endSong():Void
@@ -1295,7 +1290,7 @@ class PlayState extends MusicBeatState
scripts.call("onKeyShitPost");
}
function noteMiss(direction:Int = 1):Void
function noteMiss(note:Note):Void
{
if (!boyfriend.stunned)
{
@@ -1312,15 +1307,10 @@ class PlayState extends MusicBeatState
// FlxG.sound.play(Paths.sound('missnote1'), 1, false);
// FlxG.log.add('played imss note');
if (muteVocalsOnMiss) vocals.volume = 0;
boyfriend.stunned = true;
// get stunned for 5 seconds
new FlxTimer().start(5 / 60, function(tmr:FlxTimer)
{
boyfriend.stunned = false;
});
switch (direction)
switch (note.strumID)
{
case 0:
boyfriend.playAnim('singLEFTmiss', true);
@@ -1331,6 +1321,7 @@ class PlayState extends MusicBeatState
case 3:
boyfriend.playAnim('singRIGHTmiss', true);
}
deleteNote(note);
}
}
+1 -1
View File
@@ -23,7 +23,7 @@ class Stage extends FlxBasic implements IBeatReceiver {
if (PlayState.instance == null) return;
stagePath = Paths.xml('stages/$stage');
try {
stageXML = new Access(Xml.parse(Assets.getText(stagePath)).firstElement());
if (Assets.exists(stagePath)) stageXML = new Access(Xml.parse(Assets.getText(stagePath)).firstElement());
} catch(e) {
// TODO: handler
trace(e.details());
+3 -1
View File
@@ -32,10 +32,12 @@ class Strum extends FlxSprite {
// TODO: angle stuff
daNote.x = x + offset.x;
daNote.y = y - offset.y;
offset.put();
}
public function updateClipRect(daNote:Note) {
if (!daNote.isSustainNote) return;
if (!daNote.isSustainNote || !daNote.wasGoodHit) return;
daNote.updateClipRect(this);
}