Skip to content

Commit 609f773

Browse files
committed
refactor(chart): Unitize speed events
1 parent 379d525 commit 609f773

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

src/chart/converter/official/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const ConvertFromOfficial = (_chartRaw: IChartOfficial) => {
8181
_newEvents.speed.push({
8282
startTime: calcRealTime(oldEvent.startTime, oldLine.bpm),
8383
endTime: oldEvent.endTime < 999999999 ? calcRealTime(oldEvent.endTime, oldLine.bpm) : Infinity,
84-
value: parseDoublePrecist(oldEvent.value, 6),
84+
value: parseDoublePrecist(oldEvent.value * 0.6, 6),
8585
});
8686
});
8787

src/chart/converter/phiedit/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,15 @@ export const ConvertFromPhiEdit = (_chartRaw: string) => {
285285
break;
286286
}
287287
case '&': { // Note scale X
288-
noteList[noteList.length - 1].scaleX = parseNumber(commandArr[1], 1);
288+
noteList[noteList.length - 1].scaleX = parseNumber(commandArr[1], 1, 4);
289289
break;
290290
}
291291
// Parse line events
292292
case 'cv': { // Speed event
293293
pushEventToLine(lineList, commandArr[1], 'speed', {
294294
startBeat: parseNumber(commandArr[2], 0),
295295
endBeat: NaN,
296-
value: parseNumber(parseFloat(commandArr[3]) / 7, 1),
296+
value: parseNumber(parseFloat(commandArr[3]) / (1400 / 120), 1),
297297
});
298298
break;
299299
}

src/chart/converter/rephiedit/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ export const ConvertFromRePhiEdit = (_chartRaw: TRPEChart) => {
231231
if (oldLayer.speedEvents) oldLayer.speedEvents.forEach((oldEvent) => {
232232
newEvents.speed.push(...calculateSpeedEventEase({
233233
...oldEvent,
234-
start: parseDoublePrecist(oldEvent.start / 4.5, 6),
235-
end: parseDoublePrecist(oldEvent.end / 4.5, 6),
234+
start: parseDoublePrecist(oldEvent.start / (900 / 120), 6),
235+
end: parseDoublePrecist(oldEvent.end / (900 / 120), 6),
236236
}).map((e) => ({
237237
...e,
238238
startTime: calculateRealTime(bpmList, e.startTime),
@@ -326,14 +326,14 @@ export const ConvertFromRePhiEdit = (_chartRaw: TRPEChart) => {
326326
for (const note of noteList) sameTimeNote[`${note.time}`] = sameTimeNote[`${note.time}`] ? 2 : 1;
327327
for (const oldNote of noteList) {
328328
const floorPosition = getFloorPositionByTime(oldNote.judgeline, oldNote.time);
329-
const holdLength = oldNote.type === 3 ? parseDoublePrecist(getFloorPositionByTime(oldNote.judgeline, (oldNote.time + oldNote.holdTime!)) - floorPosition, 3, -1) : null;
329+
const holdLength = oldNote.type === 3 ? parseDoublePrecist(getFloorPositionByTime(oldNote.judgeline, (oldNote.time + oldNote.holdTime!)) - floorPosition, 4, -1) : null;
330330

331331
result.notes.push(new GameChartNote(
332332
oldNote.judgeline,
333333
oldNote.type,
334334
oldNote.isAbove,
335335
oldNote.time,
336-
oldNote.speed,
336+
parseDoublePrecist(oldNote.speed, 6),
337337
oldNote.posX,
338338
sameTimeNote[`${oldNote.time}`] === 2,
339339
floorPosition,

src/chart/eventlayer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ export interface IGameChartEventLayer {
1111
}
1212

1313
export class GameChartEventLayer {
14+
/**
15+
* 1 Speed = 100vh/s
16+
*/
1417
readonly speed: ArrayIndexed<GameChartEventSingle> = new ArrayIndexed();
1518
/**
1619
* Use percentage. The center of the X-axis is `0%`.

src/chart/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class GameChart {
106106
for (const note of data.notes) {
107107
if (note.type === 3) {
108108
const { isOfficial } = note;
109-
const holdLength = (isOfficial ? note.holdTime! / 1000 : note.holdLength!) * note.speed * sizer.noteSpeed / sizer.noteScale;
109+
const holdLength = (isOfficial ? note.holdTime! / 1000 : note.holdLength!) * note.speed * sizer.height / sizer.noteScale;
110110

111111
note.sprite!.children[0].visible = true;
112112
note.sprite!.children[1].scale.y = 1;

src/chart/tick.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export function onChartTick(this: GameChart, currentTime: number, container: Con
3131
const { data, game } = this;
3232

3333
const { renderer } = game;
34-
const { widthHalf, heightHalf } = renderer.size;
34+
const { size } = renderer;
35+
const { widthHalf, heightHalf } = size;
3536

3637
for (const line of data.lines) {
3738
const { eventLayers, parent } = line;
@@ -115,7 +116,6 @@ export function onChartTick(this: GameChart, currentTime: number, container: Con
115116
sprite.alpha = line.alpha;
116117
}
117118

118-
const { size } = renderer;
119119
const { widthHalfBorder, heightHalfBorder } = size;
120120
for (const note of data.notes) {
121121
const {
@@ -156,7 +156,7 @@ export function onChartTick(this: GameChart, currentTime: number, container: Con
156156
}
157157

158158
const posX = widthHalf * notePosX;
159-
const posY = floorPositionDiff * size.noteSpeed * (isAbove ? -1 : 1);
159+
const posY = floorPositionDiff * size.height * (isAbove ? -1 : 1);
160160
const realXSin = posY * judgeline.sinr * -1;
161161
const realYCos = posY * judgeline.cosr;
162162

@@ -167,11 +167,11 @@ export function onChartTick(this: GameChart, currentTime: number, container: Con
167167
note.realHoldEndPosY = note.realPosY = note.realLinePosY + realYCos;
168168

169169
if (type === 3) {
170-
let realHoldLength = holdLength! * size.noteSpeed / size.noteScale;
170+
let realHoldLength = holdLength! * size.height / size.noteScale;
171171
if (time <= currentTime) {
172172
realHoldLength = (
173173
isOfficial ? (holdEndTime! - currentTime) / 1000 : (holdFloorPosition! - judgeline.floorPosition)
174-
) * speed * size.noteSpeed / size.noteScale;
174+
) * speed * size.height / size.noteScale;
175175

176176
const [ spriteHead, spriteBody, spriteEnd ] = sprite.children;
177177

src/renderer/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export interface IGameRendererSize {
3939

4040
noteScale: number,
4141
noteWidth: number,
42-
noteSpeed: number,
4342

4443
hitParticleScale: number,
4544

@@ -70,7 +69,6 @@ export class GameRenderer {
7069

7170
noteScale: 0,
7271
noteWidth: 0,
73-
noteSpeed: 0,
7472

7573
hitParticleScale: 0,
7674

@@ -159,7 +157,6 @@ export class GameRenderer {
159157

160158
size.noteScale = size.width / 8080; // TODO: Settings
161159
size.noteWidth = size.width * 0.117775;
162-
size.noteSpeed = size.height * 0.6;
163160

164161
size.hitParticleScale = size.noteScale * 6;
165162

0 commit comments

Comments
 (0)