Camera in 2D platformer game

Hi, I'm currently developing a 2D side-scrolling platformer game using SFML. How do I stop the camera from moving when it reaches the edges of the level ?
Something like this
1
2
3
if right edge of camera > right edge of level
	move camera so that right edge of camera = right edge of level
	if you have some kind of variable determining the horizontal camera speed you could set that speed to zero here.

Do the same with the other directions.
Thank you Peter87, the first one worked really well.
Topic archived. No new replies allowed.