Update click.js
This commit is contained in:
committed by
GitHub
parent
6434e94441
commit
02b3f8b049
@@ -7,9 +7,9 @@ window.requestAnimFrame = (function (callback) {
|
|||||||
const overlayCanvas = document.getElementById('minesweeper-overlay');
|
const overlayCanvas = document.getElementById('minesweeper-overlay');
|
||||||
const overlayCtx = overlayCanvas.getContext('2d');
|
const overlayCtx = overlayCanvas.getContext('2d');
|
||||||
|
|
||||||
const particlesPerExplosion = 20;
|
const particlesPerExplosion = 10;
|
||||||
const particlesMinSpeed = 3;
|
const particlesMinSpeed = 3;
|
||||||
const particlesMaxSpeed = 6;
|
const particlesMaxSpeed = 5;
|
||||||
const particlesMinSize = 3;
|
const particlesMinSize = 3;
|
||||||
const particlesMaxSize = 6;
|
const particlesMaxSize = 6;
|
||||||
const explosions = [];
|
const explosions = [];
|
||||||
@@ -28,11 +28,14 @@ if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(naviga
|
|||||||
let play = true;
|
let play = true;
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
function draw() {
|
function drawClickAnimation() {
|
||||||
// Loop
|
// Loop
|
||||||
if(play)
|
if(play)
|
||||||
requestAnimationFrame(draw);
|
requestAnimationFrame(drawClickAnimation);
|
||||||
|
|
||||||
|
if(explosions.length === 0)
|
||||||
|
return;
|
||||||
|
|
||||||
// Set NOW and DELTA
|
// Set NOW and DELTA
|
||||||
now = Date.now();
|
now = Date.now();
|
||||||
delta = now - then;
|
delta = now - then;
|
||||||
@@ -47,14 +50,11 @@ function draw() {
|
|||||||
|
|
||||||
// Our animation
|
// Our animation
|
||||||
drawExplosion();
|
drawExplosion();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw explosion(s)
|
// Draw explosion(s)
|
||||||
function drawExplosion() {
|
function drawExplosion() {
|
||||||
|
|
||||||
if (explosions.length === 0) {
|
if (explosions.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -138,9 +138,9 @@ function particle(x, y) {
|
|||||||
this.xv = randInt(particlesMinSpeed, particlesMaxSpeed, false);
|
this.xv = randInt(particlesMinSpeed, particlesMaxSpeed, false);
|
||||||
this.yv = randInt(particlesMinSpeed, particlesMaxSpeed, false);
|
this.yv = randInt(particlesMinSpeed, particlesMaxSpeed, false);
|
||||||
this.size = randInt(particlesMinSize, particlesMaxSize, true);
|
this.size = randInt(particlesMinSize, particlesMaxSize, true);
|
||||||
this.r = randInt(113, 222);
|
this.r = randInt(2, 36);
|
||||||
this.g = '00';
|
this.g = randInt(135, 150;
|
||||||
this.b = randInt(105, 255);
|
this.b = randInt(190, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns an random integer, positive or negative
|
// Returns an random integer, positive or negative
|
||||||
@@ -159,4 +159,4 @@ function randInt(min, max, positive) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
draw();
|
draw();
|
||||||
|
Reference in New Issue
Block a user