PDA

View Full Version : Campfire Light



ScaryBinary
02-18-2008, 10:44 PM
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....

http://img86.imageshack.us/img86/9061/zelda012pg7.jpg

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.


// 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 :
// * min_radius: the minimum radius, in pixels, of the circle.
// 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 rand_r = min_radius;
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){
rand_r = min_radius + Rand(wobble);
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
}

Joe123
02-19-2008, 12:55 PM
Might be nice to attach it to Link for some aLttP style candle type scripts

Revfan9
03-17-2008, 11:51 PM
Maybe make everything BUT the circle black, and center it around Link?

ScaryBinary
03-20-2008, 07:16 AM
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*
:banghead: Maybe the solution is to draw a bunch of black circles outward starting some distance from Link?

Gleeok
03-20-2008, 11:41 PM
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*
:banghead: Maybe the solution is to draw a bunch of black circles outward starting some distance from Link?

Here's something cool for you.


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

Mean Mr Mustard
04-12-2014, 04:54 PM
I have a question..
but first I just want to say that this script is awesome!! :highfive:
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! :confused_white: )