📄 alcsnow.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: alcsnow.java
import java.applet.Applet;
import java.awt.*;
import java.util.Random;
public class alcsnow extends Applet
implements Runnable
{
Thread mainThread;
Image offScrn;
Graphics offGrph;
Random rand;
int stopFlag;
long stopTime;
int snowX[];
int snowY[];
int snows;
int wind;
int threadSleep;
Dimension dim;
Image gAlc[];
MediaTracker mt;
public void init()
{
rand = new Random();
dim = size();
offScrn = createImage(dim.width, dim.height);
offGrph = offScrn.getGraphics();
String s = getParameter("snows");
if(s == null)
snows = 100;
else
snows = Integer.valueOf(s).intValue();
if(snows > 500)
snows = 500;
s = getParameter("threadsleep");
if(s == null)
threadSleep = 80;
else
threadSleep = Integer.valueOf(s).intValue();
if(threadSleep < 10)
threadSleep = 10;
else
if(threadSleep > 1000)
threadSleep = 1000;
snowX = new int[snows];
snowY = new int[snows];
for(int i = 0; i < snows; i++)
{
snowX[i] = rand.nextInt() % (dim.width / 2) + dim.width / 2;
snowY[i] = rand.nextInt() % (dim.height / 2) + dim.height / 2;
}
s = getParameter("graphic");
if(s == null)
{
s = getParameter("graph");
if(s == null)
{
s = getParameter("grph");
if(s == null)
s = "tento1.gif";
}
}
mt = new MediaTracker(this);
gAlc = new Image[1];
gAlc[0] = getImage(getDocumentBase(), s);
mt.addImage(gAlc[0], 0);
try
{
mt.waitForID(0);
}
catch(InterruptedException _ex)
{
return;
}
stopFlag = 0;
}
public void start()
{
if(mainThread == null)
{
mainThread = new Thread(this);
mainThread.start();
}
}
public void stop()
{
mainThread = null;
}
public void run()
{
while(mainThread != null)
{
try
{
Thread.sleep(threadSleep);
}
catch(InterruptedException _ex)
{
return;
}
repaint();
}
}
public void paint(Graphics g)
{
offGrph.setColor(Color.black);
offGrph.fillRect(0, 0, dim.width, dim.height);
offGrph.drawImage(gAlc[0], 0, 0, this);
drawBackSnow();
g.drawImage(offScrn, 0, 0, null);
}
public void update(Graphics g)
{
paint(g);
}
public void drawBackSnow()
{
offGrph.setColor(Color.white);
for(int i = 0; i < snows; i++)
{
offGrph.fillRect(snowX[i], snowY[i], 1, 1);
snowX[i] += rand.nextInt() % 2 + wind;
snowY[i] += (rand.nextInt() % 6 + 5) / 5 + 1;
if(snowX[i] >= dim.width)
snowX[i] = 0;
if(snowX[i] < 0)
snowX[i] = dim.width - 1;
if(snowY[i] >= dim.height || snowY[i] < 0)
{
snowX[i] = Math.abs(rand.nextInt() % dim.width);
snowY[i] = 0;
}
}
switch(rand.nextInt() % 100)
{
case -2:
wind = -2;
return;
case -1:
wind = -1;
return;
case 0: // '\0'
wind = 0;
return;
case 1: // '\001'
wind = 1;
return;
case 2: // '\002'
wind = 2;
return;
}
}
public alcsnow()
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -