Collisions

how would i make an object stop once it hits another? such as a game sprite not being able to go through a wall or fall through a platform