jfroco wrote:Hi Jasoco,
Did you implemented doors? I'm not fan of doors as I said before, but I've been reading a couple of articles about and it doesn't seem to be trivial. Please let us know!!!!
I'm kind of upset of not being able to do floor casting without using dynamic quads... don't get me wrong, I think your implementation is fantastic and I too should use whatever technology is available , the problem for me is that it is not "portable"... but anyway.. I was playing with floor casting until I realized that I coded a simple 3d to 2d projection code, and then I remembered an old game that is fantastic "The Colony" (1987-Macintosh). So instead of trying to make the floorcasting work, I dropped all my raycasting code and made this:
[youtube]kyeZ4nMkNtU[youtube]
I can't use textures (without using canvas+dynamic quads
), but it was fun to implement
Best regards
Daaaaaaaamn. I loved watching videos of
The Colony on YouTune a while ago. It was actually what I was going to try and make at first if I was unable to do textures. You gotta share that code.
I'm still working on doors. I have a wireframe right now showing where the door would be, but I have to figure out how to draw it with images. I'm thinking it should be as easy as:
1) Take the side of the door you are looking at. i.e. Right or Left/Up or Down
2) Calculate the left and right most pixels on the screen where the door lies
3) Cast rays from the left to right pixels using the inset of the door as an offset, add each slice to the drawing pool as long as the slice is not covered up by the slice already existing at that point. (i.e. don't draw it if it's inside the wall. If the door is closed and not transparent, replace the slice that's already there, otherwise add a new one to draw in front.)
I just need to figure out the math to do the casting. I'll try taking the existing raycaster and make a secondary doorcaster function.
Experimenting will be fun. Right now I have a wireframe and working open/close functionality.
I would love to not have to rely on canvases and wish they weren't so unportable, but there's really no other way to do this with speed without Löve having the ability to Distort images and quads like you can in PhotoShop. It's really the only thing keeping us from being able to make realistic 3D. As I have shown before, I can totally calculate 3D, but if I could also distort images to any shape by moving the four corners independently you wouldn't have to use solid polygons and I wouldn't need to use raycasting to draw the 3D view as an array of 1 pixel strips. It would probably be faster because, say I have a view and you can see 10 wall tiles from your perspective, it would only require 10 draw calls and transform calls instead of 320 or 640 of them across the screen. For the floor I would simply need to add visible floor tiles to a table as my rays are passing through them and then draw only the ones you can see using the same distort feature.
- Distort.png (5.62 KiB) Viewed 7343 times
Basically we need access to some more modern image manipulation features. Yeah, I know, I know, "Löve2D", but really, it doesn't have to be 100% 2D if we are provided the right tools. (Although, then I wouldn't be able to do depth shading on the floor or walls at a per pixel basis. Nor could I do proper z-ordering of objects and wall slices unless we had actual texture clipping like normal 3D engines.)
But I'm getting off-topic. A game like DOOM could be totally possible with a little work. The main difference between how Wolfenstein worked and DOOM worked is Wolfenstein's walls are all on a grid. Whereas DOOM's could be anywhere. So in order to do it, DOOM had to create a lookup table of every sector that could be seen from every other sector so the engine wouldn't have to do as many calculations on sectors that aren't even visible. The fun part would be creating the
BSP generator.
I do have plans on adding some other features like maybe simple sloped walls and higher floors and lower ceilings if I can figure out the best way to do it. (Which would probably consist of making separate Floor/Ceiling inner and outer canvases for each height level. I'd be afraid I'll reach the limit of most graphic cards this way though.)
This is a WIP and will probably be for a while, but hopefully it's a fun ride. The use of LuaJIT made it much more fun though since it's now faster. I just fear I will be building something too powerful for many computers, even ones with high-end components. So I can't wait to open it up to the public here officially to get peoples testing and help and input.