-
Notifications
You must be signed in to change notification settings - Fork 4
/
no.hx
103 lines (88 loc) · 2.15 KB
/
no.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import haxe.Json;
import sys.FileSystem;
import sys.io.File;
typedef TileData =
{
var step:Int;
var direction:Int;
}
typedef LineMap =
{
var tiles:Array<TileData>;
var bpm:Float;
}
typedef WeirdData = {
var notes:Array<Dynamic>;
}
/**
* CDC is my FNF Engine's chart format ("CDEV Chart", used in FNF CDEV Engine)
* This haxe code is used to convert CDC to this game's map format, currently called as "TileMap"
*/
class CDCToTileMap
{
/** Current BPM, change it using `updateBPM` **/
public static var bpm:Float = 120;
/** Single beat in miliseconds **/
public static var beat_ms:Float = 500;
/** Single step in miliseconds **/
public static var step_ms:Float = 125;
/** offset **/
public static var offset:Float = 60;
static function main()
{
trace("hi");
cls();
Sys.println("hold on");
var path:String = "D:/GAMES/FNFMOD/CoreDev Engine/cdev_engine-master/art/converter/chartTemp/right-now/right-now.cdc";
if (FileSystem.exists(path))
{
Sys.println("Exists!");
var tileData:LineMap = {
tiles: [],
bpm: 0
}
var mainChart = Json.parse(File.getContent(path));
updateBPM(mainChart.info.bpm);
tileData.bpm = mainChart.info.bpm;
var anotherWeird:WeirdData = Json.parse(File.getContent(path));
var lastDirs:Array<Int> = [];
var lastStep:Int = 0;
for (i in anotherWeird.notes)
{
var stp:Int = Math.round((i[0] - offset) / step_ms);
if (lastStep == stp)
continue;
lastStep = stp;
var rand:Int;
do
{
rand = Math.round(Math.random() * 3);
}
while (lastDirs.contains(rand));
lastDirs.push(rand);
if (lastDirs.length > 2)
lastDirs.shift();
tileData.tiles.push(cast {
step: stp,
direction: rand
});
}
trace("BPM: " + mainChart.info.bpm + " // ");
File.saveContent("./assets/data/maps/Right Now/map.json", Json.stringify(tileData, "\t"));
}
else
{
Sys.println("Nope.");
}
}
public static function updateBPM(newBPM:Float = 120)
{
bpm = newBPM;
beat_ms = ((60 / bpm) * 1000);
step_ms = beat_ms / 4;
}
static function cls()
{
Sys.command("cls");
}
}