Monday, April 5, 2010

Alchemy Ray Casting Engine source code released

This is my first project using alchemy, porting a simple ray casting engine from this tutorial (http://www.student.kuleuven.be/~m0216922/CG/raycasting.html) to flash, and finished about half a year ago. Source code is just released because Im too lazy to clean up the dirty code behind the first demo.
This engine is better than may other flash based ray caster because it can render ceil/floor and sprites. Its not hard to make a Wolfenstein-like game using this engine but Im not motivated to do that now.
We already have more powerful alchemy doom and alchemy quake engine now. There are many good game editors for these two engines; we can create a quake-like FPS even without programming now. But its strange that I havent seen any new game made.
(If you want to do this, here are tutorials:
One reason is no LAN game play, hope someone can solve this problem. I think another reason is those engines are too complicated to deal with. This little engine is much simpler and can be used personally, hope you will like it.
I wont develop it further because recently Im focus on a totally new ray casting engine BENGINE (http://flaswf.googlecode.com/files/Bengine_v01.swf ), a voxel based 2.5D/3D ray casting engine.
As to the source code of this alchemy ray caster, special thanks to Lode, the original author of the C++ code, and Ralph Hauwert (unitzeroone.com), I learned how to use alchemy from his source.
It is not well written, and maybe you wont like my way of writing C code, I dont use .h file, I prefer C to C++ (so the original C++ source is C now) and like to use include a lot.
Besides, there may be lots of bugs and many things can be optimized.
If you want to make it better, some ToDos (for you):
1.      Use 1D screen buffer ([]) instead of 2D screen buffer ([][]) to speed up rendering.
2.      Improve the sprite sorting function.
3.      Use a lookup table to calculate rays instead of vectors (#1).
4.      More controls: Strafe left/right, jump/crouch, run, look up/down (#1).
5.      Some lighting effect (#1).
6.      A better way to handle textures/sprites, doom wad like data/resources.
7.      A better way to define a map, a map editor, import Wolfenstein map format.
8.      Animated sprites.
9.      Write a simple game.

#1 Another nice ray casting tutorial you may need:

Sponsors