aspose file tools*
The moose likes Game Development and the fly likes Raycasting troubles Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "Raycasting troubles" Watch "Raycasting troubles" New topic
Author

Raycasting troubles

oajfh johnson
Greenhorn

Joined: Aug 11, 2013
Posts: 1
Hello all, first post here (I hope this all displays correctly).
I program a little in Java here and there (made a few very basic games), and recently thought I should start writing my own raycasting engine.

My code is based off the Permadi tutorial (my code may not be very well-written, I hope no one cringes too much). Wall size is 128 pixels.
http://www.permadi.com/tutorial/raycast/

Anyhow, I seem to have a problem rendering my walls properly. My level is square-shaped, with blocks along the edges.

Currently, the size of the walls seems to be a little strange : it is the same ratio no matter what direction one looks in, no matter where one happens to be (walls at the other end of the map seem to be the same size as ones a dozen pixels away).
What's more, some walls are jagged whereas some others are smooth. Lastly, the size of the wall doesn't quite change smoothly with distance.

Source code enclosed is simplified and therefore mostly unoptimised (little bit shifting, nor any precaslculated values) in order to help understanding.

Angles are in degrees (360 >angles >=0).

554 is the distance to the proj plane, for a FOV of 60 degrees. Screen size is 640*400.


In my Render class, I have these methods :



The render method has this piece of code :





Here's the raycasting (which I put in a separate class) :



Finally, here's the level data :
This method returns the block corresponding to the coordinates (usually intersection coordinates)



Here's the level :


That 's the layout. -1 for walls. Width and depth are set to 8.


I hope that wasn't too much of a mouthful, but I've been stuck at this point for the last couple of days, even after rewriting part of the above.
If the full source code needs to be posted, just tell me.
Any help on this would be greatly appreciated.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Raycasting troubles