recursive shadowcasting FOV in ascii rogue

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
meoiswa
Prole
Posts: 48
Joined: Wed Mar 14, 2012 8:13 pm
Location: Venezuela

Re: recursive shadowcasting FOV in ascii rogue

Post 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
Write the ö of Löve with Alt+numPad(148) or Alt+numPad(153)
User avatar
pch
Prole
Posts: 32
Joined: Sun Mar 04, 2012 5:17 pm
Location: poland

Re: recursive shadowcasting FOV in ascii rogue

Post 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
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: recursive shadowcasting FOV in ascii rogue

Post 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?
User avatar
pch
Prole
Posts: 32
Joined: Sun Mar 04, 2012 5:17 pm
Location: poland

Re: recursive shadowcasting FOV in ascii rogue

Post 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.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: recursive shadowcasting FOV in ascii rogue

Post 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
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: recursive shadowcasting FOV in ascii rogue

Post by Robin »

Don't forget to call love.graphics.present after calling love.draw(), otherwise nothing will be shown.
Help us help you: attach a .love.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: recursive shadowcasting FOV in ascii rogue

Post 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?
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
pch
Prole
Posts: 32
Joined: Sun Mar 04, 2012 5:17 pm
Location: poland

Re: recursive shadowcasting FOV in ascii rogue

Post 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
meoiswa
Prole
Posts: 48
Joined: Wed Mar 14, 2012 8:13 pm
Location: Venezuela

Re: recursive shadowcasting FOV in ascii rogue

Post by meoiswa »

You did exactly what I suggested :) Have shadows work with any angle and not just 45. It's looking very nice already!
Write the ö of Löve with Alt+numPad(148) or Alt+numPad(153)
User avatar
tsturzl
Party member
Posts: 161
Joined: Fri Apr 08, 2011 3:24 am

Re: recursive shadowcasting FOV in ascii rogue

Post 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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests