# Help needed (Processing)

**URL:** <https://discourse.processing.org/t/help-needed-processing/1134>\
**Category:** Coding Questions\
**Created:** [June 20, 2018, 8:16pm UTC](https://discourse.processing.org/t/help-needed-processing/1134 "2018-06-20T20:16:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adlertag](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@adlertag](https://discourse.processing.org/u/adlertag)\
**Post date:** [June 20, 2018, 8:16pm UTC](https://discourse.processing.org/t/help-needed-processing/1134/1 "2018-06-20T20:16:02Z")

</div>

What is wrong with this Sketck?

//////////////////////////////////////////////////////  
Ptica[] p = new Ptica[1200];  
int N = 100;

void setup() {  
size(1280, 900);  
for(int i=0; i \< N; i++) {  
p[i] = new Ptica(random(width), random(height)); } }

void draw() {  
background(32, 112, 80);  
for(int i=0; i \< N; i++) {  
p[i].leti(i); } }

void mousePressed() {  
if(N \< 1200) {  
N = N + 1;  
println(“n =”, str(N));  
p[N] = new Ptica(mouseX, mouseY); } }

///////////////////////////////////////////////////////////////////

class Ptica {  
//varijable vidljive u cijeloj klasi  
float x;  
float y;  
float azimut;  
float brzina;  
float r;

//konstruktor (Lee)  
Ptica(float tx, float ty) {  
azimut = random(TWO\_PI);  
brzina = random(1,3);  
r = 3.0;  
x = tx;  
y = ty; }

//metode klase Ptica  
void sudar(int j) {  
for(int i = 0; i \< N; i++) {  
if(i != j) {  
float d = dist(p[i].x,p[i].y, p[j].x,p[j].y);  
if(d \< 6) {  
p[i] = p[N-1];  
p[j] = p[N-2];  
N = N - 2; } } } }

void leti(int i) {  
translacija();  
sudar(i);  
provjeri\_rubove();  
//println(N);  
crtaj(i); }

void translacija() {  
float dx = brzina_cos(azimut);  
float dy = brzina_sin(azimut);  
x = x + dx;  
y = y + dy; }

void crtaj(int i) {  
textSize(16);  
text(str(i), x+8, y+8);

```
fill(200,100);
stroke(255);

pushMatrix();
  translate(x, y);
  rotate(azimut + 0.5*PI);
  beginShape(TRIANGLES);
    vertex(0, -r*2);
    vertex(-r, r*2);
    vertex(r, r*2);
  endShape();
popMatrix(); }

```

void provjeri\_rubove() {  
if(x \< 0) x = width;  
if(y \< 0) y = height;  
if(x \> width) x = 0;  
if(y \> height) y = 0; } }

---

<div class="post-metadata">

**Author:** ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)\
**Post date:** [June 21, 2018, 12:00am UTC](https://discourse.processing.org/t/help-needed-processing/1134/2 "2018-06-21T00:00:35Z")

</div>

Can you please format your code? Highlight it and press the `</>` code button to preserve indentation.

What exactly does this code do? What do you expect it to do? How are those two things different? Which line of code is behaving differently from what you expected?

Have you tried [debugging](http://happycoding.io/tutorials/processing/debugging) your code?
