📄 tools.java
字号:
package src;
import javax.microedition.lcdui.Graphics;
import java.util.Random;
public final class Tools {
public static final int GRAPHICS_TOP_LEFT = Graphics.LEFT | Graphics.TOP;
public static final int posx[] = new int[50];
public static final int posy[] = new int[50];
private static final Random randomizer = new Random();
public static final int getRand(int min, int max) {
int r = Math.abs(randomizer.nextInt());
return (r % ((max - min + 1))) + min;
}
public static final void drawSnow(Graphics graphics) {
graphics.setColor(255, 255, 255);
for (int i = 10; i < 25; i++) {
graphics.fillArc(posx[i], posy[i], 1, 1, 0, 360);
}
for (int i = 25; i < 50; i++) {
graphics.fillArc(posx[i], posy[i], 2, 2, 0, 360);
}
}
public static final void updatesnow(int wind) {
for (int i = 10; i < 25; i++) {// 种类二的雪花的处理
int temp1 = Tools.getRand(1, 3);
posx[i] = posx[i] + wind;
if (temp1 == 1) {
if (posx[i] > -2)
posx[i] = posx[i] - 1;
else {
posx[i] = KingCanvas.SCREEN_WIDTH - Tools.getRand(1, 3);
}
}
if (temp1 == 2) {
if (posx[i] < KingCanvas.SCREEN_WIDTH)
posx[i] = posx[i] + 1;
else {
posx[i] = Tools.getRand(1, 3);
}
}
posy[i] = posy[i] + 2;
if (posy[i] > Tools.getRand(KingCanvas.SCREEN_HEIGHT / 3,
KingCanvas.SCREEN_HEIGHT * 2 / 3)) {
posx[i] = Tools.getRand(0, KingCanvas.SCREEN_WIDTH);
posy[i] = -4;
}
}
for (int i = 25; i < 50; i++) {// 种类三的雪花的处理
int temp2 = Tools.getRand(1, 3);
posx[i] = posx[i] + wind;
if (temp2 == 1) {
if (posx[i] > -2)
posx[i] = posx[i] - 2;
else {
posx[i] = KingCanvas.SCREEN_WIDTH - Tools.getRand(1, 3);
}
}
if (temp2 == 2) {
if (posx[i] < KingCanvas.SCREEN_WIDTH)
posx[i] = posx[i] + 2;
else {
posx[i] = Tools.getRand(1, 3);
}
}
posy[i] = posy[i] + 3;
if (posy[i] > Tools.getRand(KingCanvas.SCREEN_HEIGHT * 3 / 3,
KingCanvas.SCREEN_HEIGHT)) {
posx[i] = Tools.getRand(0, KingCanvas.SCREEN_WIDTH);
posy[i] = -4;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -