Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: ddavey1983 on Sun 25/09/2022 13:26:48

Title: Flashlight effect
Post by: ddavey1983 on Sun 25/09/2022 13:26:48
Hello

I have an effect in my game where I've used a gui that follows the player to give a flashlight effect. In the 340x200 room it works very well. I've used a black screen (399,699) with a transparent elipse in the middle. I've set the gui position to:

gtorch.SetPosition (player.x-317, player.y-240);

That works great, the torchlight follows the player around.

Now I have a room that is 523 x 200. It scrolls as you walk side to side. The original g.torch gui doesn't work obviously because the room is a different length. I've tried making a gui that's twice the length of the new room with the elipse at the centre then adjusting the setposition to various different values but it always seems to follow thr player for a bit then speed away.

Any ideas anyone?
Title: Re: Flashlight effect
Post by: Khris on Sun 25/09/2022 16:44:42
You need to convert the player's coordinates (which are room coordinates) to screen coordinates first.
In a non-scrolling room they're the same, but as soon as the rooms get bigger, you need to convert appropriately.
Title: Re: Flashlight effect
Post by: Nahuel on Mon 26/09/2022 23:06:58
I remember the flashlight plugin but all links are gone now, does anyone has anything that works for a simple flashlight to follow the cursor please  :sad: ?
Title: Re: Flashlight effect
Post by: Slasher on Tue 27/09/2022 04:17:54
Quote from: Nahuel on Mon 26/09/2022 23:06:58I remember the flashlight plugin but all links are gone now, does anyone has anything that works for a simple flashlight to follow the cursor please  :sad: ?
I'm not sure this still works but you could try it...  https://www.mediafire.com/file/hek22m3xevs5w4t/ags_flashlight_1_2.7z/file
Title: Re: Flashlight effect
Post by: Crimson Wizard on Tue 27/09/2022 06:17:04
Quote from: Nahuel on Mon 26/09/2022 23:06:58I remember the flashlight plugin but all links are gone now, does anyone has anything that works for a simple flashlight to follow the cursor please  :sad: ?

You don't need a plugin for that, that's as easy as making a big black GUI with a transparent circle in the middle, making it translucent (Transparency property) and scripting it to follow the cursor.
Title: Re: Flashlight effect
Post by: Nahuel on Tue 27/09/2022 08:42:41
Quote from: Slasher on Tue 27/09/2022 04:17:54I'm not sure this still works but you could try it...  https://www.mediafire.com/file/hek22m3xevs5w4t/ags_flashlight_1_2.7z/file

Thanks a lot @Slasher!

Quote from: Crimson Wizard on Tue 27/09/2022 06:17:04You don't need a plugin for that, that's as easy as making a big black GUI with a transparent circle in the middle, making it translucent (Transparency property) and scripting it to follow the cursor.

Thanks @Crimson Wizard it works very well and it was simple to create, the only thnk that I'm missing that I'm trying is to get some glow around but it's getting pink-ish tint
 
Spoiler
(https://i.ibb.co/LZH1kXw/Screenshot-2022-09-27-at-09-32-37.png)
[close]
Title: Re: Flashlight effect
Post by: Khris on Tue 27/09/2022 12:49:54
You need to create a PNG where the hole has a semi transparent edge. While importing it into AGS make sure the alpha channel is kept. You also need to "leave transparency as-is" afaik.
Title: Re: Flashlight effect
Post by: Nahuel on Tue 27/09/2022 16:11:15
Quote from: Khris on Tue 27/09/2022 12:49:54You need to create a PNG where the hole has a semi transparent edge. While importing it into AGS make sure the alpha channel is kept. You also need to "leave transparency as-is" afaik.

Thanks @Khris Will check that then, will get back with updates
Title: Re: Flashlight effect
Post by: ddavey1983 on Fri 14/10/2022 21:53:11
Thanks so much for all the replies. In the end I (somewhat furiously) just changed my scrolling room to a normal-sized one and ploughed on with the game, hence the delay in my thanks!
Title: Re: Flashlight effect
Post by: Khris on Sat 15/10/2022 02:00:10
This should do it:

  gtorch.SetPosition(player.x - (317 + Game.Camera.X), player.y - (240 + Game.Camera.Y));