java满天星星下坠代码 满天星python

实现星星闪动的java代码

package panel;

站在用户的角度思考问题,与客户深入沟通,找到赤壁网站设计与赤壁网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都做网站、成都网站制作、企业官网、英文网站、手机端网站、网站推广、域名与空间、网页空间、企业邮箱。业务覆盖赤壁地区。

import java.awt.Color;

import java.awt.Font;

import java.awt.Graphics;

import javax.swing.JPanel;

import main.MainTank;

public class TipPanel extends JPanel implements Runnable{

/**

*

*/

private static final long serialVersionUID = 1L;

//偶数打印,画面板

int time=0;

public void paintComponent(Graphics g){

super.paint(g);

g.fillRect(0, 0, MainTank.getWidthOfGame(), MainTank.getHeightOfGame());//绘制提示窗口

if (time%2==0){//偶数打印,画面板,造成闪烁效果

g.setColor(Color.ORANGE);

Font font=new Font("华文楷体",Font.BOLD,30);

g.setFont(font);//选用字体

g.drawString("Ready", 140, 130);

}

}

@Override

public void run() {

while (true){

try{

Thread.sleep(250);

}catch (Exception e){

e.getMessage();

}

time++;//绘图开关

this.repaint();

}

}

}//TipPanel

类似的,修改下就行

用Java语言打星星

第一个的代码如下,可以改变i的数值来控制X形状的大小

class Test

{

public static void main(String[] args)

{

int i=3;

int j=i*2-1;

int k,l;

for(;j0;j--)

{

k=(i-1)-Math.abs(j-i);

l=Math.abs(j-i)*2-1;

for(;k0;k--)

{

System.out.print(" ");

}

System.out.print("*");

if(l0)

{

for(;l0;l--)

{

System.out.print(" ");

}

System.out.print("*");

}

System.out.print("\n");

}

}

}

你第二个我也没看明白,不过思路应该都差不多,你根据这一个自己琢磨琢磨吧,关键问题就在k和l的计算上.

页面特效:下星星的代码(JAVA代码)

以下的代码就可以,lz自己在*的地方填入星星的图片就可以了

body bgcolor=#ee3300

style

.drop { position: absolute; width: 3; filter: flipV(), flipH(); font-size: 40; color: #ffffff }

/style

script language="javascript"

snow = false; // false-rain; true-snow

snowsym = " * " are the symbols for each

rainsym = " * " can put images here.

howmany = 20 many drops/snowflakes?

/**************Do not need to change anything below***********/

if(snow){sym = snowsym; speed=1; angle=10; drops=howmany}

else{sym = rainsym; speed=30; drops=howmany; angle=6}

movex = -speed/angle; movey = speed; count = 0;

function moverain(){

for(move = 0; move drops; move++){

xx[move]+=movex; yy[move]+=mv[move];

hmm = Math.round(Math.random()*1);

if(xx[move] 0){xx[move] = maxx+10;}

if(yy[move] maxy){yy[move] = 10;}

drop[move].left = xx[move]

drop[move].top = yy[move]+document.body.scrollTop;

}setTimeout('moverain()','1')}

/script

script language="javascript"

if (document.all){

drop = new Array(); xx = new Array(); yy = new Array(); mv = new Array()

ly = "document.all[\'"; st = "\'].style"

for(make = 0; make drops; make++){

document.write('div id="drop'+make+'" class=drop'+sym+'/div');

drop[make] = eval(ly+'drop'+make+st);

maxx = document.body.clientWidth-40

maxy = document.body.clientHeight-40

xx[make] = Math.random()*maxx;

yy[make] = -100-Math.random()*maxy;

drop[make].left = xx[make]

drop[make].top = yy[make]

mv[make] = (Math.random()*5)+speed/16;

drop[make].fontSize = (Math.random()*10)+20;

if(snow){col = 'white'}else{col = 'white'}

drop[make].color = col;

}

window.onload=moverain

}

/script

/body


网站栏目:java满天星星下坠代码 满天星python
分享链接:http://azwzsj.com/article/dojcgps.html