Skip to content

Commit

Permalink
feat(colors): refactor Drums colors
Browse files Browse the repository at this point in the history
  • Loading branch information
domi7777 committed Dec 14, 2024
1 parent 162e60a commit a98aa88
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/scenes/DrumsScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export class DrumsScene extends PadsScene {
return Phaser.Display.Color.IntegerToColor(hexToColor(Colors.black));
}

protected getHitColor(_numberOfPads: number, index: number) {
console.log('getHitColor', index);
return Phaser.Display.Color.IntegerToColor(hexToColor(padColors[this.instruments[index]]));
}

protected getPadText(index: number) {
return { text: this.instruments[index], color: padColors[this.instruments[index]] };
}
Expand Down
17 changes: 10 additions & 7 deletions src/scenes/PadsScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ export abstract class PadsScene extends Phaser.Scene {

protected createPad(index: number, numberOfPads: number): Pad {
const padColor = this.getPadColor(numberOfPads, index);
const padText = this.getPadText?.(index);
const inactiveColor = padColor.color;
const hitColor = padColor.brighten(40).color;
const hitColor = this.getHitColor(numberOfPads, index);
const padText = this.getPadText(index);
const button = this.add.rectangle()
.setFillStyle(inactiveColor)
.setFillStyle(padColor.color)
.setStrokeStyle(2, hexToColor(Colors.white))
.setInteractive()
.setOrigin(0, 0);
Expand All @@ -110,7 +109,7 @@ export abstract class PadsScene extends Phaser.Scene {
const handlePadPress = () => {
if (!isActivated) {
this.playSound(index);
button.setFillStyle(hitColor);
button.setFillStyle(hitColor.color);
this.game.events.emit(EVENTS.instrumentPlayed, {
callback: () => this.playSound(index),
scene: this
Expand All @@ -119,7 +118,7 @@ export abstract class PadsScene extends Phaser.Scene {
}
};
const handlePadRelease = () => {
button.setFillStyle(inactiveColor);
button.setFillStyle(padColor.color);
isActivated = false;
}
button.on('pointerdown', (e: Phaser.Input.Pointer) => {
Expand All @@ -143,11 +142,15 @@ export abstract class PadsScene extends Phaser.Scene {
return Phaser.Display.Color.HSLToColor((numberOfPads - index) / (numberOfPads * 1.5), 1, 0.5);
}

protected getPadText(_index: number): {text: string, color?: HexaColor, alpha?: number} | undefined {
protected getPadText(_index: number): { text: string, color?: HexaColor, alpha?: number } | undefined {
return undefined;
}

onSettingChange(setting: Setting) {
logger.log('Setting changed', JSON.stringify(setting));
}

protected getHitColor(numberOfPads: number, index: number): Phaser.Display.Color {
return this.getPadColor(numberOfPads, index).brighten(40);
}
}

0 comments on commit a98aa88

Please sign in to comment.