mr-crocs-adventures/js/effects/SnowEffect.js

32 lines
622 B
JavaScript
Raw Normal View History

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();
this.image.src = '/js/effects/snow.png';
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);
}
}
}
}