Sprites rendering in 2.5D raycasting engine

Hi all! I’ve been reading this BB for a while and this is my first post :slight_smile:

I’m a CS student and I’m quite new at game development, though I have good Java skills.

After working on some 2D games I decided to try to implement a Wolfenstein 3D-like game engine from scratch (I know it’s not a novel idea :P).

My current engine is capable of correctly displaying walls and textures, but I’m stuck at sprites rendering.

My engine does not use matrices, just some geometry and trigonometry; but I’m missing the technique needed to get sprites on screen.

It’s quite easy to determine if a sprite is currently visible on the screen, but I definitely don’t know how to determine the portion of the sprite image that has to be drawn.

In the following picture, if the red dot is the viewer (with its field of view) and the blue dot is a sprite, how can I render it on screen? How can I determine the on-screen x coord of the sprite?

https://dl.dropbox.com/u/43271824/rc.png

Thanks a lot (I hope my english is not that bad ;))

Are you using Java2D? Or something else?

I’m using just AWT. Anyway after an afternoon of work I figured out how to make it, maybe I’ll post some screens of my engine ^^

So your using ray-casting to determine line-of-sight?

Yes. The engine draws the walls and stores their distance, then it calculates the distance to the visible sprites (the sprites contained in the current field of view) and draws their vertical stripes which are not covered by a wall.

If I remember correctly, wolfenstein use bsp map format.
Correct me if I m wrong but there is directly visibility data inside the bsp tree, so you just have to render all sprites inside the visible zone computed by vis.