﻿ Campfire Light

1. ## Campfire Light

Here's a simple, dopey little script. It draws a wavering circle of light (like that produced by a fire or candle), centered at the location of an FFC (see the picture, though you won't see it waver...). I tried to explain everything in the comments, but it basically draws a filled, translucent circle with a slightly random radius. You can control the radius and the amount of "variance" from that radius, as well as how fast it wavers. You can also set the color of the circle. The circle is drawn on layer 6, so it affects the way Link and enemies look when they're in the light. Since I tied the circle to the center of the FFC, it might be interesting to use this with a moving FFC though I haven't tried it yet.

I was going to use it for some camp-fire mood lighting, but maybe someone else can do something cooler with it....

I didn't spend any time on error handling/range checking, so I don't know what will happen, if for instance, the wobble is greater than the min_radius....

In the screenshot, I used a min_radius of 24 and a wobble of 3 and it looked decent. You'll have to experiment with the color to get the proper look of the transparency.

Code:
```// Script  : Light_Circle
// Purpose : Renders a circle of "light" on the screen.  This
//           can be used to simulate light cast by fires,
//           lanters, etc.  The center of the circle is positioned
//           at the _center_ of the FFC to which this
//           script is assigned.
// Args    :
//                Measured from the CENTER of the FFC.
//  * wobble    : the maximum number of pixels by which to vary
//                the radius.  This can be used to simulate the
//                wavering light of a campfire or candle.
//  * speed     : The speed of the wobble.  1 = recompute the wobble
//                every frame, 2 = every other fame,
//                3 = every third frame, etc.
//  * color     : The color used to draw the circle, from the 256 pallete.
// Notes   :
//  1. As originally written, the script draws the circle on
//     layer 6 so that it affects Link's colors.
//
ffc script Light_Circle{
void run(int min_radius, int wobble, int speed, int color){

int speed_count = 0;

// Draw a translucent circle, filled, to simulate
// the light thrown by a fire or light.
while(true){
if(speed_count >= speed){
speed_count = 0;
}
Screen->Circle(6, this->X + 8, this->Y + 8, rand_r, color, 1, 0, 0, 0, true, 64);

speed_count++;
Waitframe();
}

} // run
}```

2. ## Re: Campfire Light

Might be nice to attach it to Link for some aLttP style candle type scripts

3. ## Re: Campfire Light

Maybe make everything BUT the circle black, and center it around Link?

4. ## Re: Campfire Light

Originally Posted by Revfan9
Maybe make everything BUT the circle black, and center it around Link?
I'd thought about that, too, but I couldn't figure out how to go about it....

I figured you'd draw the whole screen in ZQuest as if it were "lit", but then somehow script most of it to be black...? I guess I could try drawing a black rectangle over the whole screen, then drawing the circle around Link. I'm not sure how the transparency would work...

*EDIT*
Maybe the solution is to draw a bunch of black circles outward starting some distance from Link?

5. ## Re: Campfire Light

Originally Posted by ScaryBinary
I'd thought about that, too, but I couldn't figure out how to go about it....

I figured you'd draw the whole screen in ZQuest as if it were "lit", but then somehow script most of it to be black...? I guess I could try drawing a black rectangle over the whole screen, then drawing the circle around Link. I'm not sure how the transparency would work...

*EDIT*
Maybe the solution is to draw a bunch of black circles outward starting some distance from Link?
Here's something cool for you.

Code:
`Screen->Arc(6,Link->X+8,Link->Y+8,40,450,90,16,1,0,0,0,true,true,128);`

6. I have a question..
but first I just want to say that this script is awesome!!
I have been wanting to do this in my game for quite some time now!

...alright, here's my question...
Is there a way i could, slightly, adjust this script to allow me to set the cset that is used when link walks into the light??
(I really don't care for the brown/gray color links turns to when he walks into the light)
If so, then how would I do it? (I have NO experience with writing ZScripts! )

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•