Flashlight effect

Started by ddavey1983, Sun 25/09/2022 13:26:48

Previous topic - Next topic

ddavey1983

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?

Khris

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.

Nahuel

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: ?
Life isn't a game. Let's develop a life-like-game.

Slasher

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

Crimson Wizard

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.

Nahuel

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
[close]
Life isn't a game. Let's develop a life-like-game.

Khris

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.

Nahuel

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
Life isn't a game. Let's develop a life-like-game.

ddavey1983

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!

Khris

This should do it:

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

SMF spam blocked by CleanTalk