From 4c7f832eb02d7ca86a48da103be7c0ff4a6b4257 Mon Sep 17 00:00:00 2001 From: Emil Kosz Date: Fri, 4 Oct 2024 18:17:46 +0200 Subject: [PATCH] Add particle rotation --- game.js | 2 +- index.html | 1 - particles.js | 6 +++--- style.css | 5 ----- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/game.js b/game.js index b8810b6..d60da7a 100644 --- a/game.js +++ b/game.js @@ -206,7 +206,7 @@ function reveal_cell_cosmetic(cell) { let x = cell.offsetLeft - cell.scrollLeft; let y = cell.offsetTop - cell.scrollTop; - spawn_particle(x, y, (Math.random() * 2 - 1) / 16, -0.3, 0, 1, dummy_image, w, h); + spawn_particle(x, y, (Math.random() * 2 - 1) / 16, -0.3, 0, (Math.random() * 2 - 1) / 16, dummy_image, w, h); } // Shows the game won/over popup. diff --git a/index.html b/index.html index 52cdb84..2d83cf0 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,6 @@ diff --git a/particles.js b/particles.js index ecfb104..fe5266a 100644 --- a/particles.js +++ b/particles.js @@ -51,9 +51,9 @@ function update_particles(delta_time) { particle.vel_y += 0.001 * delta_time; // Render particle. particle_ctx.save(); - // particle_ctx.translate(-particle.width / 2, -particle.height / 2); - // particle_ctx.rotate(particle.rot * Math.PI / 180); - particle_ctx.drawImage(particle.img, particle.x, particle.y, particle.w, particle.h) + particle_ctx.translate(particle.x + particle.w / 2, particle.y + particle.h / 2); + particle_ctx.rotate(particle.rot * Math.PI / 180); + particle_ctx.drawImage(particle.img, -particle.w / 2, -particle.h / 2, particle.w, particle.h) particle_ctx.restore(); } } diff --git a/style.css b/style.css index 8ab2b30..bd96384 100644 --- a/style.css +++ b/style.css @@ -68,11 +68,6 @@ body.popup-victory { #nextlevel { display: block; } } span#game-title { font-size: 3em; margin: 16px; - margin-bottom: 0; -} - -span#subtitle { - margin: 16px; } #button-list {