"""
Rory Solomon
Code Toolkit: Python
Example of a parallax effect

Inspired by:
      http://1morecastle.com/wp-content/uploads/2013/01/parallax-scrolling-mario.gif

The images referenced below are available here:
   - http://composingdigitalmedia.org/ccr/week03-mountains.png
   - http://composingdigitalmedia.org/ccr/week03-hills.png
   - http://composingdigitalmedia.org/ccr/week03-foreground.png
Download these and save them into your sketch folder.
"""

def setup():
    size(800,375)

    global mountainsImage
    global hillsImage
    global foregroundImage

    mountainsImage = loadImage("week03-mountains.png")
    hillsImage = loadImage("week03-hills.png")
    foregroundImage = loadImage("week03-foreground.png")

def draw():

  rg = map(mouseX, 0,width, 155,10)
  b = map(mouseX, 0,width, 255,50)
  background(rg,rg,b)

  mtnX = map(mouseX, 0,width, 0,-20 );
  image(mountainsImage, mtnX,50)

  hillsX = map(mouseX, 0,width, -20,-200 )
  image(hillsImage, hillsX,250)

  fgX = map(mouseX, 0,width, 0,-2000 )
  image(foregroundImage, fgX,225)

  darkness = map(mouseX, 0,width, 0,225)
  fill(0,darkness)
  rect(0,0,width,height)