The Daily Click ::. Forums ::. Klik Coding Help ::. flash light
 

Post Reply  Post Oekaki 
 

Posted By Message

Willy C



Registered
  14/02/2004
Points
  1524

Game of the Week WinnerKlikCast StarPicture Me This -Round8- Winner!VIP MemberWii OwnerIt's-a me, Mario!Hero of TimeThe Cake is a LiePS3 OwnerI am an April Fool
Batman!Teddy Bear
25th March, 2005 at 09:42:11 -

anyone know how to make a flashlight effect. like a black area covering the screen and a light object that looks through the black area.

 
http://www.robocaptain.com

The Chris Street

Administrator
Unspeakably Lazy Admin

Registered
  14/05/2002
Points
  48488

Game of the Week WinnerClickzine StaffAcoders MemberKlikCast StarVIP MemberPicture Me This Round 35 Winner!Second GOTW AwardYou've Been Circy'd!Picture Me This Round 38 Winner!GOTM December Third Place!!
I am an April FoolKliktober Special Award Tag
25th March, 2005 at 12:34:23 -

A large black active object with a hole in the middle, the size of the frame, position the hotspot to the top left corner, then: ALWAYS: set position of object to x left frame, y top frame? Then maybe create another circular active, give it some transparency and position it where the hole would be? Is that what you mean?

 
n/a

Willy C



Registered
  14/02/2004
Points
  1524

Game of the Week WinnerKlikCast StarPicture Me This -Round8- Winner!VIP MemberWii OwnerIt's-a me, Mario!Hero of TimeThe Cake is a LiePS3 OwnerI am an April Fool
Batman!Teddy Bear
25th March, 2005 at 13:01:18 -

I suppose that would work, but I would rather have this triangular shape so it looks like a flashlight

 
http://www.robocaptain.com

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
25th March, 2005 at 14:12:48 -

