Skip to content

Commit

Permalink
Merge pull request #4 from Joalor64GH/main
Browse files Browse the repository at this point in the history
attempted sustain notes
  • Loading branch information
yophlox authored Oct 28, 2024
2 parents 3198482 + bf59b31 commit a5ec72a
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 44 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
name: Moon4K-Win

on:
push:
branches: [ main ]

workflow_dispatch:

jobs:
buildWindows:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4.1.7
- uses: actions/checkout@main

- uses: krdlab/setup-haxe@master
with:
haxe-version: 4.3.4
haxe-version: 4.3.6

- name: Restore Previous Cache
id: cache-build-restore
Expand All @@ -30,14 +33,11 @@ jobs:
shell: powershell

- name: Install Haxelib
run: |
haxelib setup C:/haxelib
haxelib install hxcpp > /dev/null --quiet
.\"setup/setup.bat"
run: haxe --interp -cp ./actions/libs-installer -D analyzer-optimize -main Main
- name: Create Version Tag
run: echo "${{github.run_id}}" > VERSION
- name: Compile
run: haxelib run lime build windows --app-version="4.0.0-${{ github.run_id}}" -debug
run: haxelib run lime build windows -debug

- name: Clear Previous Cache
uses: actions/github-script@main
Expand All @@ -56,7 +56,7 @@ jobs:
cache-windows-debug
- name: Publish Artifact
uses: actions/upload-artifact@v4.3.4
uses: actions/upload-artifact@main
with:
name: Moon4K-Win-Release
path: export/debug/windows/bin
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@

