-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTauntSystem.js
More file actions
131 lines (131 loc) Β· 4.57 KB
/
Copy pathTauntSystem.js
File metadata and controls
131 lines (131 loc) Β· 4.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// Taunt System for Arkanoid Game
export class TauntSystem {
constructor() {
this.taunts = [
"Missed again, champ! π―",
"You call that aim? π",
"My grandma hits harder! π΅",
"Is this your first time? π€",
"Even a blindfolded turtle could do better! π’",
"Ouch! That had to hurt... your pride! π",
"Maybe try aiming next time? πͺ",
"That ball's got a mind of its own! π€ͺ",
"Physics called - they want their laws back! π§ͺ",
"Did you mean to do that? π",
"The ball is lava! π₯",
"Houston, we have a problem! π",
"Task failed successfully! β
",
"Legends never miss... oh wait! π
",
"That's what we call 'creative aiming'! π¨",
"The paddle is not a suggestion! π",
"Gravity: 1, Player: 0! β‘",
"Maybe the real treasure was the misses we made along the way! π"
];
this.lastTauntTime = 0;
this.tauntCooldown = 5000; // 5 seconds between taunts
this.isGameActive = false;
this.missCount = 0;
this.bubbles = {
left: document.getElementById('taunt-left'),
right: document.getElementById('taunt-right'),
bottom: document.getElementById('taunt-bottom')
};
}
startGame() {
this.isGameActive = true;
this.missCount = 0;
this.lastTauntTime = Date.now();
}
stopGame() {
this.isGameActive = false;
this.hideAllTaunts();
}
onBallMiss() {
if (!this.isGameActive)
return;
this.missCount++;
const now = Date.now();
// Show taunt with some probability and cooldown
if (now - this.lastTauntTime > this.tauntCooldown && Math.random() < 0.7) {
this.showRandomTaunt();
this.lastTauntTime = now;
}
}
onBrickMiss() {
if (!this.isGameActive)
return;
const now = Date.now();
// Occasional taunt on missing bricks (lower probability)
if (now - this.lastTauntTime > this.tauntCooldown && Math.random() < 0.2) {
this.showRandomTaunt();
this.lastTauntTime = now;
}
}
showRandomTaunt() {
const taunt = this.taunts[Math.floor(Math.random() * this.taunts.length)];
const positions = ['left', 'right', 'bottom'];
const position = positions[Math.floor(Math.random() * positions.length)];
this.showTaunt(position, taunt);
}
showTaunt(position, text) {
const bubble = this.bubbles[position];
if (!bubble)
return;
// Hide all other bubbles first
this.hideAllTaunts();
// Set the text
const textElement = bubble.querySelector('.taunt-text');
if (textElement) {
textElement.textContent = text;
}
// Show the bubble
bubble.classList.remove('hidden');
setTimeout(() => {
bubble.classList.add('show');
}, 10);
console.log(`Taunt "${text}" shown at`, new Date().toLocaleTimeString());
// Auto-hide after 2 seconds
setTimeout(() => {
console.log(`Taunt "${text}" hiding at`, new Date().toLocaleTimeString());
this.hideTaunt(position);
}, 2000);
}
hideTaunt(position) {
const bubble = this.bubbles[position];
if (!bubble)
return;
bubble.classList.remove('show');
setTimeout(() => {
bubble.classList.add('hidden');
}, 500); // Increased fade out time for smoother transition
}
hideAllTaunts() {
const positions = ['left', 'right', 'bottom'];
positions.forEach(position => {
this.hideTaunt(position);
});
}
// Special taunts for specific events
showWelcomeTaunt() {
setTimeout(() => {
this.showTaunt('right', "Ready to show me what you've got? π");
}, 1000);
}
showGameOverTaunt(score) {
if (score === 0) {
this.showTaunt('bottom', "Well... that was something! π¬");
}
else if (score < 5) {
this.showTaunt('left', "Not bad for a beginner! π");
}
else if (score < 15) {
this.showTaunt('right', "Getting warmer! Keep it up! π₯");
}
else {
this.showTaunt('bottom', "Impressive! You've got skills! π");
}
}
showVictoryTaunt() {
this.showTaunt('bottom', "Wow! You actually did it! ππ");
}
}