Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
375ae0f
Initial Arrow System Creation
collectioncard Jan 29, 2025
d19f173
Node restructuring and make noteManager
collectioncard Jan 29, 2025
6c785fa
Make note creation functions return their note obj
collectioncard Jan 30, 2025
8fed186
Merge pull request #26 from Project-Funk-Engine/note-system
LifeHckr Jan 30, 2025
560d062
Testing Chart Background Looping
LifeHckr Jan 29, 2025
61f18db
Initial Complete Chart Looping
LifeHckr Jan 30, 2025
f20cedb
Integrated Notes and Chart
LifeHckr Jan 30, 2025
38c5ff1
Merge pull request #27 from Project-Funk-Engine/S1-ChartLooping
LifeHckr Jan 30, 2025
6b2eee8
Created input and timing
Rmojarro1 Jan 31, 2025
21fe9de
HealthBar display and script
Rmojarro1 Jan 29, 2025
4f37572
Made HealthBar tscn
Rmojarro1 Jan 30, 2025
4b23be9
Linked notes to player health, made enemy
Rmojarro1 Jan 31, 2025
51ae9ef
Reworked, see description
LifeHckr Jan 31, 2025
2f03e1d
Merge pull request #28 from Project-Funk-Engine/healthBar
LifeHckr Jan 31, 2025
f2a04e2
Refactor HP Bars
LifeHckr Jan 31, 2025
b8e7d9a
Simplified health bars
LifeHckr Jan 31, 2025
212f95d
Refactoring
LifeHckr Jan 31, 2025
9b9a4fb
Merge pull request #29 from Project-Funk-Engine/InputTiming
LifeHckr Jan 31, 2025
62da2f7
player can place notes
cornerloan Feb 1, 2025
1ff43a6
note placement bar implemented and working - placed notes are uninter…
cornerloan Feb 3, 2025
34293ff
Initial tweaks and fixes
LifeHckr Feb 3, 2025
993b9c1
Merge pull request #30 from Project-Funk-Engine/player-adding-notes
LifeHckr Feb 3, 2025
1f507de
Consolidated into single lane structure
LifeHckr Feb 1, 2025
e3070c2
Organization
LifeHckr Feb 1, 2025
5585c4b
More effectively handle looping
LifeHckr Feb 1, 2025
d8bb0c5
Simplify arrow creation
LifeHckr Feb 1, 2025
b8c7ea1
Adding visuals
LifeHckr Feb 3, 2025
5b17978
Integrate and adjust NPB
LifeHckr Feb 3, 2025
252a9ac
Adding notes fixes
LifeHckr Feb 3, 2025
27e0ffa
Reworking and some juice
LifeHckr Feb 4, 2025
bba4b9c
Finalize for Sprint 1
LifeHckr Feb 4, 2025
c5cf3b3
Merge pull request #38 from Project-Funk-Engine/rewrite
LifeHckr Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Audio/335571__magntron__gamemusic_120bpm.mp3
Binary file not shown.
19 changes: 19 additions & 0 deletions Audio/335571__magntron__gamemusic_120bpm.mp3.import
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
18 changes: 18 additions & 0 deletions Classes/Note.cs
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;
}
}
3 changes: 3 additions & 0 deletions Funk Engine.sln.DotSettings.user
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>
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ Current team members include:



#### Attributions:
Note icon: <a href="https://www.flaticon.com/free-icons/next" title="next icons">Next icons created by Pixel perfect - Flaticon</a>


41 changes: 40 additions & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ config_version=5
[application]

config/name="Funk Engine"
run/main_scene="res://scenes/main.tscn"
run/main_scene="res://scenes/BattleDirector/test_battle_scene.tscn"
config/features=PackedStringArray("4.3", "C#", "Forward Plus")
config/icon="res://icon.svg"

[autoload]

TimeKeeper="*res://scripts/TimeKeeper.cs"

[display]

window/size/viewport_width=640
Expand All @@ -25,3 +29,38 @@ window/stretch/scale_mode="integer"
[dotnet]

project/assembly_name="Funk Engine"

[input]

arrowUp={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
arrowDown={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
arrowLeft={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
arrowRight={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
]
}

[rendering]

textures/canvas_textures/default_texture_filter=0

[threading]

worker_pool/canvas_textures/default_texture_filter=1
277 changes: 277 additions & 0 deletions scenes/BattleDirector/BattleDirector.cs
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();
}
}
}
Loading