I just don't know how to implement a good gradient drawing function to draw the darkening floor and ceiling effect based on how dark the level ambience is supposed to be.
Seems like it would have been easy. Take a start color and an end color, figure out how many steps it takes to get there, then walk along the steps getting gradually darker.
This is what I used currently:
Code: Select all
grad.stages = screenHeight / 2
grad.step = (grad.stop - grad.start) / grad.stages
grad.cur = grad.start
for i = 0, grad.stages do
grad.cur = grad.cur + grad.step
love.graphics.setColor(100,100,100,255 * grad.cur)
love.graphics.rectangle("fill", 0, screenHeight / 2 - i, screenWidth, 1)
end
grad.stages = screenHeight / 2
grad.step = (grad.stop - grad.start) / grad.stages
grad.cur = grad.start
for i = 0, grad.stages do
grad.cur = grad.cur + grad.step
love.graphics.setColor(66,53,41,255 * grad.cur)
love.graphics.rectangle("fill", 0, screenHeight / 2 + i, screenWidth, 1)
end
To draw the grey ceiling and brown floor. But that's hard coded and based on opacity over black. I'd rather draw in the color.
Edit: Okay, in the meantime, here's a current version of what I have done so far:
- WolfenLove3D.love
- 0.8.0 required or at least recommended.
- (146.33 KiB) Downloaded 372 times
Notes:
Move with the arrow keys. No Strafing yet. And collision is really basic. I will fix collision and add strafing.
Press / to change the resolution. The way it works is screen width / scale factor = number of lines drawn across the screen. It currently lets you go up to 4 and down to 1 with 8 being the most pixelated and 1 being 1:1 pixel. 1:1 is slower and 8:1 is fast. But 1:1 looks really nice if your computer can run it smooth enough.
The current screen size is 800x500. Use the MENU to change the resolution! Adjust both options to fit your speed.
There is a current sprite bug where it gets indexed a bit wrong. I will fix as soon as possible.
Like the original, opposite walls are reversed. I tried disabling this as I'd rather control the reverse texturing myself, but need to figure it out more.
Press M to toggle the map.
Press L to toggle the lighting.
Don't criticize my code. It's still a bit messy since it was someone elses code that was ported from a JavaScript project. I'm working on optimizing and cleaning it up. But jfroco did a pretty damn good job porting it I must say.
Next Objectives:
> Sky - Can't believe I forgot that. This will be the easiest part. Simply place an image behind the walls and sprites and move it based on which direction you are facing. Easy peasy lemon squeezy.
> Transparent walls - This will be interesting. Will have to modify the ray cast function to record when it hits a transparent wall, save it for later and keep going, then modify the display portion to allow for an optional second layer over the first layer when there's a see-through wall in front. That will be fun.
> New mapping format - Will have to figure out an easy to modify and understand format for my maps.
> Enemies - Have to do them some time. I also have to fix the sprite clipping bug. Can't wait to start trying to create an AI for them. I want them to pursue the player when they see them and run and find shelter when running low on health. Maybe give some the ability to heal themselves. But I'm getting ahead of myself. Let's get static enemies in place first.
> Separate floor colors - If I can't do images for the floors, I can at least figure out how to draw each floor/ceiling tile individually so I can create lighting effects.
> Better player movement/collision detection - Self explanatory
> Editor - If time I will whip up an easy to use editor for creating maps.
> Animation - Sprites, walls, maybe eventually floors and ceilings.
> Doors - Still not sure how to handle this yet. Need to figure out how to have walls that aren't on the exact grid to do this. A door in Wolf3D was a flat wall that was inset half a block and slid to the side when opened. Hmm... I wonder if I could look at the original Wolfenstein code.