Page 2 of 2
Re: recursive shadowcasting FOV in ascii rogue
Posted: Thu Mar 15, 2012 4:00 am
by meoiswa
Suggestion: not having pre-defined fields of view (45 degrees), but rather generate them by following the imaginary line between the current position and the corner of the wall that is blocking the view
Re: recursive shadowcasting FOV in ascii rogue
Posted: Thu Mar 15, 2012 8:49 am
by pch
algoritm is fixed -:)
updated download in first post.
keep pressing Enter until the room with enough pillars will be generated
number of pillars can be changed by 9/0 - anyway this is the maximum number of columns per room.
teh8bits wrote:You should load maps from a txt file, that would be awesome ;P
i'll do that. its going to work like this: if there is a file called mapXXX.txt - load it, if not - generate random map.
meoiswa wrote:Suggestion: not having pre-defined fields of view (45 degrees), but rather generate them by following the imaginary line between the current position and the corner of the wall that is blocking the view
I don't quite understand - sorry it's new to me - but anyway I think that is already happening here.
I followed that tut:
http://roguebasin.roguelikedevelopment. ... dowcasting
the next step is to tune it a little with this:
http://roguebasin.roguelikedevelopment. ... dowcasting
Re: recursive shadowcasting FOV in ascii rogue
Posted: Thu Mar 15, 2012 10:20 am
by coffee
Nice work, and thanks. Now with pillars far away we can check angle "streching". Looks good. Are you still perfecting it or you advanced for things like light source?
Re: recursive shadowcasting FOV in ascii rogue
Posted: Thu Mar 15, 2012 10:37 am
by pch
first i will try "upgrading" it with a more acurate slop/visibility calculations.
Lights will come shortly.
Just have one question, not about fov but about love and draw/update functions:
is there a way to force love not to redraw screen so often?
I'd like it to be redraw only when I press the movement key - since all calculations are done only once and only after arrow is pressed.
I,m asking because everytime I start my program then the fan in my computer starts as well and after a short time it gets quite loud.
Re: recursive shadowcasting FOV in ascii rogue
Posted: Thu Mar 15, 2012 3:13 pm
by Nixola
You'll have to overwrite
love.run, maybe like this (not tested), and call love.graphics.clear() and love.draw() in love.keypressed:
Code: Select all
function love.run()
if love.load then love.load(arg) end
local dt = 0
-- Main loop time.
while true do
if love.timer then
love.timer.step()
dt = love.timer.getDelta()
end
if love.update then love.update(dt) end -- will pass 0 if love.timer is disabled
--[[ if love.graphics then
love.graphics.clear()
if love.draw then love.draw() end
end]] --Simply delete this line and the 3 above
--Rest of love.run, don't delete this!
end
function love.keypressed(key, unicode)
--your stuff
love.graphics.clear()
love.draw()
end
Re: recursive shadowcasting FOV in ascii rogue
Posted: Thu Mar 15, 2012 3:21 pm
by Robin
Don't forget to call
love.graphics.present after calling love.draw(), otherwise nothing will be shown.
Re: recursive shadowcasting FOV in ascii rogue
Posted: Thu Mar 15, 2012 3:27 pm
by Nixola
I didn't know that ^^'
If you call it after love.draw you don't need to call it in love.run, right?
Re: recursive shadowcasting FOV in ascii rogue
Posted: Thu Mar 15, 2012 4:23 pm
by pch
thanks.
I put that code and transfered love.graphics part into love.keypressed()
It redraws the screen continously but like 50% slower - so you can see horizontal border passing from top to bottom and it draws it in two different positions (it depends which arrow was pressed last) - for example left/right then it draws everything once and the next redraw shifts the image to the left/right and then back.
But I'll think on that since I have already a starting point.
ETA:
ok, my fault.
I forgot to remove
Code: Select all
if love.graphics then love.graphics.present() end
from the end of love.run() - so it was duplicated.
Now it works.
Thanks
Re: recursive shadowcasting FOV in ascii rogue
Posted: Thu Mar 15, 2012 7:24 pm
by meoiswa
You did exactly what I suggested
Have shadows work with any angle and not just 45. It's looking very nice already!
Re: recursive shadowcasting FOV in ascii rogue
Posted: Fri Mar 16, 2012 8:06 pm
by tsturzl
IMO, everything it the shadow should be hidden, so enemies, objects, etc. Maybe even walls? Just omit any characters in the shadow area, perhaps.