This commit is contained in:
choelzl 2022-02-23 21:18:13 +01:00
parent 2ae578d97d
commit 7a560ed793
Signed by: sora
GPG Key ID: A362EA0491E2EEA0

View File

@ -142,7 +142,7 @@ $(async function () {
randRange(0,canvas.height),
0,0,0,0);
this.sete = emote ? emote:null
this.emote = emote || randEmote(this.sete)
this.emote = Array.isArray(emote)? randEmote(this.sete) : emote
this.time = 0;
}
@ -157,9 +157,13 @@ $(async function () {
draw(){
ctx.globalAlpha = tWave(this.time);
if(img_map[this.emote])
ctx.drawImage(img_map[this.emote], this.x, this.y,
sWave(this.time,this.size), sWave(this.time,this.size));
if(img_map[this.emote]){
let img = img_map[this.emote]
let factor = img.naturalWidth / img.naturalHeight;
ctx.drawImage(img, this.x, this.y,
sWave(this.time,this.size*factor), sWave(this.time,this.size));
}
}
update(tick){
@ -185,9 +189,12 @@ $(async function () {
draw(){
ctx.globalAlpha = tWave(this.time);
if(img_map[this.emote])
ctx.drawImage(img_map[this.emote], this.x, this.y,
this.size, this.size);
if(img_map[this.emote]){
let img = img_map[this.emote]
let factor = img.naturalWidth / img.naturalHeight;
ctx.drawImage(img, this.x, this.y,
this.size*factor, this.size);
}
}
}
@ -337,6 +344,7 @@ $(async function () {
main(0);
const handleEmoteData = async (d) =>{
let te = d.twitch, ce = d.custom.map(e=>e.replace(/\s/g, '')).filter(e=> img_map[e]);
if(!te || te.length == 0){
@ -360,7 +368,8 @@ $(async function () {
console.log(message.eventType, message.data)
let emote = await handleEmoteData(message.data)
if(message.eventType == 'bounce') {
createParticule(BounceP, emote, {}, {})
for(let em of emote)
createParticule(BounceP, em, {}, {})
}else if(message.eventType == 'rain') {
genRain(emote)
}else if(message.eventType == 'firework') {