Grid based lighting/field of view

0 favourites
From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • Excellent work !!! An "capx" with example is it possible ?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • No capx yet <img src="smileys/smiley2.gif" border="0" align="middle" />

  • great work so far sir,

    i love roguelikes myself.

    please carry on.

    Thanks harrio!

  • I've edited my first post to include a demo of the field of view plugin which uses pre-calculation. Needs more work still but getting there!

  • EDIT: Here is a quick implementation of the plugin version using pre-calculated light/sight arrays. Left click to create a "House" which blocks sight. PLEASE NOTE: The slow down is caused by the number of black blocks, not related to the plugin! This is just a simple example to show the speed difference so nothing fancy!

    And what a difference it makes!

    The event driven demo runs with 4 to 26 fps on my pc, the plugin version runs with 58 to 65 fps (slowing down to 26 as soon as the black blocks are drawn).

    But I must say the event driven demo reminds me more on some topdown minecraft thingy :D

  • Now averages around 57 FPS - much better :)

  • > EDIT: Here is a quick implementation of the plugin version using pre-calculated light/sight arrays. Left click to create a "House" which blocks sight. PLEASE NOTE: The slow down is caused by the number of black blocks, not related to the plugin! This is just a simple example to show the speed difference so nothing fancy!

    And what a difference it makes!

    The event driven demo runs with 4 to 26 fps on my pc, the plugin version runs with 58 to 65 fps (slowing down to 26 as soon as the black blocks are drawn).

    But I must say the event driven demo reminds me more on some topdown minecraft thingy :D

    Yeah it has all fancy opacity events and is based on the mouse position. None of that in the second test. I'm glad the speed is better still more to do. Need to find a way to show the field of view without the use of blocks maybe. Definitely influenced by Minecraft and roguelikes. <img src="smileys/smiley2.gif" border="0" align="middle">

  • Now averages around 57 FPS - much better :)

    That's great! Still more to do...

  • Another update! Just a few more tests. See first post.

  • love the improvements rez,

    hope you don't lose the 'retro' graphic opacity zones of the first test. that has dungeon crawl written all over it...lol.

    love the smoothness of the latest tests as well.

    my half-orc 'grogan t. blackblade' awaits your progress.

  • love the improvements rez,

    hope you don't lose the 'retro' graphic opacity zones of the first test. that has dungeon crawl written all over it...lol.

    love the smoothness of the latest tests as well.

    my half-orc 'grogan t. blackblade' awaits your progress.

    <img src="smileys/smiley1.gif" border="0" align="middle" /> If I can find a quicker way of rendering shadows then this would be easy just a play on opacity. Another way is to limit the range so when you render the light it only uses a few objects for lit squares but I still need to find a quick/good way of doing this. Then you would have a dark layer over everything then use light objects to cut out the dark layer like the way the light works in my demos, hopefully that would speed things up! Then there's making it as easy as possible for everyone... <img src="smileys/smiley5.gif" border="0" align="middle" />

  • Getting there! Went back to real time calculation which is actually really fast. Made it so you can limit the radius which speeds things up. Currently working on a method to make finding lit/seen cells faster (for rendering)... <img src="smileys/smiley23.gif" border="0" align="middle" />

  • Good work. Running 60 fps in the 40x40 cells demo, needing 1.5 seconds to re-calculate.

    I don't know your algorithm, but make it flexible enough to only calculate rows and columns, instead of the whole scene. Then, while moving the camera only calculate the next one or two (depends on the speed of the camera movement) rows/columns.

    If the camera goes to the right, you only need to calculate one or two columns to the right, if the movement hits the next column (grid-based, in this case column 41 would be needed, etc.). Same for all other directions. The heaviest impact would be a diagonal movement, where both, row and column needs to be calculated.

    EDIT: Forget about it. Was writing quicker than thinking. It doesn't solve the problem of light cells that may influence the rows/columns. Sorry.

  • Good work. Running 60 fps in the 40x40 cells demo, needing 1.5 seconds to re-calculate.

    I don't know your algorithm, but make it flexible enough to only calculate rows and columns, instead of the whole scene. Then, while moving the camera only calculate the next one or two (depends on the speed of the camera movement) rows/columns.

    If the camera goes to the right, you only need to calculate one or two columns to the right, if the movement hits the next column (grid-based, in this case column 41 would be needed, etc.). Same for all other directions. The heaviest impact would be a diagonal movement, where both, row and column needs to be calculated.

    EDIT: Forget about it. Was writing quicker than thinking. It doesn't solve the problem of light cells that may influence the rows/columns. Sorry.

    No worries. I've noticed I can use a real time method which doesn't impact performance as much as long as the "radius" of light is limited. My algorithm is just BASIC fov so it sends rays out. Limiting the rays to a certain length increases speed alot. The only problem I'm having is I've created a "list" to hold all "lit" cells instead of having to iterate through all which slows it right down on large grids! The problem I'm having at the moment is overlapping which adds the same positions to the list, I need a way to make sure only one position is added and no duplicates. <img src="smileys/smiley5.gif" border="0" align="middle" />

  • Here's my progress:

    This shows pretty much how the Events will work:

    <img src="http://dl.dropbox.com/u/19078872/gist.png" border="0">

    And this is the latest example!

    This example is 40x40 and calculates real time! Move the purple block with the arrow keys!

    Edit: The example now only renders lit cells surrounding the Purple player. The grid is 60x60 with the sight radius of 6! I get about 30 fps which is pretty good at 60x60 cells. For some reason the "light" is brighter when exported?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)