Skip to content

Commit

Permalink
Merge pull request #82 from neogeek/feature/godot-cpp-plugin
Browse files Browse the repository at this point in the history
[feat] Godot GDExtension Plugin
  • Loading branch information
neogeek authored Nov 8, 2024
2 parents 79f2a0f + 92abf82 commit 59e64ee
Show file tree
Hide file tree
Showing 28 changed files with 1,439 additions and 56 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "GodotPlugin/godot-cpp"]
path = GodotPlugin/godot-cpp
url = https://github.com/godotengine/godot-cpp.git
13 changes: 12 additions & 1 deletion Documentation/API/Common/InverseLerp.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### `Common.InverseLerp`

> Languages: `C#` `C++`
> Languages: `C#` `C++` `GDScript`
##### C#

Expand Down Expand Up @@ -31,3 +31,14 @@ int main()
return 0;
}
```

##### GDScript

```gdscript
extends Node
func _ready() -> void:
var value = rhythm_game_utilities.inverse_lerp(0, 10, 5)
print(value) # 0.5
```
13 changes: 12 additions & 1 deletion Documentation/API/Common/Lerp.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### `Common.Lerp`

> Languages: `C#` `C++`
> Languages: `C#` `C++` `GDScript`
##### C#

Expand Down Expand Up @@ -31,3 +31,14 @@ int main()
return 0;
}
```

##### GDScript

```gdscript
extends Node
func _ready() -> void:
var value = rhythm_game_utilities.lerp(0, 10, 0.5)
print(value) # 5
```
18 changes: 17 additions & 1 deletion Documentation/API/Parsers/ParseBpmFromChartSection.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### `Parsers.ParseBpmFromChartSection`

> Languages: `C#` `C++`
> Languages: `C#` `C++` `GDScript`
##### C#

Expand Down Expand Up @@ -39,3 +39,19 @@ int main()
return 0;
}
```

##### GDScript

```gdscript
extends Node
func _ready() -> void:
var file = FileAccess.open("res://song.txt", FileAccess.READ)
var content = file.get_as_text()
var sections = rhythm_game_utilities.parse_sections_from_chart(content)
var bpm = rhythm_game_utilities.parse_bpm_from_chart_section(sections["SyncTrack"])
print(bpm)
```
18 changes: 17 additions & 1 deletion Documentation/API/Parsers/ParseLyricsFromChartSection.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### `Parsers.ParseLyricsFromChartSection`

> Languages: `C#` `C++`
> Languages: `C#` `C++` `GDScript`
##### C#

Expand Down Expand Up @@ -39,3 +39,19 @@ int main()
return 0;
}
```

##### GDScript

```gdscript
extends Node
func _ready() -> void:
var file = FileAccess.open("res://song.txt", FileAccess.READ)
var content = file.get_as_text()
var sections = rhythm_game_utilities.parse_sections_from_chart(content)
var lyrics = rhythm_game_utilities.parse_lyrics_from_chart_section(sections["Events"])
print(lyrics)
```
18 changes: 17 additions & 1 deletion Documentation/API/Parsers/ParseMetaDataFromChartSection.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### `Parsers.ParseMetaDataFromChartSection`

> Languages: `C#` `C++`
> Languages: `C#` `C++` `GDScript`
##### C#

Expand Down Expand Up @@ -43,3 +43,19 @@ int main()
return 0;
}
```

##### GDScript

```gdscript
extends Node
func _ready() -> void:
var file = FileAccess.open("res://song.txt", FileAccess.READ)
var content = file.get_as_text()
var sections = rhythm_game_utilities.parse_sections_from_chart(content)
var meta_data = rhythm_game_utilities.parse_meta_data_from_chart_section(sections["Song"])
print(meta_data)
```
18 changes: 17 additions & 1 deletion Documentation/API/Parsers/ParseNotesFromChartSection.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### `Parsers.ParseNotesFromChartSection`

> Languages: `C#` `C++`
> Languages: `C#` `C++` `GDScript`
##### C#

Expand Down Expand Up @@ -47,3 +47,19 @@ int main()
return 0;
}
```

##### GDScript

```gdscript
extends Node
func _ready() -> void:
var file = FileAccess.open("res://song.txt", FileAccess.READ)
var content = file.get_as_text()
var sections = rhythm_game_utilities.parse_sections_from_chart(content)
var notes = rhythm_game_utilities.parse_notes_from_chart_section(sections["ExpertSingle"])
print(notes)
```
16 changes: 15 additions & 1 deletion Documentation/API/Parsers/ParseSectionsFromChart.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### `Parsers.ParseSectionsFromChart`

> Languages: `C#` `C++`
> Languages: `C#` `C++` `GDScript`
##### C#

Expand Down Expand Up @@ -34,3 +34,17 @@ int main()
return 0;
}
```

##### GDScript

```gdscript
extends Node
func _ready() -> void:
var file = FileAccess.open("res://song.txt", FileAccess.READ)
var content = file.get_as_text()
var sections = rhythm_game_utilities.parse_sections_from_chart(content)
print(sections)
```
18 changes: 17 additions & 1 deletion Documentation/API/Parsers/ParseTimeSignaturesFromChartSection.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### `Parsers.ParseTimeSignaturesFromChartSection`

> Languages: `C#` `C++`
> Languages: `C#` `C++` `GDScript`
##### C#

Expand Down Expand Up @@ -39,3 +39,19 @@ int main()
return 0;
}
```

##### GDScript

```gdscript
extends Node
func _ready() -> void:
var file = FileAccess.open("res://song.txt", FileAccess.READ)
var content = file.get_as_text()
var sections = rhythm_game_utilities.parse_sections_from_chart(content)
var time_signatures = rhythm_game_utilities.parse_time_signatures_from_chart_section(sections["SyncTrack"])
print(time_signatures)
```
21 changes: 20 additions & 1 deletion Documentation/API/Utilities/CalculateAccuracyRatio.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### `Utilities.CalculateAccuracyRatio`

> Languages: `C#` `C++`
> Languages: `C#` `C++` `GDScript`
##### C#

Expand Down Expand Up @@ -51,3 +51,22 @@ int main()
return 0;
}
```

##### GDScript

```gdscript
extends Node
func _ready() -> void:
var seconds = 2
var resolution = 192
var position_delta = 50
var bpm_changes = { 0: 120000 }
var current_position = rhythm_game_utilities.convert_seconds_to_ticks(seconds, resolution, bpm_changes)
var value = rhythm_game_utilities.calculate_accuracy_ratio(750, current_position, position_delta)
print(round(value * 100) / 100.0) # 0.64
```
22 changes: 21 additions & 1 deletion Documentation/API/Utilities/CalculateBeatBars.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### `Utilities.CalculateBeatBars`

> Languages: `C#` `C++`
> Languages: `C#` `C++` `GDScript`
##### C#

Expand Down Expand Up @@ -50,3 +50,23 @@ int main()
return 0;
}
```

##### GDScript

```gdscript
extends Node
func _ready() -> void:
var resolution = 192
var time_signature = 4
var bpm_changes = {
0: 88000, 3840: 112000, 9984: 89600,
22272: 112000, 33792: 111500, 34560: 112000,
42240: 111980
}
var beat_bars = rhythm_game_utilities.calculate_beat_bars(bpm_changes, resolution, time_signature, true)
print(beat_bars)
```
22 changes: 21 additions & 1 deletion Documentation/API/Utilities/ConvertSecondsToTicks.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### `Utilities.ConvertSecondsToTicks`

> Languages: `C#` `C++`
> Languages: `C#` `C++` `GDScript`
##### C#

Expand Down Expand Up @@ -52,3 +52,23 @@ int main()
return 0;
}
```

##### GDScript

```gdscript
extends Node
func _ready() -> void:
var seconds = 5
var resolution = 192
var bpm_changes = {
0: 88000, 3840: 112000, 9984: 89600,
22272: 112000, 33792: 111500, 34560: 112000,
42240: 111980
}
var ticks = rhythm_game_utilities.convert_seconds_to_ticks(seconds, resolution, bpm_changes)
print(ticks) # 1408
```
16 changes: 15 additions & 1 deletion Documentation/API/Utilities/ConvertTickToPosition.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### `Utilities.ConvertTickToPosition`

> Languages: `C#` `C++`
> Languages: `C#` `C++` `GDScript`
##### C#

Expand Down Expand Up @@ -37,3 +37,17 @@ int main()
return 0;
}
```

##### GDScript

```gdscript
extends Node
func _ready() -> void:
var tick = 2784
var resolution = 192
var position = rhythm_game_utilities.convert_tick_to_position(tick, resolution)
print(position) # 14.5
```
16 changes: 15 additions & 1 deletion Documentation/API/Utilities/IsOnTheBeat.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### `Utilities.IsOnTheBeat`

> Languages: `C#` `C++`
> Languages: `C#` `C++` `GDScript`
##### C#

Expand Down Expand Up @@ -41,3 +41,17 @@ int main()
return 0;
}
```

##### GDScript

```gdscript
extends Node
func _ready() -> void:
var bpm = 120
var current_time = 10
var delta = 0.05
if rhythm_game_utilities.is_on_the_beat(bpm, current_time, delta):
print("Is on the beat!")
```
13 changes: 12 additions & 1 deletion Documentation/API/Utilities/RoundUpToTheNearestMultiplier.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### `Utilities.RoundUpToTheNearestMultiplier`

> Languages: `C#` `C++`
> Languages: `C#` `C++` `GDScript`
##### C#

Expand Down Expand Up @@ -31,3 +31,14 @@ int main()
return 0;
}
```

##### GDScript

```gdscript
extends Node
func _ready() -> void:
var value = rhythm_game_utilities.round_up_to_the_nearest_multiplier(12, 10)
print(value) # 20
```
4 changes: 4 additions & 0 deletions GodotPlugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
addons/

*.os
*.dblite
Loading

0 comments on commit 59e64ee

Please sign in to comment.