54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
"""
|
|
HITOBJECTS SYNTAX:
|
|
x,y,type,hitSound,objectParams,hitSample
|
|
"""
|
|
|
|
|
|
class SliderParams():
|
|
def __init__(self, curvePoints, curveType="B", slides=1, length=100):
|
|
self.curveType = curveType # B=bézier, L=linear, P=perfect circle
|
|
self.curvePoints = curvePoints # '|x1:y1|x2:y2,'
|
|
self.slides: int = slides
|
|
self.length: float = length #visual length in osu px
|
|
def __str__(self):
|
|
curvePoints = [f"{x}:{y}" for x, y in self.curvePoints]
|
|
curvePoints = "|".join(curvePoints)
|
|
return f"{self.curveType}|{curvePoints},{self.slides},{self.length},,"
|
|
|
|
class HitObject():
|
|
"""
|
|
Base class for hit objects.
|
|
(x, y) int*int: position tuple
|
|
time: int: time in ms where the object is placed.
|
|
type: int
|
|
hitsound: assumed to be the default (0)
|
|
objectParams: awa (comma separated list)
|
|
hitSample: don't write anything
|
|
"""
|
|
def __init__(self, pos=(0, 0), time=0, objectType=0, newCombo=False, objectParams=""):
|
|
self.pos = pos
|
|
self.time = time
|
|
self.objectType = objectType
|
|
self.newCombo = newCombo*2
|
|
self.objectParams = objectParams
|
|
def __str__(self):
|
|
return (f"{self.pos[0]},{self.pos[1]},{self.time},{self.objectType+self.newCombo},0,{self.objectParams},")
|
|
|
|
|
|
|
|
def import_hitobjects(filename: str):
|
|
with open(filename, 'r') as file:
|
|
lines = f.readlines()
|
|
for line in lines:
|
|
params = line.split(",")
|
|
if params[3] ==
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
circle = HitObject((120, 120),250,0,1)
|
|
slider = HitObject((120, 120), 250, 1, False, SliderParams(((130, 130), (110, 110))))
|
|
"""
|