# I am coding gravity but its stuttering

I am making a 2d platformer and am working on gravity and collision but when I actually get the collision working my gravity became very stuttery, is there a way to fix this? here is code:

```gravity(){
if(this.y <= 400 - this.scale){
let gc = get(this.x, this.y + 20);
print(gc);
if(gc == 0 && gc == 0 && gc == 255 && gc == 255){
return;
}
else{
this.y += 2;
}
}
}
```

edit: I have heard this should be working so I will provide more code to see if it helps. here is the function that runs everything:

```    var groundArray = [];
groundArray = ;
groundArray = ;
groundArray = ;
groundArray = ;
groundArray = ;
groundArray = ;
groundArray = ;
groundArray = ;
groundArray = ;
groundArray = [1, 1];

function setup() {
noStroke();
createCanvas(400, 400);
for(let y = 0; y < groundArray.length; y++){
for(let x = 0; x < groundArray[y].length; x++){
if(groundArray[y][x] != 0){
groundArray[y][x] = new ground(x * 40, y * 40);
}
}
}
}

var play = new player(35, 0, 20);

function draw() {
background(255);
for(let y = 0; y < groundArray.length; y++){
for(let x = 0; x < groundArray[y].length; x++){
if(groundArray[y][x] != 0){
groundArray[y][x].draw();
}
}
}
play.draw();

play.gravity();
}
```

Normally a function named `draw()` is called every frame, is that what’s happening here? It looks like it. In which case, do you really want to be calling `new ground(x * 40, y * 40)` every frame, wouldn’t this object creation be better placed in `setup()`?