|
Voir le sujet précédent :: Voir le sujet suivant
|
| Auteur |
Message |
| |
|
keroin WRInaute accro

Inscrit le: 29 Avr 2006 Messages: 2063
|
Posté le : Mar Oct 31, 2006 18:28 Sujet du message: Un script spécial halloween |
|
|
si vous voulez amuser vos visiteurs ce soir, voici un petit script qui affiche un petit fantôme qui se balade sur votre site
| Code: |
<!-- HALLOWEEN -->
<!-- Copy and paste just above </BODY> in your HTML -->
<SCRIPT TYPE="text/javascript">
/**
** Ghosts - Halloween - JavaScript
** This script and many more are free at
** http://rainbow.arch.scriptmania.com/scripts/
*/
if(!window.Halloween) Halloween=new Object();
Halloween.ghostImages = new Array(
"<img src='http://rainbow.arch.scriptmania.com/scripts/ghost3.gif'>"
"<img src='http://rainbow.arch.scriptmania.com/scripts/ghost1.gif'>"
"<img src='http://rainbow.arch.scriptmania.com/scripts/ghost2.gif'>"
"<img src='http://rainbow.arch.scriptmania.com/scripts/ghost2.gif'>"
);
var ns4 = document.layers;
var ie4 = document.all;
Halloween.makeLayer = function(id)
{
var el = document.getElementById ? document.getElementById(id) :
document.all ? document.all[id] :
document.layers[id];
if(ns4) el.style=el;
el.sP=function(x,y){this.style.left = x;this.style.top=y;};
el.show=function(){ this.style.visibility = "visible"; }
el.hide=function(){ this.style.visibility = "hidden"; }
if(ns4 || window.opera)
el.sO = function(pc){return 0;};
else if(ie4)
el.sO = function(pc)
{
if(this.style.filter=="")
this.style.filter="alpha(opacity=100);";
this.filters.alpha.opacity=pc;
}
else
el.sO = function(pc){this.style.MozOpacity=pc/100;}
return el;
}
if(window.innerWidth)
{
gX=function(){return innerWidth;};
gY=function(){return innerHeight;};
}
else
{
gX=function(){return document.body.clientWidth-30;};
gY=function(){return document.body.clientHeight-30;};
}
Halloween.ghostOutput=function()
{
for(var i=0 ; i<Halloween.ghostImages.length ; i++)
document.write(ns4 ? "<LAYER NAME='gh"+i+"'>"+Halloween.ghostImages[i]+"</LAYER>" :
"<DIV id='gh"+i+"' style='position:absolute'>"+Halloween.ghostImages[i]+"</DIV>" );
}
Halloween.ghostSprites = new Array();
Halloween.ghostStartAni = function()
{
for(var i=0 ;i<Halloween.ghostImages.length;i++)
{
var el=Halloween.makeLayer("gh"+i);
el.x=Math.random()*gX();
el.y=Math.random()*gY();
el.tx=Math.random()*gX();
el.ty=Math.random()*gY();
el.dx=-5+Math.random()*10;
el.dy=-5+Math.random()*10;
el.state="off";
el.op=0;
el.sO(el.op);
el.hide();
Halloween.ghostSprites[i] = el;
}
setInterval("Halloween.ghostAni()", 40);
}
Halloween.ghostAni = function()
{
for(var i=0 ;i<Halloween.ghostSprites.length;i++)
{
el=Halloween.ghostSprites[i];
if(el.state == "off")
{
if(Math.random() > .99)
{
el.state="up";
el.show();
}
}
else if(el.state == "on")
{
if(Math.random() > .98)
el.state="down";
}
else if(el.state == "up")
{
el.op += 2;
el.sO(el.op);
if(el.op==100)
el.state = "on";
}
else if(el.state == "down")
{
el.op -= 2;
if(el.op==0)
{
el.hide();
el.state = "off";
}
else
el.sO(el.op);
}
var X = (el.tx - el.x);
var Y = (el.ty - el.y);
var len = Math.sqrt(X*X+Y*Y);
if(len < 1) len = 1;
var dx = 20 * (X/len);
var dy = 20 * (Y/len);
var ddx = (dx - el.dx)/10;
var ddy = (dy - el.dy)/10;
el.dx += ddx;
el.dy += ddy;
el.sP(el.x+=el.dx,el.y+=el.dy);
if(Math.random() >.95 )
{
el.tx = Math.random()*gX();
el.ty = Math.random()*gY();
}
}
}
Halloween.ghostStart = function()
{
if(Halloween.ghostLoad)Halloween.ghostLoad();
Halloween.ghostStartAni();
}
Halloween.ghostOutput();
Halloween.ghostLoad=window.onload;
window.onload=Halloween.ghostStart;
</SCRIPT>
<!-- FIN HALLOWEEN --> |
=> Pour voir se que ça donne, voir mon www 
Dernière édition par keroin le Mar Oct 31, 2006 20:40; édité 1 fois |
|
| |
|
 |
carrel WRInaute accro

