Skip to content

Commit

Permalink
✨ プレー設定にミラーオプションを追加 (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
3w36zj6 authored Nov 21, 2023
1 parent be0361c commit 156ec19
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/class/ChartPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ export class ChartPlayer {

if (parseInt(object.channel) in replacementLongNote) {
laneIndex = replacementLongNote[parseInt(object.channel)]

laneIndex = playConfig.isMirror ? 6 - laneIndex : laneIndex
if (!isLatestEndLongNote[laneIndex]) {
beatLatestEndLongNote[laneIndex] = beat
isLongNoteStart = true
} else {
isLongNoteEnd = true
}
isLatestEndLongNote[laneIndex] = true
} else {
laneIndex = playConfig.isMirror ? 6 - laneIndex : laneIndex
}

if (parseInt(object.channel) === 1) {
Expand Down
4 changes: 4 additions & 0 deletions src/class/PlayConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,24 @@ export class PlayConfig {
public noteType: NoteType
public key: Key
public difficulty: Difficulty
public isMirror: boolean

constructor({
noteSpeed,
noteType,
isMirror,
key,
difficulty,
}: {
noteSpeed: number
noteType: NoteType
isMirror: boolean
key: Key
difficulty: Difficulty
}) {
this.noteSpeed = noteSpeed
this.noteType = noteType
this.isMirror = isMirror
this.key = key
this.difficulty = difficulty
}
Expand Down
38 changes: 38 additions & 0 deletions src/scene/ConfigScene.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { type NoteType, type PlayConfig } from "../class/PlayConfig"
import { ToggleButton } from "../class/ToggleButton"

type LaneType = "normal" | "mirror"

export class ConfigScene extends Phaser.Scene {
private playConfig: PlayConfig

private previewNote: Phaser.GameObjects.Image
private previewTimer: Date

private noteTypeIndex: number
private laneTypeIndex: number

constructor() {
super("config")
Expand Down Expand Up @@ -125,6 +128,37 @@ export class ConfigScene extends Phaser.Scene {
})
this.add.existing(noteTypeToggleButton)

const laneTypeLabel = this.add
.text(width / 2 - 260, height / 2 - 180 + 360 * 0.4, "レーンの配置", {
fontFamily: "Noto Sans JP",
fontSize: "35px",
color: "#f0f0f0",
})
.setOrigin(0, 0.5)
.setScale(0.5)
.setDepth(1)
.setAlpha(0)

const laneTypeList: LaneType[] = ["normal", "mirror"]
this.laneTypeIndex = Number(this.playConfig.isMirror)
const laneTypeToggleButton = new ToggleButton(this, `${laneTypeList[this.laneTypeIndex]}`)
.setPosition(width / 2 + 260 - 95.5, height / 2 - 180 + 360 * 0.4)
.setDepth(2)
.setAlpha(0)
laneTypeToggleButton.leftZone.on("pointerdown", () => {
this.sound.play("cursor")
this.laneTypeIndex ^= 1
this.playConfig.isMirror = Boolean(this.laneTypeIndex)
laneTypeToggleButton.setText(`${laneTypeList[this.laneTypeIndex]}`)
})
laneTypeToggleButton.rightZone.on("pointerdown", () => {
this.sound.play("cursor")
this.laneTypeIndex ^= 1
this.playConfig.isMirror = Boolean(this.laneTypeIndex)
laneTypeToggleButton.setText(`${laneTypeList[this.laneTypeIndex]}`)
})
this.add.existing(laneTypeToggleButton)

const closeLabel = this.add
.text(width / 2, height / 2 - 180 + 360 * 1.15, "閉じる", {
fontFamily: "Noto Sans JP",
Expand Down Expand Up @@ -156,6 +190,8 @@ export class ConfigScene extends Phaser.Scene {
noteSpeedToggleButton,
noteTypeLabel,
noteTypeToggleButton,
laneTypeLabel,
laneTypeToggleButton,
closeLabel,
closeButton,
this.previewNote,
Expand Down Expand Up @@ -232,6 +268,8 @@ export class ConfigScene extends Phaser.Scene {
noteSpeedToggleButton,
noteTypeLabel,
noteTypeToggleButton,
laneTypeLabel,
laneTypeToggleButton,
closeLabel,
closeButton,
this.previewNote,
Expand Down
1 change: 1 addition & 0 deletions src/scene/ResultScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class ResultScene extends Phaser.Scene {
playConfig: {
noteSpeed: 6.5,
noteType: "rectangle",
isMirror: false,
key: 7,
difficulty: 3,
},
Expand Down
1 change: 1 addition & 0 deletions src/scene/SelectScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export class SelectScene extends Phaser.Scene {
new PlayConfig({
noteSpeed: 3.0,
noteType: "circle",
isMirror: false,
key: 4,
difficulty: 1,
})
Expand Down
2 changes: 1 addition & 1 deletion src/scene/TitleScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class TitleScene extends Phaser.Scene {

// 日本語のフォントがうまく読み込まれないので、使う文字を予め強制的に読み込んでおく
this.add
.text(1280, 0, "あ難易度使用数変更譜面現在設定企画立案楽曲", {
.text(1280, 0, "あ難易度使用数変更速見目配置譜面現在設定企画立案楽曲", {
fontFamily: "Noto Sans JP",
fontSize: "40px",
color: "#fafafa",
Expand Down

0 comments on commit 156ec19

Please sign in to comment.