User Tag List

Results 1 to 6 of 6

Thread: Campfire Light

  1. #1
    Keese ScaryBinary's Avatar
    Join Date
    Dec 2006
    Age
    49
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    935
    Level
    10
    vBActivity - Bars
    Lv. Percent
    61.84%

    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    :
    //  * 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
    }

  2. #2
    &&
    ZC Developer
    Joe123's Avatar
    Join Date
    Sep 2006
    Age
    33
    Posts
    3,061
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    7,323
    Level
    26
    vBActivity - Bars
    Lv. Percent
    11.69%

    Re: Campfire Light

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

  3. #3
    Lynel Revfan9's Avatar
    Join Date
    Jun 2005
    Location
    In front of a screen. I never leave.
    Age
    32
    Posts
    1,160
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    3,409
    Level
    18
    vBActivity - Bars
    Lv. Percent
    75.87%

    Re: Campfire Light

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

  4. #4
    Keese ScaryBinary's Avatar
    Join Date
    Dec 2006
    Age
    49
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    935
    Level
    10
    vBActivity - Bars
    Lv. Percent
    61.84%

    Re: Campfire Light

    Quote Originally Posted by Revfan9 View Post
    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. #5
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,827
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,979
    Level
    33
    vBActivity - Bars
    Lv. Percent
    28.41%

    Re: Campfire Light

    Quote Originally Posted by ScaryBinary View Post
    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);
    This post contains the official Gleeok seal of approval. Look for these and other posts in an area near you.

  6. #6
    Mean Mr Mustard Mean Mr Mustard's Avatar
    Join Date
    Apr 2014
    Location
    USA
    Age
    37
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    388
    Level
    7
    vBActivity - Bars
    Lv. Percent
    16.27%
    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! )

Thread Information

Users Browsing this Thread

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
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social