• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Piet Souris

Raycasting troubles

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

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.
Whatever. Here's a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!