2024-12-08 16:53:56 +01:00
|
|
|
import {FullscreenEffect} from "./FullscreenEffect.js";
|
|
|
|
|
|
|
|
export class SnowEffect extends FullscreenEffect
|
|
|
|
{
|
|
|
|
static NAME = 'snow';
|
|
|
|
|
|
|
|
constructor()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
this.image = new Image();
|
2024-12-08 17:02:18 +01:00
|
|
|
this.image.src = 'js/effects/snow.png';
|
2024-12-08 16:53:56 +01:00
|
|
|
this.offset = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
update(timestamp)
|
|
|
|
{
|
|
|
|
super.update(timestamp);
|
|
|
|
this.offset = timestamp % 512;
|
|
|
|
}
|
|
|
|
|
|
|
|
render(context)
|
|
|
|
{
|
|
|
|
super.render(context);
|
|
|
|
|
|
|
|
for (let y = -1; y < Math.ceil(context.canvas.height / 512); y++) {
|
|
|
|
for (let x = -1; x < Math.ceil(context.canvas.width / 512); x++) {
|
|
|
|
context.drawImage(this.image, this.offset + 512 * x, this.offset + 512 * y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|