diff --git a/build.xml b/build.xml
new file mode 100644
index 0000000..8f85056
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,83 @@
+
+
+
+
+
+ Builds, tests, and runs the project .
+
+
+
diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml
new file mode 100644
index 0000000..d909d8e
--- /dev/null
+++ b/nbproject/build-impl.xml
@@ -0,0 +1,1247 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Classpath to J2ME Ant extension library (libs.j2me_ant_ext.classpath property) is not set. For example: location of mobility/modules/org-netbeans-mobility-antext.jar file in the IDE installation directory.
+ Platform home (platform.home property) is not set. Value of this property should be ${platform.active.description} emulator home directory location.
+ Platform boot classpath (platform.bootclasspath property) is not set. Value of this property should be ${platform.active.description} emulator boot classpath containing all J2ME classes provided by emulator.
+ Must set src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set preprocessed.dir
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set build.classes.dir
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set obfuscated.classes.dir
+
+
+
+ Must set obfuscated.classes.dir
+ Must set obfuscator.srcjar
+ Must set obfuscator.destjar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set preverify.classes.dir
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ MicroEdition-Configuration: ${platform.configuration}
+
+ MicroEdition-Configuration: ${platform.configuration}
+
+
+
+ MicroEdition-Profile: ${platform.profile}
+
+ MicroEdition-Profile: ${platform.profile}
+
+
+
+ Must set dist.jad
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${manifest.midlets}${evaluated.manifest.apipermissions}${evaluated.manifest.pushregistry}${manifest.others}${manifest.jad}
+ ${manifest.midlets}${evaluated.manifest.apipermissions}${evaluated.manifest.pushregistry}${manifest.others}${manifest.manifest}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Starting emulator with port number ${active.debug.port}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Starting emulator with port number ${active.debug.port}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set dist.javadoc.dir
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${all.configurations}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Property deployment.${deployment.method}.scriptfile not set. The property should point to an Ant script providing ${deployment.method} deployment.
+
+
+
+
+
+
+
+ Classpath to Ant Contrib library (libs.ant-contrib.classpath property) is not set.
+
+
+
+
+
+
+
+
+ Active project configuration: @{cfg}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Property build.root.dir is not set. By default its value should be \"build\".
+ Property dist.root.dir is not set. By default its value should be \"dist\".
+
+
+
+
+
diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties
new file mode 100644
index 0000000..282a4f6
--- /dev/null
+++ b/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+build.xml.data.CRC32=d0d3406f
+build.xml.script.CRC32=3289d453
+build.xml.stylesheet.CRC32=9c6a911d
+nbproject/build-impl.xml.data.CRC32=d0d3406f
+nbproject/build-impl.xml.script.CRC32=4f6bb502
+nbproject/build-impl.xml.stylesheet.CRC32=e46c2d22
diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties
new file mode 100644
index 0000000..f5a3bda
--- /dev/null
+++ b/nbproject/private/private.properties
@@ -0,0 +1,7 @@
+#Fri, 06 Jan 2012 21:43:22 +0200
+app-version.autoincrement=true
+config.active=
+deployment.counter=41
+deployment.number=0.0.40
+javadoc.preview=true
+netbeans.user=C:\\Users\\aNNiMON\\.netbeans\\7.1
diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml
new file mode 100644
index 0000000..c1f155a
--- /dev/null
+++ b/nbproject/private/private.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/nbproject/project.properties b/nbproject/project.properties
new file mode 100644
index 0000000..32e9bdf
--- /dev/null
+++ b/nbproject/project.properties
@@ -0,0 +1,142 @@
+abilities=MMAPI=1.1,SATSAJCRMI=1.0,SATSACRYPTO=1.0,JSR82=1.1,NOKIAUI=1.0,JSR226=1.0,capuchin=1.0,MIDP=2.1,JSR229=1.1.0,SATSAAPDU=1.0,CLDC=1.1,JSR177=1.0,JSR179=1.0.1,eSWT=1.1,J2MEWS=1.0,VSCL=2.1,WMA=2.0,JSR172=1.0,JSR256=1.1,SEMC_EXT_JP8=1.0,ColorScreen,NokiaUI=1.0,OBEX=1.0,JSR238=1.0,JSR239=1.0,JSR211=1.0,JSR234=1.0,ScreenWidth=240,MascotV3=1.0,JSR75=1.0,IAPInfo=1.0,SATSAPKI=1.0,JSR184=1.1,ScreenHeight=321,ScreenColorDepth=8,JSR180=1.0.1,J2MEXMLRPC=1.0,
+all.configurations=\
+application.args=
+application.description=
+application.description.detail=
+application.name=
+application.vendor=Vendor
+build.classes.dir=${build.dir}/compiled
+build.classes.excludes=**/*.java,**/*.form,**/*.class,**/.nbintdb,**/*.mvd,**/*.wsclient,**/*.vmd
+build.dir=build/${config.active}
+build.root.dir=build
+debug.level=debug
+debugger.timeout=
+deployment.copy.target=deploy
+deployment.instance=default
+deployment.jarurl=${dist.jar}
+deployment.method=NONE
+deployment.override.jarurl=false
+dist.dir=dist/${config.active}
+dist.jad=LetItSnow.jad
+dist.jar=LetItSnow.jar
+dist.javadoc.dir=${dist.dir}/doc
+dist.root.dir=dist
+extra.classpath=
+filter.exclude.tests=false
+filter.excludes=
+filter.more.excludes=**/overview.html,**/package.html
+filter.use.standard=true
+jar.compress=true
+javac.debug=true
+javac.deprecation=false
+javac.encoding=UTF-8
+javac.optimize=false
+javac.source=1.3
+javac.target=1.3
+javadoc.author=false
+javadoc.encoding=
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+libs.classpath=
+main.class=
+main.class.class=applet
+manifest.apipermissions=
+manifest.file=manifest.mf
+manifest.is.liblet=false
+manifest.jad=
+manifest.manifest=
+manifest.midlets=MIDlet-1: LetItSnow,/icon.png,Main\n
+manifest.others=MIDlet-Vendor: aNNiMON\nMIDlet-Name: LetItSnow\nMIDlet-Version: ${deployment.number}\n
+manifest.pushregistry=
+name=LetItSnow
+no.dependencies=false
+nokiaS80.application.icon=
+nsicom.application.monitorhost=
+nsicom.application.runremote=
+nsicom.application.runverbose=
+nsicom.remoteapp.location=\\My Documents\\NetBeans Applications
+nsicom.remotevm.location=\\Windows\\creme\\bin\\CrEme.exe
+obfuscated.classes.dir=${build.dir}/obfuscated
+obfuscation.custom=@E:\\SETUPS\\Disk\\Programming\\Java\\annimon.pro
+obfuscation.level=1
+obfuscator.destjar=${build.dir}/obfuscated.jar
+obfuscator.srcjar=${build.dir}/before-obfuscation.jar
+platform.active=Sony_Ericsson_SDK_2_5_0_6_for_the_Java_TM__ME_Platform_Emulator_
+platform.active.description=Sony Ericsson SDK 2.5.0.6 for the Java(TM) ME Platform(Emulator)
+platform.apis=JSR234-1.0,SATSA-APDU-1.0,capuchin-1.0,J2ME-WS-1.0,J2ME-XMLRPC-1.0,SATSA-JCRMI-1.0,SATSA-CRYPTO-1.0,JSR239-1.0,MascotV3-1.0,JSR238-1.0,MMAPI-1.1,JSR256-1.1,NokiaUI-1.0,IAPInfo-1.0,JSR229-1.1.0,SATSA-PKI-1.0,JSR180-1.0.1,JSR226-1.0,SEMC_EXT_JP8-1.0,VSCL-2.0,VSCL-2.1,eSWT-1.1,JSR75-1.0,JSR184-1.1,WMA-2.0,JSR211-1.0,JSR82-1.1,JSR177-1.0,JSR179-1.0.1
+platform.bootclasspath=${platform.home}/lib/eswt.jar:${platform.home}/lib/mascotv3.jar:${platform.home}/lib/jsr226.jar:${platform.home}/lib/jsr256.jar:${platform.home}/lib/satsa-crypto.jar:${platform.home}/lib/jsr229.jar:${platform.home}/lib/jsr238.jar:${platform.home}/lib/j2me-xmlrpc.jar:${platform.home}/lib/jsr211.jar:${platform.home}/lib/vscl21.jar:${platform.home}/lib/satsa-jcrmi.jar:${platform.home}/lib/jsr082.jar:${platform.home}/lib/satsa-apdu.jar:${platform.home}/lib/jsr184.jar:${platform.home}/lib/nokiaext.jar:${platform.home}/lib/capuchin.jar:${platform.home}/lib/jsr239.jar:${platform.home}/lib/jsr75.jar:${platform.home}/lib/satsa-pki.jar:${platform.home}/lib/jsr179.jar:${platform.home}/lib/jsr180.jar:${platform.home}/lib/iapinfo.jar:${platform.home}/lib/vscl.jar:${platform.home}/lib/mmapi.jar:${platform.home}/lib/j2me-ws.jar:${platform.home}/lib/wma20.jar:${platform.home}/lib/jsr234.jar:${platform.home}/lib/semc_ext_jp8.jar:${platform.home}/lib/cldcapi11.jar:${platform.home}/lib/midpapi20.jar
+platform.configuration=CLDC-1.1
+platform.device=SonyEricsson_JP8_240x320_Emu
+platform.fat.jar=true
+platform.profile=MIDP-2.0
+platform.trigger=CLDC
+platform.type=UEI-1.0.1
+preprocessed.dir=${build.dir}/preprocessed
+preverify.classes.dir=${build.dir}/preverified
+preverify.sources.dir=${build.dir}/preverifysrc
+resources.dir=resources
+ricoh.application.email=
+ricoh.application.fax=
+ricoh.application.icon=
+ricoh.application.target-jar=
+ricoh.application.telephone=
+ricoh.application.uid=51003948
+ricoh.application.version=
+ricoh.dalp.application-desc.auto-run=false
+ricoh.dalp.application-desc.energy-save=
+ricoh.dalp.application-desc.exec-auth=
+ricoh.dalp.application-desc.visible=true
+ricoh.dalp.argument=
+ricoh.dalp.codebase=
+ricoh.dalp.display-mode.color=true
+ricoh.dalp.display-mode.is-4line-support=false
+ricoh.dalp.display-mode.is-hvga-support=true
+ricoh.dalp.display-mode.is-vga-support=false
+ricoh.dalp.display-mode.is-wvga-support=false
+ricoh.dalp.information.abbreviation=
+ricoh.dalp.information.icon.basepath=
+ricoh.dalp.information.icon.location=
+ricoh.dalp.information.is-icon-used=true
+ricoh.dalp.install.destination=hdd
+ricoh.dalp.install.mode.auto=true
+ricoh.dalp.install.work-dir=hdd
+ricoh.dalp.is-managed=true
+ricoh.dalp.resources.dsdk.version=2.0
+ricoh.dalp.resources.jar.basepath=
+ricoh.dalp.resources.jar.version=
+ricoh.dalp.version=
+ricoh.icon.invert=false
+ricoh.platform.target.version=
+run.cmd.options=
+run.jvmargs=
+run.method=STANDARD
+run.security.domain=trusted
+run.use.security.domain=false
+savaje.application.icon=
+savaje.application.icon.focused=
+savaje.application.icon.small=
+savaje.application.uid=TBD
+savaje.bundle.base=
+savaje.bundle.debug=false
+savaje.bundle.debug.port=
+semc.application.caps=
+semc.application.icon=
+semc.application.icon.count=
+semc.application.icon.splash=
+semc.application.icon.splash.installonly=false
+semc.application.uid=E8047253
+semc.certificate.path=
+semc.private.key.password=
+semc.private.key.path=
+sign.alias=
+sign.enabled=false
+sign.keystore=
+src.dir=src
+use.emptyapis=true
+use.preprocessor=true
diff --git a/nbproject/project.xml b/nbproject/project.xml
new file mode 100644
index 0000000..89e5256
--- /dev/null
+++ b/nbproject/project.xml
@@ -0,0 +1,10 @@
+
+
+ org.netbeans.modules.kjava.j2meproject
+
+
+ LetItSnow
+ 1.6
+
+
+
diff --git a/src/DrawParticles.java b/src/DrawParticles.java
index 8a73b7e..8efdec3 100644
--- a/src/DrawParticles.java
+++ b/src/DrawParticles.java
@@ -22,7 +22,8 @@ public class DrawParticles extends Canvas implements Runnable {
/* Время, после которого меняется направление ветра */
private long timeToChangeWind;
private Background bg;
- private Image background;
+ private Graphics G;
+ private Image background, I;
private Vector particles;
@@ -30,6 +31,8 @@ public class DrawParticles extends Canvas implements Runnable {
setFullScreenMode(true);
w = getWidth();
h = getHeight();
+ I = Image.createImage(w, h);
+ G = I.getGraphics();
autoChangeTime = true;
hour = Util.getHour();
speed = MIN_SPEED;
@@ -39,19 +42,25 @@ public class DrawParticles extends Canvas implements Runnable {
bg = new Background(w, h);
background = bg.generateImage();
particles = new Vector();
- for (int i = 0; i < (h/64); i++) {
- particles.addElement(new Snow(w, h, MAX_SNOW));
- }
+ //for (int i = 0; i < (h/64); i++) {
+ particles.addElement(new Snow(w, h, MAX_SNOW*(h/64)));
+ //}
new Thread(this).start();
}
public void paint(Graphics g) {
+ draw(G);
+ g.drawImage(I, 0, 0, 20);
+ }
+
+ private void draw(Graphics g) {
g.drawImage(background, 0, 0, 20);
bg.drawStar(g);
// рисуем системы
- for (int i = 0; i < particles.size(); i++) {
+ int i = 0;
+ //for (int i = 0; i < particles.size(); i++) {
((ParticleSystem) particles.elementAt(i)).render(g);
- }
+ //}
// эффекты времени суток
if (Parameters.timeEffects) bg.postDraw(g);
// инфа
@@ -173,6 +182,9 @@ public class DrawParticles extends Canvas implements Runnable {
} else if (key == KEY_NUM9) {
Parameters.timeEffects = !Parameters.timeEffects;
}
+ else if (key == KEY_NUM0) {
+ Main.midlet.destroyApp(true);
+ }
}
}
diff --git a/src/ParticleSystem.java b/src/ParticleSystem.java
index 922d5dd..a9b0045 100644
--- a/src/ParticleSystem.java
+++ b/src/ParticleSystem.java
@@ -1,4 +1,5 @@
+import java.util.Vector;
import javax.microedition.lcdui.Graphics;
/*
@@ -12,13 +13,13 @@ import javax.microedition.lcdui.Graphics;
*/
public abstract class ParticleSystem {
- /* Массив частицы */
- protected Point3D[] particles;
+ /* Массив частиц */
+ protected Vector particles;
protected Rectangle window;
public ParticleSystem(int x, int y, int w, int h, int numOfParticles) {
window = new Rectangle(x, y, w, h);
- particles = new Point3D[numOfParticles];
+ particles = new Vector();
}
/* Отрисовка системы частиц */
@@ -33,16 +34,26 @@ public abstract class ParticleSystem {
return resetParticle();
}
+ /* Добавление частицы на основе заданной */
+ protected Point3D addParticle(Point3D object) {
+ return resetParticle(object);
+ }
+
/* Сброс свойств частицы */
protected abstract Point3D resetParticle();
+ /* Сброс свойств частицы к заданным */
+ protected abstract Point3D resetParticle(Point3D object);
/* Обновление свойств частиц */
protected abstract void update();
/* Отрисовка частиц */
protected abstract void draw(Graphics g);
+
+
/* Точка в 3D */
protected class Point3D {
float x, y, z;
+ boolean enable;
}
/* Прямоугольник */
diff --git a/src/Snow.java b/src/Snow.java
index 67a9a65..05e16b8 100644
--- a/src/Snow.java
+++ b/src/Snow.java
@@ -25,8 +25,8 @@ public class Snow extends ParticleSystem {
public Snow(int w, int h, int numOfParticles) {
super(0, 0, w, h, numOfParticles);
MAX_Z = w / 15;
- for (int i = 0; i < particles.length; i++) {
- particles[i] = addParticle();
+ for (int i = 0; i < numOfParticles; i++) {
+ particles.addElement(addParticle());
}
}
@@ -43,6 +43,7 @@ public class Snow extends ParticleSystem {
/* Начальные свойства снежинки */
protected Point3D resetParticle() {
Point3D snow = new Point3D();
+ snow.enable = true;
snow.z = Util.random(1, MAX_Z);
int w_x = (int) (window.x / snow.z);
int w_y = (int) (window.y / snow.z);
@@ -54,52 +55,84 @@ public class Snow extends ParticleSystem {
return snow;
}
+
+ /* Начальные свойства снежинки на основе заданной */
+ protected Point3D resetParticle(Point3D src) {
+ Point3D snow = new Point3D();
+ snow.enable = true;
+ snow.z = src.z;
+ int w_x = (int) (window.x / snow.z);
+ int w_y = (int) (window.y / snow.z);
+ int w_w = (int) (window.w * snow.z);
+ int w_h = (int) (window.h * snow.z);
+ snow.x = Util.random(w_x, w_w);
+ // создаём снежинки за экраном
+ snow.y = Util.random(w_y, w_h);
+
+ return snow;
+ }
protected void update() {
- for (int i = 0; i < particles.length; i++) {
- particles[i].x += 2*Math.cos(windAngle);// ветер по X
- particles[i].z += 0.01f*Math.sin(windAngle);// ветер по Z
- particles[i].y = particles[i].y + speed + 0.981f; // скорость + притяжение
- if (particles[i].z < MIN_Z) {
- particles[i].z = MAX_Z;
- particles[i].x = Util.random((int) (window.x / particles[i].z),
- (int) (window.h * particles[i].z));
- particles[i].y = window.y-Util.random(0, 10);
- } else if (particles[i].z > MAX_Z) {
- particles[i].x = window.w + Util.random(0, 10);
- particles[i].y = Util.random((int) (window.y / particles[i].z),
- (int) (window.w * particles[i].z));
- particles[i].z = MIN_Z;
+ int size = particles.size();
+ for (int i = 0; i < size; i++) {
+ Point3D particle = (Point3D) particles.elementAt(i);
+ if (!particle.enable) continue;
+ particle.x += 2*Math.cos(windAngle);// ветер по X
+ particle.z += 0.01f*Math.sin(windAngle);// ветер по Z
+ particle.y = particle.y + speed + 0.981f; // скорость + притяжение
+ if (particle.z < MIN_Z) {
+ particle.z = MAX_Z;
+ particle.x = Util.random((int) (window.x / particle.z),
+ (int) (window.h * particle.z));
+ particle.y = window.y-Util.random(0, 10);
+ } else if (particle.z > MAX_Z) {
+ particle.x = window.w + Util.random(0, 10);
+ particle.y = Util.random((int) (window.y / particle.z),
+ (int) (window.w * particle.z));
+ particle.z = MIN_Z;
}
- int x = (int) (particles[i].x / particles[i].z);
- int y = (int) (particles[i].y / particles[i].z);
- int w_x = (int) (window.x / particles[i].z);
- int w_y = (int) (window.y / particles[i].z);
- int w_w = (int) (window.w * particles[i].z);
+ int x = (int) (particle.x / particle.z);
+ int y = (int) (particle.y / particle.z);
+ int w_x = (int) (window.x / particle.z);
+ int w_y = (int) (window.y / particle.z);
+ int w_w = (int) (window.w * particle.z);
int wind_x = (int) (2*Math.cos(windAngle));
- int y_max = (int) (window.h - (particles[i].z * window.h/3)/MAX_Z);
- if (y > y_max) {//if (y > window.h) {
- if (wind_x > 0) particles[i].x = Util.random(w_x-wind_x*10, w_w);
- else if (wind_x < 0) particles[i].x = Util.random(w_x, w_w-wind_x*10);
- else particles[i].x = Util.random(w_x, w_w);
- particles[i].y = w_y - Util.random(0, 10);
- } else if (particles[i].x > w_w) {
- if (wind_x > 0) particles[i].x = w_x-Util.random(0, 10);
+ int y_max = (int) (window.h - (particle.z * window.h/3)/MAX_Z);
+ if (y > y_max) {
+ // Упало на землю
+ if (wind_x > 0) particle.x = Util.random(w_x-wind_x*10, w_w);
+ else if (wind_x < 0) particle.x = Util.random(w_x, w_w-wind_x*10);
+ else particle.x = Util.random(w_x, w_w);
+ // Если снежинка возле экрана и такой еще нет
+ boolean contain = particles.contains(particle);
+ if ( (particle.z < (MAX_Z/3)) && (particles.size() < 700) && contain ) {
+ // То исключаем её из обработки
+ // и добавляем новую
+ particle.enable = false;
+ particles.addElement(addParticle(particle));
+ } else {
+ // Иначе перемещаем её вверх
+ particle.y = w_y - Util.random(0, 10);
+ }
+ } else if (particle.x > w_w) {
+ if (wind_x > 0) particle.x = w_x-Util.random(0, 10);
} else if (x < w_x) {
- particles[i].x = w_w+Util.random(0, 10);
- particles[i].y = Util.random((int) (window.y / particles[i].z),
- (int) (window.w * particles[i].z));
+ particle.x = w_w+Util.random(0, 10);
+ particle.y = Util.random((int) (window.y / particle.z),
+ (int) (window.w * particle.z));
}
+ particles.setElementAt(particle, i);
}
}
protected void draw(Graphics g) {
- for (int i = 0; i < particles.length; i++) {
- if (particles[i].z < MIN_Z) continue;
- g.setColor(Util.colorFromBrightness(255 - (int)(particles[i].z * (128 / MAX_Z))));
- int x = (int) (particles[i].x / particles[i].z);
- int y = (int) (particles[i].y / particles[i].z);
- int radius = (int) (MAX_Z / particles[i].z);
+ for (int i = 0; i < particles.size(); i++) {
+ Point3D particle = (Point3D) particles.elementAt(i);
+ if (particle.z < MIN_Z) continue;
+ g.setColor(Util.colorFromBrightness(255 - (int)(particle.z * (128 / MAX_Z))));
+ int x = (int) (particle.x / particle.z);
+ int y = (int) (particle.y / particle.z);
+ int radius = (int) (MAX_Z / particle.z);
if (radius < 2) g.drawLine(x, y, x, y);
else drawSnow(g, x, y, radius);
}