Grid based lighting/field of view

0 favourites
From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • Hi,

    Here's an example of my lighting/field of view test I've been working on. It uses a custom plugin I wrote which uses Bresenham's line algorithm. This was all done using events and is still not very optimised (at the moment) and needs a semi decent system to get a decent frame rate. Eventually I will turn this into a grid based lighting/fov plugin AND optimise the hell out of it! <img src="smileys/smiley5.gif" border="0" align="middle">

    Original grid based lighting example (not optimised)

    (Move the mouse to move the light)

    • Rez

    PS I'm a fan of roguelikes, can you tell? <img src="smileys/smiley2.gif" border="0" align="middle">

    Edit 5 (24/09/11): Here is the latest pretty example. This is a bit more decorated example, it has skeletons which don't do anything! It crashes at the edges so I wouldn't go there! (Forgot to put a barrier.) Seems the rendering can slow alot of computers down so try the speed test below.

    Edit 6: Here is a speed test. You can change the radius with +/-. The grid is 60x60. Please if you can, post your fps at each radi and your computer spec e.g. high, medium, low! Thanks.

    Edit 7: Here is an alternate way to render the shadow and light which is a bit faster.

  • Hey, this is pretty cool and the performance is quite good (steady 60 fps or so). I was just making a raytracer of sorts in CC, this looks super-similar, although I slightly cheated with the shadow part, just doing some distance-based point checks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks! The radius is pretty small so not much of a performance hit at the moment. Trying to think of ways to optimise it using maybe a pre fov test for every coord in the grid done when the game starts then using that as a look up. Do this for all the static objects then use a dynamic version for moving objects!

  • Not sure what you do for the values here - whether it's distance based or such, but for me doing a pre-calculated array of the light circle gave some pretty crazy performance gains.

  • It uses rays which stop as they hit blocks. Think I will definitely try the pre-calculated way.

  • Using FireFox 6.0.2 the FPS goes as low as 3 and as high as 24 :( Unusual as most other HTML 5 demos I've tried have been more than OK.

  • Yeah it is a bit low in Firefox, I get between 18-30 in Firefox and 40 or more in Chrome which isn't that bad. It's quite performance hit until I get it optimised further.

  • Cool example. So you plan to release this plugin after its complete?

  • Thanks Danny! If I can optimise it enough then yeah! Got a few other plugin/behaviour ideas in the pipeline as well basically geared towards grid based role playing games. Already tested a container behaviour for an object so you can add/remove other objects. Basically I want to simplify the common needs of an rpg so anyone can make and focus on the creative side of the design process.

  • Hey 00Rez. Awesome stuff! I tried to do something similar with events but I couldn't get an FPS above 5 <img src="smileys/smiley17.gif" border="0" align="middle" /> A plugin would rock!

  • Thanks cowtrix! <img src="smileys/smiley20.gif" border="0" align="middle" /> To optimise further I was thinking of working through every grid position and calculating the fov then keeping this information to refer to. Will test this idea eventually unless something better comes along! Considering the above example uses events it works quite fast!

  • sounds awesome good luck!

  • If you were to have a plugin, you could always have a "calculate FOV" event. Also, when a tilemap plugin gets released, this could tie into that quite nicely.

  • Yeah I already have an idea how to implement. Can't wait for tile maps and especially families!! Thinking maybe having a FOV plugin then a light source behavior attached to any object then you can have multiple light sources! Will have to see how it goes...

  • great work so far sir,

    i love roguelikes myself.

    please carry on.

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