From 1a9dfbaabca3a1b153fc6ed876d497f36c354b52 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Sat, 5 Nov 2022 01:23:09 +0100 Subject: [PATCH] some cool stuff --- assets/data/charts/test/modchart.hx | 8 ++++++++ buildnumber.txt | 2 +- source/funkin/game/Character.hx | 12 +++++------- source/funkin/game/Note.hx | 7 +++++-- source/funkin/game/PlayState.hx | 10 +++++----- source/funkin/scripting/events/NoteCreationEvent.hx | 8 +++++++- source/funkin/scripting/events/NoteHitEvent.hx | 7 ++++++- 7 files changed, 37 insertions(+), 17 deletions(-) diff --git a/assets/data/charts/test/modchart.hx b/assets/data/charts/test/modchart.hx index 26fcdcd0..1aa48d27 100644 --- a/assets/data/charts/test/modchart.hx +++ b/assets/data/charts/test/modchart.hx @@ -1,4 +1,12 @@ function create() { importScript("data/scripts/pixel"); pixelNotesForBF = false; +} + +function updatePost(elapsed) { + var sin = Math.sin(curBeatFloat * Math.PI / 2); + var cos = Math.cos(curBeatFloat * Math.PI / 2); + + boyfriend.angle = sin * 15; + dad.angle = sin * -15; } \ No newline at end of file diff --git a/buildnumber.txt b/buildnumber.txt index 5642d7e4..304a6a57 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -1106 \ No newline at end of file +1109 \ No newline at end of file diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index 30863a5b..24b510cd 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -81,7 +81,6 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom curCharacter = character; this.isPlayer = isPlayer; - var tex:FlxAtlasFrames; antialiasing = true; while(true) { @@ -117,7 +116,7 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom if (xml.has.flipX) flipX = (xml.att.flipX == "true"); if (xml.has.icon) icon = xml.att.icon; - frames = Paths.getSparrowAtlas('characters/$curCharacter'); + frames = CoolUtil.loadFrames(Paths.image('characters/$curCharacter')); for(anim in xml.nodes.anim) { XMLUtil.addXMLAnimation(this, anim); } @@ -379,18 +378,17 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom script.call("onPlayAnim", [event]); - if (event.cancelled || event.animName == null) return; + if (event.cancelled || event.animName == null || !animation.exists(event.animName)) return; animation.play(event.animName, event.force, event.reverse, event.startingFrame); var daOffset = animOffsets.get(event.animName); if (daOffset != null) - offset.set(daOffset.x * (isPlayer != playerOffsets ? -1 : 1), daOffset.y); + rotOffset.set(daOffset.x * (isPlayer != playerOffsets ? -1 : 1), daOffset.y); else - offset.set(0, 0); + rotOffset.set(0, 0); - offset.x += globalOffset.x * (isPlayer != playerOffsets ? 1 : -1); - offset.y -= globalOffset.y; + offset.set(globalOffset.x * (isPlayer != playerOffsets ? 1 : -1), -globalOffset.y); if (event.animName.startsWith("sing")) lastHit = Conductor.songPosition; diff --git a/source/funkin/game/Note.hx b/source/funkin/game/Note.hx index 47ab06fe..89b00a17 100644 --- a/source/funkin/game/Note.hx +++ b/source/funkin/game/Note.hx @@ -66,7 +66,9 @@ class Note extends FlxSprite public static var swagWidth:Float = 160 * 0.7; - public function new(strumTime:Float, noteData:Int, noteType:Int = 0, mustPress:Bool = true, ?prevNote:Note, ?sustainNote:Bool = false) + public var animSuffix:String = ""; + + public function new(strumTime:Float, noteData:Int, noteType:Int = 0, mustPress:Bool = true, ?prevNote:Note, ?sustainNote:Bool = false, animSuffix:String = "") { super(); @@ -85,11 +87,12 @@ class Note extends FlxSprite this.noteData = noteData; - var event = new NoteCreationEvent(this, strumID, this.noteType, noteTypeID, mustPress, "game/NOTE_assets", 0.7); + var event = new NoteCreationEvent(this, strumID, this.noteType, noteTypeID, mustPress, "game/NOTE_assets", 0.7, animSuffix); if (PlayState.instance != null) event = PlayState.instance.scripts.event("onNoteCreation", event); + this.animSuffix = event.animSuffix; if (!event.cancelled) { switch (event.noteType) { diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index d7f3f561..89110717 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -477,7 +477,7 @@ class PlayState extends MusicBeatState else swagNote = null; - swagNote.nextNote = (swagNote = new Note(daStrumTime, daNoteData % 4, daNoteType, gottaHitNote, swagNote)); + swagNote.nextNote = (swagNote = new Note(daStrumTime, daNoteData % 4, daNoteType, gottaHitNote, swagNote, false, section.altAnim ? "-alt" : "")); swagNote.sustainLength = songNotes[2]; swagNote.scrollFactor.set(0, 0); swagNote.stepLength = stepCrochet; @@ -490,7 +490,7 @@ class PlayState extends MusicBeatState // create sustains for (susNote in 0...Math.floor(susLength)) { - swagNote = new Note(daStrumTime + (stepCrochet * susNote), daNoteData % 4, daNoteType, gottaHitNote, swagNote, true); + swagNote = new Note(daStrumTime + (stepCrochet * susNote), daNoteData % 4, daNoteType, gottaHitNote, swagNote, true, section.altAnim ? "-alt" : ""); swagNote.scrollFactor.set(); swagNote.stepLength = stepCrochet; notes.add(swagNote); @@ -1302,9 +1302,9 @@ class PlayState extends MusicBeatState var event:NoteHitEvent; if (note.mustPress) - event = scripts.event("onPlayerHit", new NoteHitEvent(note, boyfriend, true, note.noteType, note.strumID, note.noteData > 0 ? 0.023 : 0.004)); + event = scripts.event("onPlayerHit", new NoteHitEvent(note, boyfriend, true, note.noteType, note.strumID, note.noteData > 0 ? 0.023 : 0.004, note.animSuffix)); else - event = scripts.event("onDadHit", new NoteHitEvent(note, dad, false, note.noteType, note.strumID, 0)); + event = scripts.event("onDadHit", new NoteHitEvent(note, dad, false, note.noteType, note.strumID, 0, note.animSuffix)); if (!event.cancelled) { if (event.player && !note.isSustainNote) @@ -1316,7 +1316,7 @@ class PlayState extends MusicBeatState health += event.healthGain; if (!event.animCancelled) { - event.character.playSingAnim(event.direction); + event.character.playSingAnim(event.direction, event.animSuffix); } (event.player ? playerStrums : cpuStrums).forEach(function(str:Strum) { diff --git a/source/funkin/scripting/events/NoteCreationEvent.hx b/source/funkin/scripting/events/NoteCreationEvent.hx index b2b6d7f4..b08ddf70 100644 --- a/source/funkin/scripting/events/NoteCreationEvent.hx +++ b/source/funkin/scripting/events/NoteCreationEvent.hx @@ -38,6 +38,11 @@ class NoteCreationEvent extends CancellableEvent { */ public var noteScale:Float; + /** + * Sing animation suffix. "-alt" for alt anim or "" for normal notes. + */ + public var animSuffix:String; + /** * [Description] Creates a new NoteCreationEvent * @param note @@ -46,7 +51,7 @@ class NoteCreationEvent extends CancellableEvent { * @param noteTypeID * @param mustHit */ - public function new(note:Note, strumID:Int, noteType:String, noteTypeID:Int, mustHit:Bool, noteSprite:String, noteScale:Float) { + public function new(note:Note, strumID:Int, noteType:String, noteTypeID:Int, mustHit:Bool, noteSprite:String, noteScale:Float, animSuffix:String) { super(); this.note = note; this.strumID = strumID; @@ -55,5 +60,6 @@ class NoteCreationEvent extends CancellableEvent { this.mustHit = mustHit; this.noteSprite = noteSprite; this.noteScale = noteScale; + this.animSuffix = animSuffix; } } \ No newline at end of file diff --git a/source/funkin/scripting/events/NoteHitEvent.hx b/source/funkin/scripting/events/NoteHitEvent.hx index f416b299..858b38c9 100644 --- a/source/funkin/scripting/events/NoteHitEvent.hx +++ b/source/funkin/scripting/events/NoteHitEvent.hx @@ -30,6 +30,10 @@ class NoteHitEvent extends CancellableEvent { * Note Type name (null if default note) */ public var noteType:String; + /** + * Suffix of the animation. "-alt" for alt notes, "" for normal ones. + */ + public var animSuffix:String; /** * Direction of the press (0 = Left, 1 = Down, 2 = Up, 3 = Right) */ @@ -46,7 +50,7 @@ class NoteHitEvent extends CancellableEvent { /** * Creates a new NoteHitEvent. */ - public function new(note:Note, character:Character, player:Bool, noteType:String, direction:Int, healthGain:Float, unmuteVocals:Bool = true, score:Int = 350) { + public function new(note:Note, character:Character, player:Bool, noteType:String, direction:Int, healthGain:Float, unmuteVocals:Bool = true, score:Int = 350, animSuffix:String = "") { super(); this.note = note; @@ -57,6 +61,7 @@ class NoteHitEvent extends CancellableEvent { this.healthGain = healthGain; this.unmuteVocals = unmuteVocals; this.score = score; + this.animSuffix = animSuffix; } /**