Need Help Implementing @RamPackWobble 's Lighting System

0 favourites
  • 11 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hello Construct community. I'm new to construct and game dev in general, so please pardon if I violate some construct forum norms. I recently came across RamPackWobble 's Land of Light and Shadows tutorial: .The first 2 parts aren't necessary to my game, but the 3rd is. If you haven't read the tutorial please do, it's amazing. So here's my problem; I tired incoperating the lighting system into my platformer stealth type of game. The idea is the layout (think of it as a building) is divided into various segments (rooms) which have to sneak though. All the segments (rooms) in the layout are dark, unless, a light is on, in which case the room is lit. The light stays in that segment (room) only, obstructed by doors, walls, and solid ground. Some light may sip into the next room if the door between those two rooms is open (ie solid disabled). A well placed obstacle can also create shadow. I tried 3 methods listed in the his tutorials, (1) the line of sight full grid method, (2) line of sight full cone method, and (3) the cast light arc method. The line of sight cone method was my least favourite since its possible for light from one room to move into another room, therefore you'd have cones overlapping each other, and remember the whole layout is dark meaning a cone would have to be created for each light. In the end (in my case) im better of using the less complex method and using the line of sight full grid system, covering the whole layout in a grid of lights which are activated when an on light has a line of sight to them (which I also tired. I'll get back to that in a moment). I tired the cast light method, which seemed promising, except for a couple of things; (1) the walls and ground which the rays of light collide into, are long, and there origin is in the center. This affects the distance() functions which is used to calculates the distance between the light from which the ray sprite is drawn, and the obstacle (wall, ground) inorder to adjust the width of the ray of light to not go beyond the obstacle. Because the distance() function uses the centre of the obstacle to calculate distance between my light and my obstacle (a long wall). So while one ray will have an accurate width setting, the light rays won't, which creates a very ugly mess. this could be solved if I construct had a collision-point parameter which I would use in the distance() function. It would seem that the best method of me to use is the line of site full grid method you devised earlier, it's actually quite good, my only gripe with it is that, having that full grid in my game with everything else that I have in my layout seriously degrades the performance, especially on slower machines (which is odd for a 2D game, with barely anything really taxing in it). If this method was less memory intensive (or processor, or whatever it is, I'm not an expert) I'd use it (if the more skilled programmers in this community could find a way to optimize this method). Is there anyone reading this, following my chain of thought, and capable of helping? Mr RamPackWobble, can you help? I'm so close to success... Sorry but due to the device I'm using, I can't upload screenshots or a capx file, I would really have loved to see if you could help. I just hope there's some amongst you capable of helping, even without. I know I've broken some forums posting norms/rules, again, sorry.

  • First of all, thanks for the nice comments about the tutorials. (and now with 75% off* - please look in the tutorial section. )

    Easiest answer is, "Could you break your walls up into smaller sections - this would allow the distance (of the light beams) to be calculated with more precision ?"

    Fixed lights (ie room lights) could be faked with a pre-made light overlay ...

    This might have been better in the "How do I" forum ?

    Paragraphs are fun

    * The 75% off is for a limited time only

  • 1) Okay I must be getting old, I don't get the 75% off joke. (2) I can't break up the walls, considering the number of "rays", I'd have to have very tiny walls to have a accurate distance() calculation. (3) I considered the pre-made overlay, like you did, but the rooms are next to each over so the pre made over lays would just be next to each other, which is pretty much the same as just having a full grid, but with more work. (4) I considered sticking it in the how do I forum, but it didn't seem 100% percent accurate. Like I said, sorry for breaking forum posting rules. If any moderator is reading this, please move it to the appropriate forum. (5) with reference to the paragraphs bit, please don't mock my dumb phone, I can't work with the scirra forums' fancy text editor ... I still don't get the 75% off bit.

  • I realise that maybe my original lengthy text post wasn't cleat enough. So I've uploaded a capx project file (r139) of my project. Maybe that'll be more clear and someone (looking at you RamPackWobble) can have a look at it and have luck figuring out how to incoperate one of RamPackWobble 's lighting methods with fare accuracy and without a heavy strain on memory, cause I'm clearly stuck. it would b very much appreciated.

  • I will have a look but it will probably be Monday as "She who must be Obeyed" has plans for this weekend ....

    You are typing on a phone - that would take me hours and be 50% spelling errors (I'm not that good on a full sized keyboard) , so your lack of paragraphs will be overlooked for now. (Me mock ? Never ! )

    You "don't get the 75% off bit" - perhaps you viewed them before the sale ?

    Which reminds me - the 75% off sale ends soon, get the tutorials while they are cheap ...

  • [quote:1fdun8vf]

    You "don't get the 75% off bit" - perhaps you viewed them before the sale ?

    LOL i dont think that will help

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • spongehammer

  • spongehammer -_-

  • Here you go - needs work but it is showing promise ...

  • It's Sunday. was expecting Monday. There I was counting the minutes.

  • I had a bit of an epiphany and I didn't spend Sunday afternoon at the in laws . Quite a good day after all.

    What day you think of this method?

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