# Why does my spikes not show up?

**URL:** <https://discourse.processing.org/t/why-does-my-spikes-not-show-up/5161>\
**Category:** Coding Questions\
**Created:** [November 3, 2018, 4:10pm UTC](https://discourse.processing.org/t/why-does-my-spikes-not-show-up/5161 "2018-11-03T16:10:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xeeker](https://avatars.discourse-cdn.com/v4/letter/x/b5ac83/32.png) [@Xeeker](https://discourse.processing.org/u/Xeeker)\
**Post date:** [November 3, 2018, 4:10pm UTC](https://discourse.processing.org/t/why-does-my-spikes-not-show-up/5161/1 "2018-11-03T16:10:18Z")

</div>

```auto
float x = 150;
float y = 200;

float okning = 3;
int toggle = 0;
float r;
int gravity = 0.07;
int velocity;

int NumbOfSpikes = 10;

//S stands for Spike
float[] SPos = new float [NumbOfSpikes];
float[] SX = new float [NumbOfSpikes];
float[] SHeight = new float [NumbOfSpikes];

void setup() {
   size(900,600);
   
   
   //Spike Creation
   for(int i = 0; i < NumbOfSpikes; i++){
      SPos[i] = int(random(1,2));
      SX[i] = int(random(700,900));
      SHeight[i] = int(random(50,150));
   }
   
}

void draw() {
   //Background
   background(#132627);
   
   //Stripe
   pushMatrix();
   translate(-200,200);
   rotate(radians(-50));
   fill(#17403c);
   noStroke();
   rect(0,0,1500,170);
   popMatrix();
   
   //Spikes
   for(int i = 0; i < NumbOfSpikes; i++){
      triangle(SX[i],600,SX[i]+SHeight[i]/2,600,SX+SHeight[i]/4,SHeight[i]*-1)
      
      SX[i] -= 1;
      }
   
   //Body Mechanics
   //Switch Course
   velocity += gravity;
   
   if(get(x+50,y+50+velocity) == color(#132627)){
      if(okning > 0) y += velocity;
   }
   
   if(get(x+50,y+50-velocity) == color(#132627)){
      if(okning < 0) y -= velocity;
   }  
   
   if(mousePressed) velocity = 0;
   
   //Direction of Char
   if(okning > 0 && r < 30) r++
   if(okning < 0 && r > -30) r--  
   
   y += r/10;
   
   //Controls
   if(mousePressed && toggle == 0) {
      toggle = 1;
      okning = -okning;
   }
   
   //Character
   pushMatrix()
   translate(x+50,y+50);
   rotate(radians(r));
   
   //Shadow
   fill(#447653);
   triangle(-40,-30,-40,50,40,10);
   
   //Main body
   fill(#50ff70);
   triangle(-40,-40,-40,40,40,00);
   
   popMatrix();
   
   //Help
   //text(r,20,20);
   //text(y,20,40);
   
}
void mouseReleased() {
   toggle = 0;
}

```

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [November 3, 2018, 6:28pm UTC](https://discourse.processing.org/t/why-does-my-spikes-not-show-up/5161/2 "2018-11-03T18:28:48Z")

</div>

Hey,

Before that, try to debug your code on your own, there’s a lot of little mistakes (replace `int` by `float` for example…) that prevent you from running your code properly.

---

<div class="post-metadata">

**Author:** ![Xeeker](https://avatars.discourse-cdn.com/v4/letter/x/b5ac83/32.png) [@Xeeker](https://discourse.processing.org/u/Xeeker)\
**Post date:** [November 3, 2018, 6:39pm UTC](https://discourse.processing.org/t/why-does-my-spikes-not-show-up/5161/3 "2018-11-03T18:39:52Z")

</div>

Hello!  
Ive already found the issue (and fixed all small mistakes)  
But really appreciete the attempt of help  
Thank you!
