Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Infinite Line

edited August 2014 in General Posts: 145

I've been designing an infinite line scrolling down a screen. However, there are 2 problems. First, the intersections are don't look like exact intersections. Secondly, the line flickers occasionally. Could someone help improve this?

Here is the code:

  -- Use this function to perform your initial setup
  function setup()
  print("Hello World!")

   xcounter = 0
   ycounter = 0
   linex[1] = math.random(WIDTH/10,WIDTH/1.1)
   liney[1] = ycounter

   for i=2,6 do
        x = math.random(WIDTH/10,WIDTH/1.1)
        y = math.random(HEIGHT/5,HEIGHT/4)
        ycounter = ycounter + y  
        linex[i] = x
        liney[i] = ycounter

-- This function gets called once every frame
function draw()

    -- This sets a dark background color 
    background(40, 40, 50)

    -- This sets the line thickness

    -- Do your drawing here

    for i = 1,5 do



            x = math.random(WIDTH/10,WIDTH/1.1)
            y = math.random(HEIGHT/5,HEIGHT/4)

            linex[6] = x
            liney[6] = y+HEIGHT   

     for i=1,5 do

           liney[i] = liney[i] -3




  • IgnatzIgnatz Mod
    edited August 2014 Posts: 5,396

    @austinmccoy - this change to your line code should fix the joins


    I don't see the flickering - the lines sometimes look a little shimmery, but I think that is just the effect of the anti-aliasing that blends the white line into the dark background

  • What could I do to reduce the shimmering? Even a light background doesn't reduce the shimmering that much.

  • IgnatzIgnatz Mod
    Posts: 5,396

    When you pause the program, the lines look sharp, so I think it is the anti-aliasing at work (and you can't turn it off).

    I would play around with colour combinations to see if you can reduce it. It is just a visual effect.

  • Okay, thanks!

  • IgnatzIgnatz Mod
    Posts: 5,396

    Also try playing with the drawing settings, like smoothing. Others know more about that than I do.

  • Smoothing doesn't seem to help. However, additive blending reduces the frequency of the shimmering.

  • IgnatzIgnatz Mod
    Posts: 5,396

    @austinmccoy - ah, good work =D>

Sign In or Register to comment.