Seems quite easy, just do what circy suggests but take out a triangle and give it two (or more) directions and get it to follow the characters direction (rather than the top left. You may have to make it a lot larger than the screen size if it follows the character.

 
.

Dave Matthew (Jester Gaming)



Registered
  09/07/2004
Points
  148
25th March, 2005 at 15:19:05 -

what? if it is supposed to follow the character it does not need to be bigger than the screen size.

 
n/a

Willy C



Registered
  14/02/2004
Points
  1524

Game of the Week WinnerKlikCast StarPicture Me This -Round8- Winner!VIP MemberWii OwnerIt's-a me, Mario!Hero of TimeThe Cake is a LiePS3 OwnerI am an April Fool
Batman!Teddy Bear
25th March, 2005 at 18:35:20 -

yes I suppose it would if it has to rotate with the player using the flashlight

 
http://www.robocaptain.com

Dave Matthew (Jester Gaming)



Registered
  09/07/2004
Points
  148
25th March, 2005 at 18:41:00 -

no, really no! it has to be square, with a side length of max(screenWidth, screenHeight). But if you give it one animation for each direction it would never need to be BIGGER than the screen! that is absurd. Why hide something that is OUTSIDE the visible screen?

btw, I mean if the hotspot is centered and you always place the big black thing at (0,0) from character

Image Edited by the Author.

 
n/a

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
25th March, 2005 at 19:05:20 -

or you could set it to follow the playfield and just make sure you always center display on the guy. Change it's direction as the character changes its. Then it could be the exact size, otherwise it does need to be a bit biger so that the edges don't peek out during the game during movement.

 
Craps, I'm an old man!

Dave Matthew (Jester Gaming)



Registered
  09/07/2004
Points
  148
25th March, 2005 at 20:12:36 -

there is one problem though. Moving close to the edge of the frame will make it not scroll you know... (as there is nothing more to show) so it has to follow the character and has to be twice the screen size... if you know what I mean.
actually three times the screen size if you want it to work close to both left and right edge of the frame

 
n/a

SculptureOfSoul



Registered
  14/03/2005
Points
  52
25th March, 2005 at 21:25:59 -

I think the ideal method would be to utilize an overlay redux object, and draw an invisible "custom" triangle utilizing fastloops. During the loop, while it's plotting every point, it would also Grab the pixel color at that location and then add a predetermined value to it maybe RGB(25,25,25) or something. You could even use different values to simulate getting a better flashlight. The Custom Ultra Eye of the Sun flashlight could add RGB(75,75,75) to each pixel...3 times the lighting effect. On the same note, you could change the drawing algorithm to plot a bigger triangle when using a "more powerful" flashlight.

This would take up much less memory and CPU power than using a huge active object, and it would offer the benefits of easy customization. If you really wanted to make it badass, you could make a separate overlay that lies "underneath" the frame graphics...make this overlay clear or white or something and then draw all of the "walls" or "obstacles" in black(anything that the light won't shine through). During the fastloop triangle drawing routine, first check the invisible wall overlay. If the current point that the algorithm is plotting is black on the invisible overlay, don't change the color on the active frame.

The downside to this approach is that requires quite a bit of trig and the overlay redux object or some other object that can get and set the color of individual pixels, which means that doing this in TGF is out of the question.


 
Current Project: Undertaking the design of my mammoth RPG. Utilizing all of the knowledge gained while coding the now defunct "Shadow Reign".

AsparagusTrevor

Mine's a pint of the black stuff

Registered
  20/08/2002
Points
  2364

Game of the Week WinnerHas Donated, Thank You!VIP MemberEvil kliker
26th March, 2005 at 05:01:40 -

I made an example ages ago for someone who wanted to know the same thing:
http://www.asparagustrevor.nildram.co.uk/stuff/Torch.zip

This method uses the XOR ink effect.

 
Image

Long John Kickbag



Registered
  26/08/2002
Points
  148
26th March, 2005 at 08:31:02 -

I recently made an example of how to do this: www.clickteam.com/CTforum/showflat.php3?Board=upload&Number=267829 . You don't get quite the versatility of other methods like ink effects which allow full colour filtering (which I also made an example on ages ago: www.clickteam.com/CTforum/showflat.php3?Board=upload&Number=169477 ) but it's a lot faster. You could also use some transparent objects for weaker lighting.

 
Resize! - www.clicksplat.com/comparison.html

Willy C



Registered
  14/02/2004
Points
  1524

Game of the Week WinnerKlikCast StarPicture Me This -Round8- Winner!VIP MemberWii OwnerIt's-a me, Mario!Hero of TimeThe Cake is a LiePS3 OwnerI am an April Fool
Batman!Teddy Bear
26th March, 2005 at 09:18:07 -

liar

 
http://www.robocaptain.com

Long John Kickbag



Registered
  26/08/2002
Points
  148
26th March, 2005 at 09:25:17 -

AND's the one you use anyway...

 
Resize! - www.clicksplat.com/comparison.html

DistantJ [FZ Games]



Registered
  02/08/2004
Points
  855
26th March, 2005 at 14:16:54 -

SculptureOfSoul, your method sounds interesting, but I don't quite understand it. I haven't used Overlay Redux before, but it sounds like i could benifit from this.

Care to shine some light on how this works?

 
http://www.fzgames.com

SculptureOfSoul



Registered
  14/03/2005
Points
  52
27th March, 2005 at 02:31:01 -

Well my idea was merely speculation, but I thought that the overlay redux was capable of getting and setting any pixel on the screen. I'll have to check and see if it is indeed capable of modifying pixels "belonging to" active objects.

After thinking about what I'd posted for a bit I realized that there would need to be some way of storing the original color of the pixel as well, otherwise the flashlight would "lighten" the area, but when you turned or whatever the area would not go back to being dark. Eventually the whole screen would be pure white. Anyways, what would be needed is a 2 dimensional array that stores the original pixel color of every pixel it will be "lightening". During the drawing routine, before each pixel is lightened, it's original RGB value would need to be stored in the 2D array at ArrayPosition(X,Y), where the X and Y are the value of the pixel. Otherwise you could use a 3D array and just store each pixel sequentially, first pixel modified would be in array index 1, 2nd pixel at 2, etc. The RGB could be stored as a string that needs to get parsed, and the X and Y could be stored in the other 2 dimensions.

Anyhow, whenever the drawing routine is called it would first redraw every pixel stored in the "Modified" array, therefore returning them to their original color. It would then continue on with the drawing routine and modify whatever pixels were currently in it's path.

If this isn't possible with the overlay redux object, i'm pretty sure it'd be possible with a different object. I could have sworn that there was another object that allows you to get and set pixels, although I can't think of it off the top of my head.

Sooner or later I'll probably be making an example of this, as I intend to use similar effects in my RPG.

~SoS

 
Current Project: Undertaking the design of my mammoth RPG. Utilizing all of the knowledge gained while coding the now defunct "Shadow Reign".

DistantJ [FZ Games]



Registered
  02/08/2004
Points
  855
27th March, 2005 at 13:36:17 -

I'm still very interested. I'd like to be able to redraw my backgrounds like that at runtime. Sine wave effects for underwater and such. I might have to take a look at this object in more detail.

 
http://www.fzgames.com
   

Post Reply



 



Advertisement

Worth A Click