Inscrit le: 18 Oct 2006 Messages: 1822 Localisation: deux alpes
|
Posté le : Mar Oct 31, 2006 19:15 Sujet du message: Un script spécial halloween |
|
|
Pas mal, il pourrait suivre la souris quand même  |
|
| |
|
 |
keroin WRInaute accro

Inscrit le: 29 Avr 2006 Messages: 2063
|
Posté le : Mar Oct 31, 2006 19:18 Sujet du message: Un script spécial halloween |
|
|
Bah non sinon il n'y a plus d'effet de surprise  |
|
| |
|
 |
guicara WRInaute accro

Inscrit le: 02 Fév 2006 Messages: 2097 Localisation: Dans nos montagnes...
|
Posté le : Mar Oct 31, 2006 19:59 Sujet du message: Un script spécial halloween |
|
|
Une démo ?
Oups: Quand on ne lit pas à font les messages voilà ce que sa donne
Je vais aller voir ton site et voir si sa me plait 
Dernière édition par guicara le Mar Oct 31, 2006 20:00; édité 1 fois |
|
| |
|
 |
eWeb WRInaute impliqué

Inscrit le: 22 Mai 2006 Messages: 434
|
Posté le : Mar Oct 31, 2006 20:00 Sujet du message: Un script spécial halloween |
|
|
sympa et merci de partager en tout cas... |
|
| |
|
 |
keroin WRInaute accro

Inscrit le: 29 Avr 2006 Messages: 2063
|
Posté le : Mar Oct 31, 2006 20:04 Sujet du message: Un script spécial halloween |
|
|
Bah grouillez vous quand même car demain ce sera trop tard
Moi je mets l'uniforme de ghostbuster cette nuit ou demain matin et je m'en va le boutter hors de mon royaume ce ruffiant d'ectoplasme

Dernière édition par keroin le Mar Oct 31, 2006 20:07; édité 1 fois |
|
| |
|
 |
guicara WRInaute accro

Inscrit le: 02 Fév 2006 Messages: 2097 Localisation: Dans nos montagnes...
|
Posté le : Mar Oct 31, 2006 20:06 Sujet du message: Un script spécial halloween |
|
|
Ne marche pas chez moi !
L'image reste fixe ! |
|
| |
|
 |
keroin WRInaute accro

Inscrit le: 29 Avr 2006 Messages: 2063
|
Posté le : Mar Oct 31, 2006 20:08 Sujet du message: Un script spécial halloween |
|
|
| T'es certain car je l'ai mis en l'état sur 2 site sans aucun problèmes |
|
| |
|
 |
guicara WRInaute accro

Inscrit le: 02 Fév 2006 Messages: 2097 Localisation: Dans nos montagnes...
|
Posté le : Mar Oct 31, 2006 20:09 Sujet du message: Un script spécial halloween |
|
|
Il se cache dernière mes div sous ie !
Et sous firefox non il reste fixe, toit tu le ois bouger chez moi ? |
|
| |
|
 |
keroin WRInaute accro

Inscrit le: 29 Avr 2006 Messages: 2063
|
Posté le : Mar Oct 31, 2006 20:12 Sujet du message: Un script spécial halloween |
|
|
| effectivement il ne bouge pas attend je vérifie |
|
| |
|
 |
guicara WRInaute accro

Inscrit le: 02 Fév 2006 Messages: 2097 Localisation: Dans nos montagnes...
|
Posté le : Mar Oct 31, 2006 20:13 Sujet du message: Un script spécial halloween |
|
|
Ok et merci !  |
|
| |
|
 |
keroin WRInaute accro

Inscrit le: 29 Avr 2006 Messages: 2063
|
|
| |
|
 |
guicara WRInaute accro

Inscrit le: 02 Fév 2006 Messages: 2097 Localisation: Dans nos montagnes...
|
Posté le : Mar Oct 31, 2006 20:31 Sujet du message: Un script spécial halloween |
|
|
| Toi tu n'utilise pas les div, tu est en table, peux être que sa viens de çà, je vais retenter avec ton lien. en attendant je prépare un header halloween |
|
| |
|
 |
keroin WRInaute accro

Inscrit le: 29 Avr 2006 Messages: 2063
|
Posté le : Mar Oct 31, 2006 20:32 Sujet du message: Un script spécial halloween |
|
|
En fait c'est parce qu'il y a trop de sites qui pompent l'image source en même temps que ça bug.
Sur le lien du post au dessus il faut sauvegarder les images de fantome sur votre ftp pour éviter que ça lag
Edit : bon j'ai édité le script du 1er post en prenant comme source des images de fantomes le site source du script, ça doit rouler maintenant  |
|
| |
|
 |
guicara WRInaute accro

Inscrit le: 02 Fév 2006 Messages: 2097 Localisation: Dans nos montagnes...
|
Posté le : Mar Oct 31, 2006 20:57 Sujet du message: Un script spécial halloween |
|
|
J'ai mis l'image sur mon ftp dés le début,
Je ne comprend pas...
Ps: Mon header changé ! |
|
| |
|
 |
| |
|
|