Game collision dection problem

hi
this is for a university project. on line 223 I am having trouble making so the player doesn’t go over the water. I cant figure out a way for the player to not move over the water without the player getting stuck could someone please help me

character c1 = new character();
desertbackground bg = new desertbackground(750,500,1500, 1000);
wbackground w1 = new wbackground(600,200,400,200);
void setup() {
size(1500, 1000);
c1.values();
bg.varable();
frameRate(30);
}

void draw() {
background(100);

bg.display();
w1.display();
c1.move();

}

class character{
float winner, hinner, xpos, ypos, xmove, ymove, xwpos, ywpos, fillVal, swordx, swordy, swordsx, swordsy, xrestrict, yrestrict,xwmove,ywmove,xscale,yscale;
boolean sword, upface, downface, leftface, rightface;
void values(){
xpos=width/2;
ypos=height/2;
upface =false;
downface = true;
leftface=false;
rightface =false;
sword=false;
xmove=7;//player movement in the x axis
ymove=7;//player movement in the y axis
xwmove=0;//world movement
ywmove=0;//world movement
xscale=50;//player scale
yscale=70;//playerscale
}

void move(){

winner=275;
hinner=290;
rectMode(CENTER);
xrestrict =xpos+25;
yrestrict =ypos+35;
xwpos=xwpos+xwmove;
ywpos=ywpos+ywmove;
fill(255);

noFill();
rect(width/2,height/2,1000,500);//this rectangle is for when the player reches the end of the rect the player will stop moving and the objects in the world will move
fill(fillVal);

rect(xpos,ypos,xscale,yscale);
xpos = constrain(xpos, winner, width - winner);
ypos = constrain(ypos, hinner, height - hinner);
if(xrestrict<1255 && xrestrict>295){
xwmove=0;
}
if(yrestrict<750 && yrestrict>=325){
ywmove=0;
}
if(xrestrict<=295){
xwmove=7;
}
if(xrestrict>=1255){
xwmove=-7;
}
if(yrestrict<=320){
ywmove=7;
}
if(yrestrict>=750){
ywmove=-7;
}

if (keyPressed) {
if(key == ‘w’ || key == ‘W’){
ypos=ypos-ymove;
upface=true;
leftface=false;
rightface=false;
downface=false;
fillVal=255;

}

if(key == 's' || key == 'S'){
  ypos=ypos+ymove;
  upface=false;
  leftface=false;
  rightface=false;
  downface=true;
  fillVal=0;
}
    if(key == 'a' || key == 'A'){
  xpos=xpos-xmove;
  upface=false;
  leftface=true;
  rightface=false;
  downface=false;
  fillVal=150;

}
if(key == ‘d’ || key == ‘D’){

  xpos=xpos+xmove;
  upface=false;
  leftface=false;
  rightface=true;
  downface=false;
  fillVal=200;

}
if(key == ’ '){
sword=true;
if(upface==true){
swordx=xpos;
swordy=ypos-50;
swordsx=20;
swordsy=50;
rect(swordx,swordy,swordsx,swordsy);
}
if(downface==true){
swordsx=20;
swordsy=50;
swordx=xpos;
swordy=ypos+50;
rect(swordx,swordy,swordsx,swordsy);
}

if(leftface==true){
    swordsx=50;
    swordsy=20;
    swordx=xpos-50;
    swordy=ypos+5;
    rect(xpos-50,ypos+5,swordsx,swordsy);
}
      if(rightface==true){
      swordsx=50;
      swordsy=20;
      swordx=xpos+50;
      swordy=ypos+5;
    rect(xpos+50,ypos+5,swordsx,swordsy);
}


  else{
  sword=false;
}
}

}

}//end of move
}//end to class

class desertbackground {
float xrect,yrect,dx,dy,dsx,dsy;
desertbackground(float basedx, float basedy, float basedsx, float basedsy){
dx=basedx;
dy=basedy;
dsx=basedsx;
dsy=basedsy;
}

void varable(){
xrect=dx;
yrect=dy;
}
void display(){
//noStroke();
xrect=xrect+c1.xwmove;
yrect=yrect+c1.ywmove;
fill(170,109,50);
rect(xrect,yrect,dsx,dsy);
/for(int dex;dex<10;dex++ ){
for(int dey;dey<10;dey++){
fill(170,129,50);
rect(dx+dex
100-dx/2,dy+dey100,20,20);
}
}
/
}//end of display
}//end of class

class wbackground{
float wx,wy,wsx,wsy,wwxmove,wwymove,wchigh,wclow,wavesx,wavesy;
float woff = 0.0;
wbackground(float waterx, float watery, float watersx, float watersy){
wx=waterx;
wy=watery ;
wsx=watersx;
wsy=watersy;
wavesx=watersx/2;
wavesy =watersy/2;

}

void display(){

noStroke();
rectMode(CENTER);
	wyhigh=wy-(wsy/2);
wxhigh=wx-(wsx/2);
wxlow = wx+(wsx/2);
	wylow=wy+(wsy/2);

wwxmove=wwxmove+c1.xwmove;
wwymove=wwymove+c1.ywmove;
fill(173,200,250,150);
	rect(wx+wwxmove,wy+wwymove,wsx+10,wsy+10);
	fill(0,100,250);
rect(wx+wwxmove,wy+wwymove,wsx,wsy);
for(int wavex; wavex<wsx/100;wavex++){
  for(int wavey; wavey<wsy/100;wavey++){
			woff = woff + .005;
		float n = noise(woff)*10;
    fill(173,200,230,100);
  	rect(wx-50+wwxmove+wavesx+wavex*-100,wy-50+wwymove+wavesy+wavey*-100+n,50,10);//wave pixles
    rect(wx-50+wwxmove+wavesx+wavex*-100,wy-50+wwymove+wavesy+wavey*-100-10+n,20,10);//wave pixles
			fill(0,100,250);
			rect(wx-50+wwxmove+wavesx+wavex*-100,wy-50+wwymove+wavesy+wavey*-100+n,10,10);//wave pixles
  }//wavey end
}//wavex end

if( c1.xpos < wx+wwxmove + (wsx+10)/2 && c1.xpos > wx+wwxmove - (wsx+10)/2 && c1.ypos < wy+wwymove + (wsy+10)/2 && c1.ypos > wy+wwymove - (wsy+10)/2){
	/*print("bb");
	print(c1.xpos);			
	print(c1.ypos);*/
	//this is where i can figure out how to get the player to not move over the water
		
	}//end of if

}//end of display
}// end of water