Skip to content

Commit

Permalink
Merge pull request #23 from Parallaxes/main
Browse files Browse the repository at this point in the history
Update v1.0.8 - Winter Background Update
  • Loading branch information
Parallaxes authored Dec 9, 2024
2 parents 615c643 + 6c597be commit 0df00bb
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 18 deletions.
26 changes: 9 additions & 17 deletions assets/js/platformer/BackgroundSnowfall.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class BackgroundSnowfall extends Background {
super(canvas, image, data);
this.snowflakes = [];
this.snowflakeImage = new Image();
this.snowflakeImage.src = '/images/platformer/backgrounds/beefall.png'; // Correct path to the image
this.snowflakeImage.src = 'images/platformer/backgrounds/bee__1_-removebg-preview.png'; // Correct path to the image
this.snowflakeImage.onload = () => {
console.log('Snowflake image loaded successfully');
this.createSnowflakes();
Expand All @@ -17,22 +17,22 @@ export class BackgroundSnowfall extends Background {
}

createSnowflakes() {
for (let i = 0; i < 75; i++) { // Number of snowflakes
for (let i = 0; i < 10; i++) { // Number of snowflakes
this.snowflakes.push({
x: Math.random() * this.canvas.width,
y: Math.random() * this.canvas.height,
radius: Math.random() * 1.0 + 0.25, // Size of snowflakes
radius: Math.random() * 4.5 + 3.0, // Size of snowflakes
speed: Math.random() * 0.5 + 0.2 // Speed of snowflakes
});
}
}

update() {
for (let flake of this.snowflakes) {
flake.y += flake.speed;
if (flake.y > this.canvas.height) {
flake.y = 0;
flake.x = Math.random() * this.canvas.width;
flake.x -= flake.speed;
if (flake.x < 0) {
flake.x = this.canvas.width;
flake.y = Math.random() * this.canvas.height;
}
}
super.update();
Expand All @@ -41,18 +41,10 @@ export class BackgroundSnowfall extends Background {
draw() {
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
for (let flake of this.snowflakes) {
if (this.snowflakeImage.complete) {
this.ctx.drawImage(this.snowflakeImage, flake.x, flake.y, flake.radius * 2, flake.radius * 2);
} else {
// Draw a placeholder circle if the image is not loaded
this.ctx.beginPath();
this.ctx.arc(flake.x, flake.y, flake.radius, 0, Math.PI * 2);
this.ctx.fillStyle = 'white';
this.ctx.fill();
}
this.ctx.drawImage(this.snowflakeImage, flake.x, flake.y, flake.radius * 2, flake.radius * 2);
}
super.draw();
}
}

export default BackgroundSnowfall;
export default BackgroundSnowfall;
2 changes: 1 addition & 1 deletion assets/js/platformer/GameSetterWinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const assets = {
space: { src: "/images/platformer/backgrounds/planet.jpg" },
castles: { src: "/images/platformer/backgrounds/castles.png" },
winter: { src: "/images/platformer/backgrounds/flowerBoy3.webp" },
snow: { src: "/images/platformer/backgrounds/beefall.png" },
snow: { src: "/images/platformer/backgrounds/beefall (2).png" },
icewater: { src: "/images/platformer/backgrounds/icewater.png" },
narwhal: { src: "/images/platformer/backgrounds/narwhal.png", parallaxSpeed: 2 },
mini: { src: "/images/platformer/backgrounds/mini.png" },
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/platformer/backgrounds/beefall (2).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/platformer/backgrounds/beetuah.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0df00bb

Please sign in to comment.