📄 dotone.java
字号:
package FireFlower;
import java.awt.Color;
import java.awt.Graphics;
import java.util.Random;
import java.util.Vector;
//此类为爆炸后会画线的式样
class DotOne extends Dot{
public DotOne(Color col,int endX,int endY){
super(col, endX, endY);
pace=10;
}
public LittleDot[] initBlast(){
//初始化爆炸的情况
final int ONE=20;//这是爆炸的第一圈的半径
Random rand=new Random();
int blastX=endPoint.x-ONE*circle;
int blastY=endPoint.y-ONE*circle;
if(Math.random()<0.3){
for(int i=0;i<ld.length;i++){
ld[i]=new LittleDot(rand.nextInt(ONE*circle*2)+blastX,
rand.nextInt(ONE*circle*2)+blastY,
new Color(rand.nextInt(256),rand.nextInt(256),rand.nextInt(256)));
//设置该点的速度
ld[i].setPace(WALLOP,endPoint.x,endPoint.y);
}//for
}//if
else {
for(int i=0;i<ld.length;i++){
ld[i]=new LittleDot(rand.nextInt(ONE*circle*2)+blastX,
rand.nextInt(ONE*circle*2)+blastY,
col);
ld[i].setPace(WALLOP,endPoint.x,endPoint.y);
}//for
}//else
col=new Color(225,203,114);
size=10;
state=3;
return ld;
}
public LittleDot[] blast(){
//处理爆炸的情况
final int EVERY=40;//爆炸的每圈的半径
Random rand=new Random();
if(circle<=4){
for(int i=0;i<ld.length;i++){
//前三圈按照下面的代码来计算爆炸点的碎花的位置
ld[i].setPlace();
}//for
}//if
return ld;
}
public void myPaint(Graphics g,Vector lList){
if(this.state==3){
if(Math.random()<0.5){
g.setColor(new Color(220,220,200)); }
else g.setColor(col);
for(int i=0;i<ld.length;i++){
g.drawLine(x,y,ld[i].x,ld[i].y);}
}
super.myPaint(g,lList);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -