try this website for help http://permadi.com/1996/05/ray-casting-tutorial-table-of-contents/