Skip to content

Commit

Permalink
feat: bubble strength 3으로 고정
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellol77 committed Aug 27, 2024
1 parent 3c90e69 commit 176d8a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 6 additions & 2 deletions frontend/src/components/bubble.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default class Bubble {
constructor(id, x, y, speed, dx, dy, imageSrc, text, strength) {
constructor(id, x, y, speed, dx, dy, imageSrc, text) {
this.id = id;
this.x = x;
this.y = y;
Expand All @@ -8,7 +8,7 @@ export default class Bubble {
this.speed = speed;
this.text = text;
this.hovered = false;
this.strength = strength;
this.strength = 3;
const tempCanvas = document.createElement("canvas");
const tempCtx = tempCanvas.getContext("2d");
// tempCtx.font = "bold 20px Arial"; // 기본 폰트 설정
Expand Down Expand Up @@ -70,4 +70,8 @@ export default class Bubble {
this.hovered = dist < this.radius;
return dist < this.radius;
}

downStrength() {
this.strength -= 1;
}
}
9 changes: 6 additions & 3 deletions frontend/src/controller/canvasController.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,12 @@ export default class CanvasController {

for (let i = this.bubbles.length - 1; i >= 0; i--) {
if (this.bubbles[i].isClicked(mouseX, mouseY)) {
this.socket.emit("deleteBubble", this.bubbles[i].id);
this.bubblePopAudio.play();
this.bubbles.splice(i, 1);
this.bubbles[i].downStrength();
if (this.bubbles[i].strength === 0) {
this.socket.emit("deleteBubble", this.bubbles[i].id);
this.bubblePopAudio.play();
this.bubbles.splice(i, 1);
}
break;
}
}
Expand Down

0 comments on commit 176d8a4

Please sign in to comment.