Mobile spark: new parallax + disabled smoke
This commit is contained in:
Родитель
3e16cde127
Коммит
32990472e3
|
@ -6,7 +6,8 @@ var initSpark = function (level) {
|
|||
shapes = [],
|
||||
smokeCircles = [],
|
||||
colors = [],
|
||||
NB_CIRCLES = 200;
|
||||
NB_CIRCLES = 200,
|
||||
smoke = false;
|
||||
|
||||
canvas.height = h;
|
||||
canvas.width = w;
|
||||
|
@ -176,7 +177,9 @@ var initSpark = function (level) {
|
|||
};
|
||||
|
||||
initShapes();
|
||||
// initSmokeCircles();
|
||||
if(level >= 4 && smoke) {
|
||||
initSmokeCircles();
|
||||
}
|
||||
|
||||
// requestAnim shim layer by Paul Irish
|
||||
window.requestAnimFrame = (function(){
|
||||
|
@ -197,14 +200,14 @@ var initSpark = function (level) {
|
|||
var animate = function() {
|
||||
requestAnimFrame(animate);
|
||||
updateSpark();
|
||||
// if(level >= 4) {
|
||||
// updateSmoke();
|
||||
// }
|
||||
if(level >= 4 && smoke) {
|
||||
updateSmoke();
|
||||
}
|
||||
ctx.clearRect(0, 0, w, h);
|
||||
drawShapes(shapes, level);
|
||||
// if(level >= 4) {
|
||||
// drawSmoke(smokeCircles);
|
||||
// }
|
||||
if(level >= 4 && smoke) {
|
||||
drawSmoke(smokeCircles);
|
||||
}
|
||||
};
|
||||
|
||||
animate();
|
||||
|
|
|
@ -58,9 +58,10 @@ var initSpark = function (level) {
|
|||
var dice;
|
||||
for(var i = 0, nb = shapes[level - 1].length; i < nb; i += 1) {
|
||||
var s = shapes[level - 1][i],
|
||||
dice = rand(1, 20);
|
||||
dice = rand(1, 20),
|
||||
nbShapes = shapes[level -1].length;
|
||||
|
||||
s.moveFactor = 1-(i/6);
|
||||
s.moveFactor = (nbShapes - i)/8;
|
||||
|
||||
if(Math.abs(s.angle) > (s.maxAngle - s.arcAngle) || Math.abs(s.angle) < s.minAngle || dice === 6) {
|
||||
s.angleStep *= -1;
|
||||
|
@ -141,17 +142,21 @@ var initSpark = function (level) {
|
|||
|
||||
function setPosition(o) {
|
||||
if(window.innerHeight > window.innerWidth) {
|
||||
posx = o.x * 100;
|
||||
posx = o.x * 150;
|
||||
posy = (o.y - 0.6) * 100;
|
||||
} else {
|
||||
posy = (o.x - 0.6) * -100;
|
||||
posx = o.y * -100;
|
||||
posx = o.y * -150;
|
||||
}
|
||||
}
|
||||
|
||||
initShapes();
|
||||
initMove();
|
||||
|
||||
if(level > 4) {
|
||||
level = 4;
|
||||
}
|
||||
|
||||
setInterval(function() {
|
||||
updateSpark();
|
||||
ctx.clearRect(0, 0, w, h);
|
||||
|
|
Загрузка…
Ссылка в новой задаче