本帖最后由 renrousousuo 于 2009-01-12 17:41:41 编辑

解决方案 »

  1.   

    先来一个最简单的,抛砖引玉:
    <html>
    <body>
    <script type="text/javascript">
    function Ball() {
    this.span = document.createElement("span");
    document.body.appendChild(this.span);
    this.span.innerHTML = "●";
    var h = document.body.clientHeight || document.documentElement.clientHeight;
    var w = document.body.clientWidth || document.documentElement.clientWidth;
    this.left = (w - this.span.clientWidth) / 2;
    this.top = h - this.span.clientHeight;
    this.size = 20;
    with (this.span.style) {
    color = "White";
    fontSize = this.size + "px";
    position = "absolute";
    left = this.left + "px";
    top = this.top + "px";
    }
    var ball = this;
    this.speed = 20;
    this.step = 0;
    this.timer = setInterval(function() {
    ball.move();
    }, 50);
    }Ball.prototype.move = function() {
    this.top -= this.speed;
    this.step++;
    if (this.step % 3 == 0) {
    this.speed--;
    this.size--;
    if (this.size <= 0) {
    this.free();
    return;
    }
    }
    with (this.span.style) {
    fontSize = this.size + "px";
    fontSize = this.size + "px";
    left = this.left + "px";
    top = this.top + "px";
    }
    };Ball.prototype.free = function() {
    this.span.parentNode.removeChild(this.span);
    clearInterval(this.timer);
    if (typeof this.onfree == "function") this.onfree(this);
    };fireworks = {
    play: function() {
    document.body.style.backgroundColor = "Black";
    new Ball().onfree = function() {
    new Ball().onfree = arguments.callee;
    }
    }
    };fireworks.play();
    </script>
    </body>
    </html>
      

  2.   

    APPLET版import java.applet.Applet;
    import java.applet.AudioClip;
    import java.awt.*;
    import java.awt.image.MemoryImageSource;
    import java.util.Random;public class jhanabi extends Applet implements Runnable
    {private int m_nAppX;
    private int m_nAppY;
    private int m_centerX;
    private int m_centerY;
    private int m_mouseX;
    private int m_mouseY;
    private int m_sleepTime;
    private boolean isError;
    private boolean m_isPaintFinished;
    boolean isRunning;
    boolean isInitialized;
    Thread runner;
    int pix0[];
    MemoryImageSource offImage;
    Image dbImg;
    int pixls;
    int pixls2;
    Random rand;
    int bits;
    double bit_px[];
    double bit_py[];
    double bit_vx[];
    double bit_vy[];
    int bit_sx[];
    int bit_sy[];
    int bit_l[];
    int bit_f[];
    int bit_p[];
    int bit_c[];
    int bit_max;
    int bit_sound;
    int ru;
    int rv;
    AudioClip sound1;
    AudioClip sound2;public jhanabi()
    {
    m_mouseX = 0;
    m_mouseY = 0;
    m_sleepTime = 5;
    isError = false;
    isInitialized = false;
    rand = new Random();
    bits = 10000;
    bit_px = new double[bits];
    bit_py = new double[bits];
    bit_vx = new double[bits];
    bit_vy = new double[bits];
    bit_sx = new int[bits];
    bit_sy = new int[bits];
    bit_l = new int[bits];
    bit_f = new int[bits];
    bit_p = new int[bits];
    bit_c = new int[bits];
    ru = 50;
    rv = 50;
    }public void init()
    {
    String s =
    getParameter("para_bits");
    if(s != null)
    {
    bits = Integer.parseInt(s);
    }
    s = getParameter("para_max");
    if(s != null)
    {
    bit_max = Integer.parseInt(s);
    }
    s = getParameter("para_blendx");
    if(s != null)
    {
    ru = Integer.parseInt(s);
    }
    s = getParameter("para_blendy");
    if(s != null)
    {
    rv = Integer.parseInt(s);
    }
    s = getParameter("para_sound");
    if(s != null)
    {
    bit_sound =
    Integer.parseInt(s);
    }
    m_nAppX = size().width;
    m_nAppY = size().height;
    m_centerX = m_nAppX / 2;
    m_centerY = m_nAppY / 2;
    m_mouseX = m_centerX;
    m_mouseY = m_centerY;
    resize(m_nAppX, m_nAppY);
    pixls = m_nAppX * m_nAppY;
    pixls2 = pixls - m_nAppX * 2;
    pix0 = new int[pixls];
    offImage = new 
    MemoryImageSource(m_nAppX, m_nAppY, pix0, 0, m_nAppX);
    offImage.setAnimated(true);
    dbImg = createImage(offImage);
    for(int i = 0; i < pixls; i++)
    {
    pix0[i] = 0xff000000;
    }sound1 =
    getAudioClip(getDocumentBase(), "firework.au");
    sound2 = getAudioClip(getDocumentBase(), "syu.au");
    for(int j = 0; j < bits; j++)
    {
    bit_f[j] = 0;
    }isInitialized = true;
    start();
    }public void run()
    {
    while(!isInitialized) 
    {
    try
    {
    Thread.sleep(200L);
    }
    catch(InterruptedException interruptedexception) { }
    }
    do
    {
    for(int i = 0; i < pixls2; i++)
    {
    int j = pix0[i];
    int k = pix0[i + 1];
    int l = pix0[i + m_nAppX];
    int i1 = pix0[i + m_nAppX + 1];
    int j1 = (j & 0xff0000) >> 16;
    int k1 = ((((k & 0xff0000) >> 16) - j1) * ru >> 8) + j1;
    j1 = (j & 0xff00) >> 8;
    int l1 = ((((k & 0xff00) >> 8) - j1) * ru >> 8) + j1;
    j1 = j & 0xff;
    int i2 = (((k & 0xff) - j1) * ru >> 8) + j1;
    j1 = (l & 0xff0000) >> 16;
    int j2 = ((((i1 & 0xff0000) >> 16) - j1) * ru >> 8) + j1;
    j1 = (l & 0xff00) >> 8;
    int k2 = ((((i1 & 0xff00) >> 8) - j1) * ru >> 8) + j1;
    j1 = l & 0xff;
    int l2 = (((i1 & 0xff) - j1) * ru >> 8) + j1;
    int i3 = ((j2 - k1) * rv >> 8) + k1;
    int j3 = ((k2 - l1) * rv >> 8) + l1;
    int k3 = ((l2 - i2) * rv >> 8) + i2;
    pix0[i] = i3 << 16 | j3 << 8 | k3 | 0xff000000;
    }rend();
    offImage.newPixels(0, 0, m_nAppX, m_nAppY);
    try
    {
    Thread.sleep(m_sleepTime);
    }
    catch(InterruptedException interruptedexception1) { }
    } while(true);
    }public void update(Graphics g)
    {
    paint(g);
    }public void paint(Graphics g)
    {
    g.drawImage(dbImg, 0, 0, this);
    }public void start()
    {
    if(isError)
    {
    return;
    }
    isRunning = true;
    if(runner == null)
    {
    runner = new Thread(this);
    runner.start();
    }
    }public void stop()
    {
    if(runner != null)
    {
    runner.stop();
    runner = null;
    }
    }public boolean mouseMove(Event event, int i, int j)
    {
    m_mouseX = i;
    m_mouseY = j;
    return true;
    }public boolean mouseDown(Event event, int i, int j)
    {
    m_mouseX = i;
    m_mouseY = j;
    int k = (int)(rand.nextDouble() * 256D);
    int l = (int)(rand.nextDouble() * 256D);
    int i1 = (int)(rand.nextDouble() * 256D);
    int j1 = k << 16 | l << 8 | i1 | 0xff000000;
    int k1 = 0;
    for(int l1 = 0; l1 < bits; l1++)
    {
    if(bit_f[l1] != 0)
    {
    continue;
    }
    bit_px[l1] = m_mouseX;
    bit_py[l1] = m_mouseY;
    double d = rand.nextDouble() * 6.2800000000000002D;
    double d1 = rand.nextDouble();
    bit_vx[l1] = Math.sin(d) * d1;
    bit_vy[l1] = Math.cos(d) * d1;
    bit_l[l1] = (int)(rand.nextDouble() * 100D) + 100;
    bit_p[l1] = (int)(rand.nextDouble() * 3D);
    bit_c[l1] = j1;
    bit_sx[l1] = m_mouseX;
    bit_sy[l1] = m_nAppY - 5;
    bit_f[l1] = 2;
    if(++k1 == bit_max)
    {
    break;
    }
    }if(bit_sound > 1)
    {
    sound2.play();
    }
    return true;
    }public boolean mouseExit(Event event, int i, int j)
    {
    m_mouseX = i;
    m_mouseY = j;
    return true;
    }void rend()
    {
    boolean flag = false;
    boolean flag1 = false;
    boolean flag2 = false;
    for(int i = 0; i < bits; i++)
    {
    switch(bit_f[i])
    {
    default:
    break;case 1: // '\001'
    bit_vy[i] += rand.nextDouble() / 50D;
    bit_px[i] += bit_vx[i];
    bit_py[i] += bit_vy[i];
    bit_l[i]--;
    if(bit_l[i] == 0 || bit_px[i] < 0.0D || bit_py[i] < 0.0D || bit_px[i] > (double)m_nAppX || bit_py[i] > (double)(m_nAppY - 3))
    {
    bit_c[i] = 0xff000000;
    bit_f[i] = 0;
    } else
    if(bit_p[i] == 0)
    {
    if((int)(rand.nextDouble() * 2D) == 0)
    {
    bit_set((int)bit_px[i], (int)bit_py[i], -1);
    }
    } else
    {
    bit_set((int)bit_px[i], (int)bit_py[i], bit_c[i]);
    }
    break;case 2: // '\002'
    bit_sy[i] -= 5;
    if((double)bit_sy[i] <= bit_py[i])
    {
    bit_f[i] = 1;
    flag2 = true;
    }
    if((int)(rand.nextDouble() * 20D) == 0)
    {
    int j = (int)(rand.nextDouble() * 2D);
    int k = (int)(rand.nextDouble() * 5D);
    bit_set(bit_sx[i] + j, bit_sy[i] + k, -1);
    }
    break;
    }
    }if(flag2 && bit_sound > 0)
    {
    sound1.play();
    }
    }void bit_set(int i, int j, int k)
    {
    int l = i + j * m_nAppX;
    pix0[l] = k;
    }
    }
      

  3.   

    再写一个HTML来调用<applet code=jhanabi width=200 htight=300></applet>很漂亮的
      

  4.   

    雏形先:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
    <head>
    <meta http-equiv="Content-Language" content="zh-CN" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>【编程游戏】贺岁放礼花。</title>
    </head>
    <body>
    <script type="text/javascript">
    var powder = function(sky,spattern,scolor,astart,aend){
    this.sky = sky;
    this.size = 50;
    this.color = scolor;
    this.start = astart;
    this.end = aend;
    this.times = 20;
    this.steps = 100;
    this.innerHTML = spattern||'●';
    this.style.cssText = 'position:absolute;font-weight:bold;font-family:arial;color:'+scolor+';left:'+this.start[0]+'px;top:'+this.start[1]+';font-size:'+this.size+'px;';
    this.go = function(){
    var op = this,sky = this.sky;color = this.color,size = this.size,startX = this.start[0],startY = this.start[1],endX = this.end[0],endY = this.end[1],steps = this.steps;
    var dx = endX - startX;
    var dy = endY - startY;
    var curStep = 0;
    var flash = function(){
    if(!sky){return;}
    var sbg = sky.style.background = color;
    window.setTimeout(function(){sky.style.background = 'black';sky.removeChild(op);});
    };
    var move = function(){
    curStep++;
    if(curStep>steps){
    window.clearInterval(timer);
    flash();
    return;
    }
    var sx = dx*curStep/steps,sy = dy*curStep/steps,ss = size*curStep/steps;
    op.style.left = (startX + sx) + "px";
    op.style.top = (startY + sy) + "px";
    op.style.fontSize = (size - ss) + "px";
    }
    var timer = window.setInterval(move,this.times);
    };
    };var flash = function(sky){
    this.sky = sky;
    };
    flash.prototype = {
    fire:function(){
    var sky = this.sky;
    var pf = function(){
    var rsx = parseInt(Math.random()*1000),rey = parseInt(Math.random()*10);
    var astart = [rsx,800],aend = [rsx,rey];
    var x = document.createElement("div");
    sky.appendChild(x);
    powder.call(x,sky,'●','red',astart,aend);
    x.go();
    };
    window.setInterval(pf,1000);
    },
    init:function(){
    if(!this.sky){return;}
    this.sky.style.cssText = 'background:black;padding:0;border:0;width:100%;height:100%;overflow:hidden;';
    }
    };
    var xmas_flash = new flash(document.body);
    xmas_flash.init();
    xmas_flash.fire();
    </script>
    </body>
    </html>
      

  5.   

    先这样吧,明天再改<html>
    <head>
    <title></title>
    </head>
    <body>
    <script>
    var FireColor = ["red","blue","yellow","orange","pink"];
    var FireStyle = ["¤","●","○","◎","▲"];
    var StarStyle = ["☆","★","※","∵","◆"];
    function xo()
    {
    this.x=0;this.y=0;this.power=Math.floor(Math.random()*arguments[0]+arguments[1]);
    }
    function star(c)
    {
    var handle=this;
    xo.call(this,100,0);
    this.star=StarStyle[Math.floor(Math.random()*4)];
    this.angle=2*Math.PI*Math.random()+1;
    this.o=document.createElement("span");
    document.body.appendChild(this.o);
    this.o.innerHTML=this.star;
    this.style=this.o.style;
    this.color=c;
    this.exist=false;
    with(this.style)
    {
    visibility="hidden";
    position="absolute";
    color=this.color;
    }
    this.move=function()
    {
    if(this.y<this.power)
    {
    this.y+=2;
    with(this.style)
    {
    top=this.y;
    left=this.x+this.y*Math.sin(this.angle);
    }
    }else
    {
    this.clear();
    }
    }
    this.burn=function(x,y)
    {
    this.style.left=this.x=x;
    this.style.top=this.y=y;
    }
    this.shine=function(x,y)
    {
    this.burn(x,y);
    this.style.visibility="visible";
    this.gogo=setInterval(function(){handle.move()},17);
    }
    this.clear=function()
    {
    this.o.parentNode.removeChild(this.o);
    clearInterval(this.gogo);
    }
    }
    function Firework()
    {
    var handle=this;
    xo.call(this,10,25);
    this.color=FireColor[Math.floor(Math.random()*4)];
    this.shape=FireStyle[Math.floor(Math.random()*4)];
    this.starnum=Math.floor(Math.random()*7)+5;
    this.star = new Array();
    this.exist=true;
    for(var i=0;i<this.starnum;i++)
    {
    this.star[i]=new star(this.color);
    }
    this.starnum=Math.floor(Math.random()*4)+4;
    this.o = document.createElement("span");
    document.body.appendChild(this.o);
    this.o.innerHTML=this.shape;
    this.style=this.o.style;
    this.style.color=this.color;
    this.style.position="absolute";
    this.setX=function(x){this.style.left=x+"px";this.x=x;}
    this.setY=function(y){this.style.top=y+"px";this.y=y;}
    this.move=function()
    {
    this.y -=this.power/3;
    if(this.y>this.power)
    this.style.top=this.y + "px";
    else
    {
    if(this.exist)this.clear();
    }
    }
    this.fire=function()
    {
    this.gogo=setInterval(function(){handle.move()},17);
    };
    this.clear=function()
    {
    this.o.parentNode.removeChild(this.o);
    clearInterval(this.gogo);
    this.exist=false;
    for(var i=0,j=this.star.length;i<j;i++)
    {
    this.star[i].shine(this.x,this.y);
    }
    }
    }
    function FireScene(n)
    {
    this.num=n;
    this.SceneWidth=document.body.clientWidth; 
    this.SceneHeight=document.body.clientHeight; 
    this.step=Math.floor(this.SceneWidth/this.num);
    this.firework=new Array();
    for(var i=0;i<this.num;i++)
    {
    this.firework[i]=new Firework();
    this.firework[i].setX(this.step*i);
    this.firework[i].setY(this.SceneHeight-50);
    }
    this.fire=function()
    {
    for(var i=0,j=this.firework.length;i<j;i++)
    {
    this.firework[i].fire();
    }
    }
    }
    window.onload=function()
    {
    document.body.style.backgroundColor = "Black";
    new FireScene(8).fire()
    setInterval("new FireScene(8).fire()",2000);
    }
    </script>
    </body>
    </html>
      

  6.   


    <html>
    <head>
    <style>
    * {margin:0px 0px; border:0px; background:#000; text-align:center;}
    img {top:48%; position:absolute;}
    </style>
    </head>
    <body>
    <img src="http://www.dabaoku.com/gif/shehui/004/002b.gif" />
    </body>
    </html>
    要求: 
      单一的html文件(符合),8000字内(能一次贴出来)(符合); 
      尽量不含图片;(只是尽量.使用了一张.) 
      兼容IE6/7/8、FF2/3。 (至少IE6 测试通过,其它嘛.我敢肯定,绝对没问题)考评: 
      动画效果 50%                  -----还不错吧?
      可读性/代码简洁 30%            -----够简洁,可读性强
      运行效率 20%                  -----如果谁谁CPU占用超过20% 以上, 可以回复骂我....2009   oh,yeah!
      

  7.   

    就这样了,不弄了,心情8好,唉!
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
    <head>
    <meta http-equiv="Content-Language" content="zh-CN" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>【编程游戏】贺岁放礼花。</title>
    </head>
    <body>
    <script type="text/javascript">
    var powder = function(sky,spattern,scolor,isize,astart,aend){
    this.sky = sky;
    this.color = scolor;
    this.start = astart;
    this.fsize = isize;
    this.end = aend;
    this.times = 20;
    this.steps = 100;
    this.innerHTML = spattern||'●';
    this.style.cssText = 'position:absolute;font-weight:bold;font-family:arial;color:'+scolor+';left:'+this.start[0]+'px;top:'+this.start[1]+';font-size:'+this.size+'px;';
    this.go = function(){
    var op = this,sky = this.sky;color = this.color,size = 50,fsize = this.fsize,startX = this.start[0],startY = this.start[1],endX = this.end[0],endY = this.end[1],steps = this.steps;
    var dx = endX - startX;
    var dy = endY - startY;
    var curStep = 0,dtimer = null;
    var down = function(l){
    if(!l){window.clearTimeout(dtimer);sky.style.background = 'black';sky.removeChild(op);return;}
    var x = parseInt(op.style.left),y = parseInt(op.style.top);
    op.style.color = (l%2)?color:'black';
    sky.style.background = (l%20)?'black':color;
    op.style.fontSize = parseInt(op.style.fontSize)+10+'px';
    op.style.left = x-2+'px';
    op.style.top = y-3+'px';
    dtimer = window.setTimeout(function(){down(--l);});
    };
    var flash = function(){
    if(!sky){return;}
    var x = parseInt(op.style.left)-200,y = parseInt(op.style.top)-250;
    op.style.fontSize = fsize+'px';
    op.style.left = x+'px';
    op.style.top = y+'px';
    down(op.times);
    };
    var move = function(){
    curStep++;
    if(curStep>steps){
    window.clearInterval(timer);
    flash();
    return;
    }
    var sx = dx*curStep/steps,sy = dy*curStep/steps,ss = size*curStep/steps;
    op.style.left = (startX + sx) + "px";
    op.style.top = (startY + sy) + "px";
    op.style.fontSize = (size - ss) + "px";
    }
    var timer = window.setInterval(move,this.times);
    };
    };var flash = function(sky){
    this.sky = sky;
    };
    flash.prototype = {
    fire:function(){
    var sky = this.sky;
    var pf = function(){
    var asize = [100,250,350,500];
    var acolor = ['#ff0000','#A0088F','#FFD02A','#1285BE'];
    var rsx = parseInt(Math.random()*1000),rey = parseInt(Math.random()*10);
    var astart = [rsx,800],aend = [rsx,rey],ssize = asize[0],scolor = acolor[0];
    if(!(rey%2)){ssize = asize[1];scolor = acolor[1];}
    if(!(rey%3)){ssize = asize[2];scolor = acolor[2];}
    if(!(rey%5)){ssize = asize[3];scolor = acolor[3];}
    var x = document.createElement("div");
    sky.appendChild(x);
    powder.call(x,sky,'●',scolor,ssize,astart,aend);
    x.go();
    };
    window.setInterval(pf,1000);
    },
    init:function(){
    if(!this.sky){return;}
    this.sky.style.cssText = 'background:black;padding:0;border:0;width:100%;height:100%;overflow:hidden;';
    }
    };
    var xmas_flash = new flash(document.body);
    xmas_flash.init();
    xmas_flash.fire();
    </script>
    </body>
    </html>
      

  8.   

    为什么LZ和34楼的都看不了?IE7?