[pjs] noise() values problem?
in
Processing with Other Languages
•
5 months ago
I have a strange problem.
It works on Processing, but not when exporting to the web.
At first, I thought it was something to do with some
compatibility with processing.js with the
noise() function on the draw() function.
I tried passing the ArrayList to the Class method -not through the Constructor- , and I had the same result.
This is passing the ArrayList to the Class,
- ArrayList<Estrella> Estrellas;
- float EstrellasT;
- void setup() {
- size(800, 480);
- Estrellas = new ArrayList<Estrella>();
- }
- void draw() {
- background(0);
- EstrellasT = random(5,15);
- float noiseX = noise(1, frameCount/50.0)*width;
- float noiseY = noise(2, frameCount/60.0)*height;
- if (frameCount % 60 == 0){
- println(noiseX+" , "+noiseY);
- Estrellas.add(new Estrella(noiseX, noiseY, EstrellasT, Estrellas));
- }
- for (int i = Estrellas.size()-1; i >= 0; i--) {
- Estrella tal = Estrellas.get(i);
- tal.mostrar();
- if (tal.murio()) {
- Estrellas.remove(i);
- }
- }
- }
- void mousePressed() {
- Estrellas.add(new Estrella(mouseX, mouseY, EstrellasT, Estrellas));
- }
- class Estrella {
- float x;
- float y;
- float d;
- float vida = 350;
- int DIST_MIN = width/4;
- ArrayList<Estrella> EstrellasCol;
- Estrella(float tempX, float tempY, float tempD, ArrayList<Estrella> tempEstrellasCol) {
- x = tempX;
- y = tempY;
- d = tempD;
- EstrellasCol = tempEstrellasCol;
- }
- float getX() {
- return x;
- }
- float getY() {
- return y;
- }
- boolean murio() {
- vida--;
- if (vida < 0) {
- return true;
- }
- else {
- return false;
- }
- }
- void lineas() {
- for(int i=0; i < EstrellasCol.size(); i++){
- Estrella temp = EstrellasCol.get(i);
- if (dist(x, y, temp.getX(), temp.getY()) < DIST_MIN) {
- line(x, y, temp.getX(), temp.getY());
- }
- }
- }
- void mostrar() {
- fill(255, vida);
- stroke(255, vida);
- this.lineas();
- ellipse(x, y, d, d);
- }
- }
1