You could use a timeout to check if water is ahead of the player by using vecx and vecy:
PHP Code:
if( onWater( (player.x+1) + (vecx(player.dir)*3) ) ||
onWater( (player.y+1.5) + (vecy(player.dir)*3) ) ){
And then maybe cancelling out the movement with a backwards movement generated by the timeout:
PHP Code:
player.x -= vecx(player.dir);
player.y -= vecy(player.dir);
I don't know what the player's walking speed will be, so you might have to find out how much backward movement you'll need to bring the player to a stop.
This is how I would have done it if I didn't have my own custom movement system.