• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

Legacy GM Any way to detect the corners of a room dynamically?

FlamingYeti

Member
Me again :p I'm hoping by slowly learning techniques from you guys, I'll become a better programmer, than just sitting trying to work out a half-arsed slightly ****ty way of doing something.

The Concept
I'm making a top-down game. The idea is there will be a fog-of-war style roof, allowing you only to see the room you're in, and into rooms with windows, outisde etc. Currently I have a test-room with the inside of the walls covered with a tiling oRoof object, and the idea is that when you walk through the door, the alpha of the roof tiles fades to 0, and you can see everything in the room.

The reason I'd like it to be dynamic, instead of hard-coding the zones of each room is because if there's an explosion, or a change in the environment, or a wall-collapses, it'd be nice to have the player's vision almost spill out, so the game re-calculates the area you can see.

The Idea
Is there a way where every frame, or in a script or something, the game would detect 2 points, the two opposite corners of the room, then fade away the alpha of every roof tile between those points? Some kind of function, a calculation etc...

The Pseudocode
Code:
if x > CornerPoint1.x and x < CornerPoint2.x and y > CornerPoint1.y and x < CornerPoint2.y{
      FadeAlpha
}
Thank you in advance for the help, you're all so lovely <3
 

Surgeon_

Symbian Curator
Usually you can achieve this kind of effects with a dynamic lighting engines, here are a few examples:
Glare (the best there is)
Aura (most lightweight)
Mercury (my own, bundled with other stuff)

If that doesn't help you, if your game is grid based, you can try flood filling from the player's position or raycasting - these techniques can be very CPU intensive, but I guess same can be said for dynamic lighting to some degree.
 

FlamingYeti

Member
Usually you can achieve this kind of effects with a dynamic lighting engines, here are a few examples:
Glare (the best there is)
Aura (most lightweight)
Mercury (my own, bundled with other stuff)

If that doesn't help you, if your game is grid based, you can try flood filling from the player's position or raycasting - these techniques can be very CPU intensive, but I guess same can be said for dynamic lighting to some degree.
Wow, that's cool and all, I just don't think it will achieve the effect I'm going for. But I'll certainly keep these in mind, they look very impressive.
 
Top