lighting system for platform game

0 favourites
  • 11 posts
From the Asset Store
A pack of 76 platform designs for a platformer game with a mushroom/jungle theme
  • hey everyone!

    need some opinions on how to better achieve a lighting system for a 2d platform game.

    my references are these:

    Subscribe to Construct videos now
    Subscribe to Construct videos now

    this is what i have right now:

    im using around 1000 black square sprites, that follow the camera, and change their color from black to white, depending on "light" conditions.

    im using the lineofsight plugin to reproduce the shadowLight plugin. and using a simple distance thing to draw some light around the player.

    main problems:

    1 - well, its super mega uber not optimized, and runs really slow.

    2a - since the tile map blocks the line of sight (just like with the shadowLight) the actual platform terrain is 100% black (unless when close to the player, when i force some light there) this is really bad obviously because how are you going to play a platform game when you dont actually see the actual platforms!?

    2b - you could say, well, make the platform visual on top of the shadow. but then... its just going to look horrible! and defeats the purpose of even wanting to have this shadow going on.

    *why not use the shadowLight? well, first of all, it renders perfect aliased shadows and i dont feel like that works visually with my game. and, it has the same problem from "2a/2b".

    ideas??

  • bump

  • Another idea would be replacing your 1000 black square by a single tilemap. Each tick you check for LOS of each tile position and set (or erase) its tileID accordingly. You could even have multiple tile ID for multiple "lighting value".

  • my first idea was actually to use a tilemap. but i have no idea how to access the individual tiles like you said!

  • Then in that case, the manual is your friend! Check out the part on TileToPositionX/Y, this is certainly what you want. Ask away if there's still something you don't comprehend.

  • i managed to have 1 tile work!

    basically im looking at the position of tile (3,3) and then setting it to a white or black tile depending if LOS can see it or not.

    BUT i have no idea how I would make the event looks at all tiles.

    also, my layout is pretty big, at 600 tiles wide by 340 tiles tall. so i guess i would need an expression that only looks at tiles that are close enough to the player, or inside the camera/screen area?

    also right now i have it be on/off as in sees/doesnt see. how could i measure the distance of each tile to the player? so i could actualy make the light be stronger/weaker with a gradient instead of just on/off

  • Heh, one tile is better than nothing !

    But what's even better is getting all tiles to behave correctly !

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ah magistross!! this is just beautifull!

    I managed to get a loop running to check all tiles, but it was just sooo slow!

    your result is amazing! ill study it here to understand what you did!

  • Magistross - I am getting a 404 error on the capx

    can you post another link please ?

  • Sorry RamPackWobble, I had moved the file from my dropbox folder. Give it another go, it should work now.

  • Magistross - got it thanks.

    (edit 6/8/15 )

    That example is very good - it has certainly given me some new ideas, thanks again

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