Problem with my collisions need help

My friend and I are working on this labyrinth and it was working but Yoshi were able to cross the wall so i added the function get() and i wanted my yoshi to walk in a direction if the key was pressed and if the color of the pixel in the same direction my yoshi is going is white but now my yoshi isn’t moving.
Thanks for replying.

ps: I’m french

PImage labyFond;
int x;
int y;
PImage[] Yoshi = new PImage[7];

color b = color (255,255,255); //White

color q;
color r;
color s;
color t;

void setup()
{
size(1024,1024);
frameRate(30);
labyFond = loadImage(“laby.png”);

Yoshi[0] = loadImage( “Yoshi0.gif” );
Yoshi[1] = loadImage( “Yoshi1.gif” );
Yoshi[2] = loadImage( “Yoshi2.gif” );
Yoshi[3] = loadImage( “Yoshi3.gif” );
Yoshi[4] = loadImage( “Yoshi4.gif” );
Yoshi[5] = loadImage( “Yoshi5.gif” );
Yoshi[6] = loadImage( “Yoshi6.gif” );

x=-5;
y=117;
// get the color of the pixel next to Yoshi :
q =get(x,y-5); //Color above Yoshi
r= get(x,y+5); //Color under Yoshi
s= get(x-5,y); //Color on the left of Yoshi
t= get(x+5,y); //Color on the right of Yoshi
}

void draw()
{
background(labyFond);

image( labyFond, 0, 0, width, height );
image( Yoshi[frameCount%1], x, y );
}

void keyPressed(){
if (key==CODED){
if ((keyCode==UP) &&( q == b)) {
y = y-2; // notre Yoshi avance vers le haut
image( labyFond, 0, 0, width, height );
image( Yoshi[frameCount%7], x, y );
}

if ((keyCode==DOWN)&&( r == b)) {
  y = y+2; // notre Yoshi avance vers le bas
  image( labyFond, 0, 0, width, height );
  image( Yoshi[frameCount%7], x, y );
}
if ((keyCode==LEFT)&&( s == b)) {
  x = x-2; // notre Yoshi avance vers la gauche
  image( labyFond, 0, 0, width, height );
  image( Yoshi[frameCount%7], x, y );
}
if ((keyCode==RIGHT)&&( t == b)) {
  x = x+2; // notre Yoshi avance vers la droite
    image( labyFond, 0, 0, width, height );
    image( Yoshi[frameCount%7], x, y );
}

}

}

-1- if you want check on the color of pixel
i think it should be not done in setup /only at beginning

-a- copy that 4 lines out of setup
-b- put it in a extra function

-c- and call that when moving.

-2- other thing:
the image calls in keypress better delete
as they are overwritten by draw.

void keyPressed() {
  if (key==CODED) {
    if ((keyCode==UP)   &&( q == b)) y = y-2; // notre Yoshi avance vers le haut
    if ((keyCode==DOWN) &&( r == b)) y = y+2; // notre Yoshi avance vers le bas
    if ((keyCode==LEFT) &&( s == b)) x = x-2; // notre Yoshi avance vers la gauche
    if ((keyCode==RIGHT)&&( t == b)) x = x+2; // notre Yoshi avance vers la droite
  }
  color_check();                              // for next move
}


void color_check() {    // called at setup and after every move
  q =get(x, y-5); //Color above Yoshi
  r= get(x, y+5); //Color under Yoshi
  s= get(x-5, y); //Color on the left of Yoshi
  t= get(x+5, y); //Color on the right of Yoshi  
}

Thanks i’ll try that
And about the overwritting i was thinking about it but i wasn’t sure like it was my friend part

you move by 2 pix, and check by 5pix? what is the idea?

Was juste trying some stuff but i’ll change that

still not working i don’t understand

PImage labyFond;

int x;

int y;

PImage[] Yoshi = new PImage[7];

color b = color (255,255,255); //White

color q;

color r;

color s;

color t;

void setup()

{

size(1024,1024);

frameRate(30);

labyFond = loadImage(“laby.png”);

Yoshi[0] = loadImage( “Yoshi0.gif” );

Yoshi[1] = loadImage( “Yoshi1.gif” );

Yoshi[2] = loadImage( “Yoshi2.gif” );

Yoshi[3] = loadImage( “Yoshi3.gif” );

Yoshi[4] = loadImage( “Yoshi4.gif” );

Yoshi[5] = loadImage( “Yoshi5.gif” );

Yoshi[6] = loadImage( “Yoshi6.gif” );

x=-5;

y=117;

}

void check_color(){

// get the color of the pixel next to Yoshi :

q =labyFond.get(x,y-2); //Color above Yoshi

r= labyFond.get(x,y+2); //Color under Yoshi

s= labyFond.get(x-2,y); //Color on the left of Yoshi

t= labyFond.get(x+2,y); //Color on the right of Yoshi

}

void draw()

{

background(labyFond);

image( labyFond, 0, 0, width, height );

image( Yoshi[frameCount%1], x, y );

}

void keyPressed(){

check_color();

if (key==CODED){

if ((keyCode==UP) &&( q == b)) {

y = y-2; // notre Yoshi avance vers le haut

}

if ((keyCode==DOWN)&&( r == b)) {

y = y+2; // notre Yoshi avance vers le bas

}

if ((keyCode==LEFT)&&( s == b)) {

x = x-2; // notre Yoshi avance vers la gauche

}

if ((keyCode==RIGHT)&&( t == b)) {

x = x+2; // notre Yoshi avance vers la droite

}

}

}

pls.
-a- do not show your email here!!
-b- pls post your code using the code formatter

</>

you changed get(x,y) to labyFond.get(x,y)
why? that i can not test here

pls, as i can not follow better describe what is not working?
its not moving at all OR it walks through other colors as WHITE?

also take a look at that example i just made: