//Unmove previous move x=xprevious; y=yprevious; //Move until you hit the wall move_contact_solid(direction,speed); //If you hit the ground if(!place_free(x,y+1)){ //Don't move up or down vspeed=0; //Set our "ground" variable onGround=true; //Turn off gravity so we can move gravity=0; } //If you hit the ceiling if(!place_free(x,y-1)) vspeed=0; //If you hit a wall going right if(!place_free(x+1,y)) hspeed=0; //If you hit a wall going left if(!place_free(x-1,y)) hspeed=0;