-
Notifications
You must be signed in to change notification settings - Fork 0
Merge Final Sprint 1 Playable into Main! #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
375ae0f
Initial Arrow System Creation
collectioncard d19f173
Node restructuring and make noteManager
collectioncard 6c785fa
Make note creation functions return their note obj
collectioncard 8fed186
Merge pull request #26 from Project-Funk-Engine/note-system
LifeHckr 560d062
Testing Chart Background Looping
LifeHckr 61f18db
Initial Complete Chart Looping
LifeHckr f20cedb
Integrated Notes and Chart
LifeHckr 38c5ff1
Merge pull request #27 from Project-Funk-Engine/S1-ChartLooping
LifeHckr 6b2eee8
Created input and timing
Rmojarro1 21fe9de
HealthBar display and script
Rmojarro1 4f37572
Made HealthBar tscn
Rmojarro1 4b23be9
Linked notes to player health, made enemy
Rmojarro1 51ae9ef
Reworked, see description
LifeHckr 2f03e1d
Merge pull request #28 from Project-Funk-Engine/healthBar
LifeHckr f2a04e2
Refactor HP Bars
LifeHckr b8e7d9a
Simplified health bars
LifeHckr 212f95d
Refactoring
LifeHckr 9b9a4fb
Merge pull request #29 from Project-Funk-Engine/InputTiming
LifeHckr 62da2f7
player can place notes
cornerloan 1ff43a6
note placement bar implemented and working - placed notes are uninter…
cornerloan 34293ff
Initial tweaks and fixes
LifeHckr 993b9c1
Merge pull request #30 from Project-Funk-Engine/player-adding-notes
LifeHckr 1f507de
Consolidated into single lane structure
LifeHckr e3070c2
Organization
LifeHckr 5585c4b
More effectively handle looping
LifeHckr d8bb0c5
Simplify arrow creation
LifeHckr b8c7ea1
Adding visuals
LifeHckr 5b17978
Integrate and adjust NPB
LifeHckr 252a9ac
Adding notes fixes
LifeHckr 27e0ffa
Reworking and some juice
LifeHckr bba4b9c
Finalize for Sprint 1
LifeHckr c5cf3b3
Merge pull request #38 from Project-Funk-Engine/rewrite
LifeHckr c53988c
Add Asset Background
LifeHckr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| [remap] | ||
|
|
||
| importer="mp3" | ||
| type="AudioStreamMP3" | ||
| uid="uid://cv6lqjj6lu36h" | ||
| path="res://.godot/imported/335571__magntron__gamemusic_120bpm.mp3-a87b357c4b3c9199709863b47f78bd2a.mp3str" | ||
|
|
||
| [deps] | ||
|
|
||
| source_file="res://Audio/335571__magntron__gamemusic_120bpm.mp3" | ||
| dest_files=["res://.godot/imported/335571__magntron__gamemusic_120bpm.mp3-a87b357c4b3c9199709863b47f78bd2a.mp3str"] | ||
|
|
||
| [params] | ||
|
|
||
| loop=true | ||
| loop_offset=0 | ||
| bpm=0 | ||
| beat_count=0 | ||
| bar_beats=4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| using System; | ||
| using Godot; | ||
|
|
||
| /** | ||
| * @class Note | ||
| * @brief Data structure class for holding data and methods for a battle time note. WIP | ||
| */ | ||
| public partial class Note : Resource | ||
| { | ||
| public int Beat; | ||
| public NoteArrow.ArrowType Type; | ||
|
|
||
| public Note(NoteArrow.ArrowType type = NoteArrow.ArrowType.Up, int beat = 0) | ||
| { | ||
| Beat = beat; | ||
| Type = type; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
| <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003Fgamef_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F6354a7b35d7821629924d3676acd7e67a6f7f94343e0e66ec439aa2bd6ed5_003FThrowHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> | ||
| <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F6354a7b35d7821629924d3676acd7e67a6f7f94343e0e66ec439aa2bd6ed5_003FThrowHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary> |
collectioncard marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,277 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics; | ||
| using System.Linq; | ||
| using Godot; | ||
|
|
||
| /** | ||
| * @class BattleDirector | ||
| * @brief Higher priority director to manage battle effects. Can directly access managers, which should signal up to Director WIP | ||
| */ | ||
| public partial class BattleDirector : Node2D | ||
| { | ||
| #region Declarations | ||
| private HealthBar Player; | ||
| private HealthBar Enemy; | ||
|
|
||
| [Export] | ||
| private ChartManager CM; | ||
|
|
||
| [Export] | ||
| private InputHandler IH; | ||
|
|
||
| [Export] | ||
| private NotePlacementBar NotePlacementBar; | ||
|
|
||
| [Export] | ||
| private AudioStreamPlayer Audio; | ||
|
|
||
| private double _timingInterval = .1; //secs | ||
|
|
||
| [Signal] | ||
| public delegate void PlayerDamageEventHandler(int damage); | ||
|
|
||
| [Signal] | ||
| public delegate void EnemyDamageEventHandler(int damage); | ||
|
|
||
| private SongData _curSong; | ||
|
|
||
| public struct SongData | ||
| { | ||
| public int Bpm; | ||
| public double SongLength; | ||
| public int NumLoops; | ||
| } | ||
| #endregion | ||
|
|
||
| #region Note Handling | ||
| //Assume queue structure for notes in each lane. | ||
| //Can eventually make this its own structure | ||
| private NoteArrow[][] _laneData = Array.Empty<NoteArrow[]>(); | ||
| private int[] _laneLastBeat = new int[] | ||
| { //Temporary (hopefully) measure to bridge from note queue structure to ordered array | ||
| 0, | ||
| 0, | ||
| 0, | ||
| 0, | ||
| }; | ||
| private Note[] _notes = Array.Empty<Note>(); | ||
|
|
||
| //Returns first note of lane without modifying lane data | ||
| private Note GetNoteAt(NoteArrow.ArrowType dir, int beat) | ||
| { | ||
| return GetNote(_laneData[(int)dir][beat]); | ||
| } | ||
|
|
||
| //Get note of a note arrow | ||
| private Note GetNote(NoteArrow arrow) | ||
| { | ||
| return _notes[arrow.NoteIdx]; | ||
| } | ||
|
|
||
| private bool AddNoteToLane(Note note, bool isActive = true) | ||
| { | ||
| note.Beat %= CM.BeatsPerLoop; | ||
| //Don't add dupe notes | ||
| if (note.Beat == 0 || _notes.Any(nt => nt.Type == note.Type && nt.Beat == note.Beat)) | ||
| { | ||
| return false; //Beat at 0 is too messy. | ||
| } | ||
| _notes = _notes.Append(note).ToArray(); | ||
| //Get noteArrow from CM | ||
| var arrow = CM.AddArrowToLane(note, _notes.Length - 1); | ||
| arrow.IsActive = isActive; | ||
| _laneData[(int)note.Type][note.Beat] = arrow; | ||
| return true; | ||
| } | ||
| #endregion | ||
|
|
||
| //Creeate dummy notes | ||
| private void AddExampleNotes() | ||
| { | ||
| GD.Print(CM.BeatsPerLoop); | ||
| for (int i = 1; i < 15; i++) | ||
| { | ||
| Note exampleNote = new Note(NoteArrow.ArrowType.Up, i * 4); | ||
| AddNoteToLane(exampleNote); | ||
| } | ||
| for (int i = 1; i < 15; i++) | ||
| { | ||
| Note exampleNote = new Note(NoteArrow.ArrowType.Left, 4 * i + 1); | ||
| AddNoteToLane(exampleNote); | ||
| } | ||
| for (int i = 0; i < 10; i++) | ||
| { | ||
| Note exampleNote = new Note(NoteArrow.ArrowType.Right, 3 * i + 32); | ||
| AddNoteToLane(exampleNote); | ||
| } | ||
| for (int i = 0; i < 3; i++) | ||
| { | ||
| Note exampleNote = new Note(NoteArrow.ArrowType.Down, 8 * i + 16); | ||
| AddNoteToLane(exampleNote); | ||
| } | ||
| } | ||
|
|
||
| public override void _Ready() | ||
| { | ||
| _curSong = new SongData | ||
| { | ||
| Bpm = 120, | ||
| SongLength = Audio.Stream.GetLength(), | ||
| NumLoops = 5, | ||
| }; | ||
|
|
||
| var timer = GetTree().CreateTimer(AudioServer.GetTimeToNextMix()); | ||
| timer.Timeout += Begin; | ||
| } | ||
|
|
||
| private void Begin() | ||
| { | ||
| CM.PrepChart(_curSong); | ||
| _laneData = new NoteArrow[][] | ||
| { | ||
| new NoteArrow[CM.BeatsPerLoop], | ||
| new NoteArrow[CM.BeatsPerLoop], | ||
| new NoteArrow[CM.BeatsPerLoop], | ||
| new NoteArrow[CM.BeatsPerLoop], | ||
| }; | ||
| AddExampleNotes(); | ||
|
|
||
| Player = GetNode<HealthBar>("PlayerHP"); | ||
| Player.GetNode<Sprite2D>("Sprite2D").Scale *= .5f; //TEMP | ||
| Player.GetNode<Sprite2D>("Sprite2D").Position += Vector2.Down * 30; //TEMP | ||
| Enemy = GetNode<HealthBar>("EnemyHP"); | ||
|
|
||
| //TEMP | ||
| var enemTween = CreateTween(); | ||
| enemTween | ||
| .TweenProperty(Enemy.GetNode<Sprite2D>("Sprite2D"), "position", Vector2.Down * 5, 1f) | ||
| .AsRelative(); | ||
| enemTween | ||
| .TweenProperty(Enemy.GetNode<Sprite2D>("Sprite2D"), "position", Vector2.Up * 5, 1f) | ||
| .AsRelative(); | ||
| enemTween.SetTrans(Tween.TransitionType.Spring); | ||
| enemTween.SetEase(Tween.EaseType.In); | ||
| enemTween.SetLoops(); | ||
| enemTween.Play(); | ||
|
|
||
| CM.Connect(nameof(InputHandler.NotePressed), new Callable(this, nameof(OnNotePressed))); | ||
| CM.Connect(nameof(InputHandler.NoteReleased), new Callable(this, nameof(OnNoteReleased))); | ||
|
|
||
| Audio.Play(); | ||
| } | ||
|
|
||
| public override void _Process(double delta) | ||
| { | ||
| TimeKeeper.CurrentTime = Audio.GetPlaybackPosition(); | ||
| CheckMiss(); | ||
| } | ||
|
|
||
| #region Input&Timing | ||
| private void OnNotePressed(NoteArrow.ArrowType type) | ||
| { | ||
| CheckNoteTiming(type); | ||
| } | ||
|
|
||
| private void OnNoteReleased(NoteArrow.ArrowType arrowType) { } | ||
|
|
||
| //Check all lanes for misses from missed inputs | ||
| private void CheckMiss() | ||
| { | ||
| //On current beat, if prev beat is active and not inputted | ||
| double realBeat = TimeKeeper.CurrentTime / (60 / (double)_curSong.Bpm) % CM.BeatsPerLoop; | ||
| for (int i = 0; i < _laneData.Length; i++) | ||
| { | ||
| if ( | ||
| _laneLastBeat[i] < Math.Floor(realBeat) | ||
| || (_laneLastBeat[i] == CM.BeatsPerLoop - 1 && Math.Floor(realBeat) == 0) | ||
| ) | ||
| { //If above, a note has been missed | ||
| //GD.Print("Last beat " + _laneLastBeat[i]); | ||
| if ( | ||
| _laneData[i][_laneLastBeat[i]] == null | ||
| || !_laneData[i][_laneLastBeat[i]].IsActive | ||
| ) | ||
| { | ||
| _laneLastBeat[i] = (_laneLastBeat[i] + 1) % CM.BeatsPerLoop; | ||
| continue; | ||
| } | ||
| //Note exists and has been missed | ||
| _laneData[i][_laneLastBeat[i]].NoteHit(); | ||
| HandleTiming((NoteArrow.ArrowType)i, 1); | ||
| _laneLastBeat[i] = (_laneLastBeat[i] + 1) % CM.BeatsPerLoop; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private void CheckNoteTiming(NoteArrow.ArrowType type) | ||
| { | ||
| double realBeat = TimeKeeper.CurrentTime / (60 / (double)_curSong.Bpm) % CM.BeatsPerLoop; | ||
| int curBeat = (int)Math.Round(realBeat); | ||
| GD.Print("Cur beat " + curBeat + "Real: " + realBeat.ToString("#.###")); | ||
| if ( | ||
| _laneData[(int)type][curBeat % CM.BeatsPerLoop] == null | ||
| || !_laneData[(int)type][curBeat % CM.BeatsPerLoop].IsActive | ||
| ) | ||
| { | ||
| _laneLastBeat[(int)type] = (curBeat) % CM.BeatsPerLoop; | ||
| PlayerAddNote(type, curBeat); | ||
| return; | ||
| } | ||
| double beatDif = Math.Abs(realBeat - curBeat); | ||
| _laneData[(int)type][curBeat % CM.BeatsPerLoop].NoteHit(); | ||
| _laneLastBeat[(int)type] = (curBeat) % CM.BeatsPerLoop; | ||
| HandleTiming(type, beatDif); | ||
| } | ||
|
|
||
| private void HandleTiming(NoteArrow.ArrowType type, double beatDif) | ||
| { | ||
| if (beatDif < _timingInterval * 1) | ||
| { | ||
| GD.Print("Perfect"); | ||
| Enemy.TakeDamage(3); | ||
| NotePlacementBar.HitNote(); | ||
| NotePlacementBar.ComboText("Perfect!"); | ||
| } | ||
| else if (beatDif < _timingInterval * 2) | ||
| { | ||
| GD.Print("Good"); | ||
| Enemy.TakeDamage(1); | ||
| NotePlacementBar.HitNote(); | ||
| NotePlacementBar.ComboText("Good"); | ||
| } | ||
| else if (beatDif < _timingInterval * 3) | ||
| { | ||
| GD.Print("Ok"); | ||
| Player.TakeDamage(1); | ||
| NotePlacementBar.HitNote(); | ||
| NotePlacementBar.ComboText("Okay"); | ||
| } | ||
| else | ||
| { | ||
| GD.Print("Miss"); | ||
| Player.TakeDamage(2); | ||
| NotePlacementBar.MissNote(); | ||
| NotePlacementBar.ComboText("Miss"); | ||
| } | ||
| } | ||
| #endregion | ||
|
|
||
| private void PlayerAddNote(NoteArrow.ArrowType type, int beat) | ||
| { | ||
| // can also add some sort of keybind here to also have pressed | ||
| // in case the user just presses the note too early and spawns a note | ||
| GD.Print( | ||
| $"Player trying to place {type} typed note at beat: " | ||
| + beat | ||
| + " Verdict: " | ||
| + NotePlacementBar.CanPlaceNote() | ||
| ); | ||
| if (NotePlacementBar.CanPlaceNote()) | ||
| { | ||
| Note exampleNote = new Note(type, beat % CM.BeatsPerLoop); | ||
| if (AddNoteToLane(exampleNote, false)) | ||
| NotePlacementBar.PlacedNote(); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.