/export
export/
.vscode/*
index.html
style.css
converter/*.json
converter/2hot.json
source/api/gamejolt/GJKeys.hx
source/api/newgrounds/APIStuff.hx
source/states/FuckYouState.hx
/.haxelib
.haxelib/
desktop.ini
dump/

## For mac or smth
.DS_Store
34 changes: 34 additions & 0 deletions actions/libs-installer/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import sys.FileSystem;
import sys.io.File;
import haxe.Json;

typedef Library = {
var name:String;
var type:String;
var ?version:String;
var ?dir:String;
var ?ref:String;
var ?url:String;
}

class Main {
public static function main():Void {
if (!FileSystem.exists('.haxelib'))
FileSystem.createDirectory('.haxelib');

final json:Array<Library> = Json.parse(File.getContent('./hmm.json')).dependencies;

for (lib in json) {
switch (lib.type) {
case "haxelib":
Sys.command('haxelib --quiet install ${lib.name} ${lib.version != null ? lib.version : ""}');
case "git":
Sys.command('haxelib --quiet git ${lib.name} ${lib.url}');
default:
Sys.println('Cannot resolve library of type "${lib.type}"');
}
}

Sys.exit(0);
}
}
13 changes: 5 additions & 8 deletions assets/images/ui-skins/default/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
["up static0", "up press0", "up confirm0", "up note0"],
["right static0", "right press0", "right confirm0", "right note0"],
["middle static0", "middle press0", "middle confirm0", "middle note0"],
["left static0", "left press0", "left confirm0", "left note0"],
["down static0", "down press0", "down confirm0", "down note0"],
["up static0", "up press0", "up confirm0", "up note0"],
["right static0", "right press0", "right confirm0", "right note0"],
["left hold", "left hold end"],
["down hold", "down hold end"],
["up hold", "up hold end"],
["right hold", "right hold end"]
["left hold0", "left hold end0"],
["down hold0", "down hold end0"],
["up hold0", "up hold end0"],
["right hold0", "right hold end0"],
["middle hold0", "middle hold end0"]
],
"name": "Arrows",
"size": 0.7,
Expand Down
27 changes: 9 additions & 18 deletions hmm.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@
"dependencies": [
{
"name": "flixel",
"type": "haxelib",
"version": null
"type": "haxelib"
},
{
"name": "flixel-addons",
"type": "haxelib",
"version": null
"type": "haxelib"
},
{
"name": "flixel-tools",
"type": "haxelib",
"version": null
"type": "haxelib"
},
{
"name": "flixel-ui",
"type": "haxelib",
"version": null
"type": "haxelib"
},
{
"name": "funkin.vis",
Expand Down Expand Up @@ -50,28 +46,23 @@
},
{
"name": "hxcpp",
"type": "haxelib",
"version": null
"type": "haxelib"
},
{
"name": "hxcpp-debug-server",
"type": "haxelib",
"version": null
"type": "haxelib"
},
{
"name": "hxdiscord_rpc",
"type": "haxelib",
"version": null
"type": "haxelib"
},
{
"name": "lime",
"type": "haxelib",
"version": null
"type": "haxelib"
},
{
"name": "openfl",
"type": "haxelib",
"version": null
"type": "haxelib"
}
]
}
2 changes: 1 addition & 1 deletion source/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class Paths {
localTrackedAssets.push(path);
return currentTrackedAssets.get(path);
}
trace('oh no its returning null NOOOO');
trace('oh no its returning null NOOOO: $key');
trace('Code is Misfireing');
trace('Reloading Null BitmapData');
return null;
Expand Down
24 changes: 20 additions & 4 deletions source/game/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class Note extends FlxSprite {

public var strum:Float = 0.0;
public var isSustainNote:Bool = false;
public var isEndNote:Bool = false;
public var shouldHit:Bool = true;
public var sustainLength:Float = 0;

Expand All @@ -40,15 +39,13 @@ class Note extends FlxSprite {

public var offsets = [0, 0];

public function new(x, y, direction:Int = 0, ?strum:Float, ?noteskin:String = 'default', ?isSustainNote:Bool = false, ?isEndNote:Bool = false,
?keyCount:Int = 4) {
public function new(x, y, direction:Int = 0, ?strum:Float, ?noteskin:String = 'default', ?isSustainNote:Bool = false, ?keyCount:Int = 4) {
super(x, y);

this.noteskin = noteskin;
this.direction = direction;
this.strum = strum;
this.isSustainNote = isSustainNote;
this.isEndNote = isEndNote;
this.keyCount = keyCount;

loadNoteSkin(noteskin, direction);
Expand Down Expand Up @@ -83,6 +80,8 @@ class Note extends FlxSprite {
animation.addByPrefix("press", json.animations[direction][1], json.framerate, false);
animation.addByPrefix("confirm", json.animations[direction][2], json.framerate, false);
animation.addByPrefix("note", json.animations[direction][3], json.framerate, false);
animation.addByPrefix("hold", json.animations[direction + 5][0], json.framerate, false);
animation.addByPrefix("holdend", json.animations[direction + 5][1], json.framerate, false);

if (json.antialiasing == true)
antialiasing = Options.getData('antialiasing');
Expand All @@ -93,6 +92,23 @@ class Note extends FlxSprite {
updateHitbox();

playAnim("note");

if (isSustainNote && lastNote != null) {
alpha = 0.6;
x += width / 2;

playAnim("holdend");
updateHitbox();

x -= width / 2;

if (lastNote.isSustainNote) {
lastNote.playAnim("hold");

lastNote.scale.y *= Conductor.stepCrochet / 100 * 1.5 * PlayState.instance.speed;
lastNote.updateHitbox();
}
}
}

public function playAnim(anim:String, ?force:Bool = false) {
Expand Down
40 changes: 39 additions & 1 deletion source/states/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class ChartingState extends SwagState {
var beatSnap:Int = 16;

var renderedNotes:FlxTypedGroup<Note>;
var renderedSustains:FlxTypedGroup<FlxSprite>;

public var song:SwagSong;

Expand Down Expand Up @@ -79,6 +80,8 @@ class ChartingState extends SwagState {
var songInfoText:FlxText;

override public function create() {
FlxG.mouse.visible = true;

FlxG.stage.window.title = "Moon4K - ChartingState";
#if desktop
Discord.changePresence("Charting: " + song.song, null);
Expand All @@ -101,6 +104,9 @@ class ChartingState extends SwagState {
renderedNotes = new FlxTypedGroup<Note>();
add(renderedNotes);

renderedSustains = new FlxTypedGroup<FlxSprite>();
add(renderedSustains);

addSection();
updateGrid();

Expand Down Expand Up @@ -222,10 +228,20 @@ class ChartingState extends SwagState {
changeSection(curSection + 1);

if (FlxG.keys.justPressed.ENTER) {
FlxG.mouse.visible = false;
transitionState(new PlayState());
PlayState.instance.song = song;
}

if (FlxG.keys.justPressed.E)
{
changeNoteSustain(Conductor.stepCrochet);
}
if (FlxG.keys.justPressed.Q)
{
changeNoteSustain(-Conductor.stepCrochet);
}

if (FlxG.keys.justPressed.SPACE) {
if (FlxG.sound.music.playing) {
FlxG.sound.music.pause();
Expand Down Expand Up @@ -347,6 +363,15 @@ class ChartingState extends SwagState {
updateGrid();
}

function changeNoteSustain(value:Float):Void {
if (curSelectedNote != null) {
curSelectedNote.noteSus += value;
curSelectedNote.noteSus = Math.max(curSelectedNote.noteSus, 0);
}

updateGrid();
}

function deleteNote(note:Note):Void {
for (sectionNote in song.notes[curSection].sectionNotes) {
if (sectionNote.noteStrum == note.strum && sectionNote.noteData == note.rawNoteData) {
Expand Down Expand Up @@ -379,8 +404,15 @@ class ChartingState extends SwagState {

renderedNotes.clear();

while (renderedSustains.members.length > 0)
{
renderedSustains.remove(renderedSustains.members[0], true);
}

for (sectionNote in song.notes[curSection].sectionNotes) {
var note:Note = new Note(0, 0, sectionNote.noteData % song.keyCount, sectionNote.noteStrum, "default", false, false, song.keyCount);
var daSus = sectionNote.noteSus;
var note:Note = new Note(0, 0, sectionNote.noteData % song.keyCount, sectionNote.noteStrum, "default", false, song.keyCount);
note.sustainLength = daSus;

note.setGraphicSize(gridSize, gridSize);
note.updateHitbox();
Expand All @@ -391,6 +423,12 @@ class ChartingState extends SwagState {
note.rawNoteData = sectionNote.noteData;

renderedNotes.add(note);

if (daSus > 0) {
var sustainVis:FlxSprite = new FlxSprite(note.x + (gridSize / 2),
note.y + gridSize).makeGraphic(8, Math.floor(FlxMath.remapToRange(daSus, 0, Conductor.stepCrochet * 16, 0, gridBG.height)));
renderedSustains.add(sustainVis);
}
}
}

Expand Down
15 changes: 13 additions & 2 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -735,14 +735,25 @@ class PlayState extends SwagState {
else
oldNote = null;

var swagNote:Note = new Note(strum.x, strum.y, daNoteData, daStrumTime, Options.getNoteskins()[Options.getData("ui-skin")], false, false,
keyCount);
var swagNote:Note = new Note(strum.x, strum.y, daNoteData, daStrumTime, Options.getNoteskins()[Options.getData("ui-skin")], false, keyCount);
swagNote.sustainLength = note.noteSus;
swagNote.scrollFactor.set();
swagNote.lastNote = oldNote;

swagNote.playAnim('note');

var susLength:Float = swagNote.sustainLength;
susLength = susLength / Conductor.stepCrochet;

spawnNotes.push(swagNote);

for (susNote in 0...Math.floor(susLength)) {
oldNote = spawnNotes[Std.int(spawnNotes.length - 1)];

var sustainNote:Note = new Note(strum.x, strum.y, daNoteData, daStrumTime + (Conductor.stepCrochet * susNote) + Conductor.stepCrochet, Options.getNoteskins()[Options.getData("ui-skin")], true, keyCount);
sustainNote.scrollFactor.set();
spawnNotes.push(sustainNote);
}
}
}

Expand Down

0 comments on commit a5ec72a

Please sign in to comment.