Может кто поможет. Сердечки должни лететь вверх, вместо этого мой мозг улетел, ну или испарился, не важно. Пойду застрелюсь...
ЮЗАЙ СПОЙЛЕР ! (+/-)
window.onresize = function() {
doc_height = document.body.scrollHeight - 50;
doc_width = document.body.clientWidth - 50;
}
window.onload = function(){
var
col = 15,
speed = 2,
doc_height = screen.height,
doc_width = screen.width,
dx = [],
xp = [],
yp = [],
am = [],
stx = [],
sty = [],
dbHard = [];
function randomise(range) {
rand = Math.floor(range * Math.random());
return rand;
}
function createHeart() {
var
ne,
i = 0;
while(i++ < col){
dx[i] = 0;
xp[i] = Math.random()*(doc_width-50);
yp[i] = Math.random()*doc_height;
am[i] = Math.random()*20;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
}
flyHeart();
}
function flyHeart() {
var
i = 0
e;
while(i++ < col){
e = document.getElementById('Heart'+i);
yp[i] -= sty[i];
if (yp[i] < -50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = doc_height;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}
dx[i] += stx[i];
e.style.top = yp[i]+pageYOffset;
e.style.left = xp[i] +
am[i]*Math.sin(dx[i]);
}
setTimeout("flyHeart()", 100);
}
function deathHeart(ell, id) {
setTimeout(function() {
yp[id] = -100;
dx[id] = 0;
xp[id] = Math.random()*(doc_width-50);
am[id] = Math.random()*20;
stx[id] = 0.02 + Math.random()/10;
sty[id] = 0.7 + Math.random();
ell.className = 'frame f0';
}, 1200);
ell.className = 'frame f1';
}
document.write('<style>.frame { background-color: transparent; background-image: url(sprite222.png); background-repeat: no-repeat; width: 40px; height: 40px }.f0 { background-position: 0 0; }.f1 { background-position: -40px 0; } </style>');
i = 0;
while(i++ < col){
document.write('<span class="frame f0" onclick="deathHeart(this, '+i+')" id="Heart'+i+'" style="position: absolute; left: '+randomise(doc_width)+'px; top: '+doc_height+'px; z-index: 1000; cursor: all-scroll;"></span>');
}
createHeart();
}