mirror of
https://git.leinelab.org/Mal/mr-crocs-adventures.git
synced 2025-09-11 02:57:36 +02:00
Snow fullscreen effect implemented
This commit is contained in:
31
js/effects/SnowEffect.js
Normal file
31
js/effects/SnowEffect.js
Normal file
@@ -0,0 +1,31 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user