Super Mario Bros 2012 Doomsday Reactor

    Parallax Scrolling Code

    Share
    avatar
    BuzzNBen
    Admin

    Posts : 42
    Join date : 2011-12-24
    Location : United States

    Parallax Scrolling Code

    Post by BuzzNBen on Sat Dec 31, 2011 7:22 pm

    /*========================================================================

    ====================
    = Parallax Control =
    ====================

    Arguments (taken from creation code):
    num_bkgs : Number of backgrounds in the Room.
    parallax[x] : Parallax Rate for background layer 'x'.
    'x' must be an integer between 0 and 7 inclusive.
    All values greater than zero are valid.
    Higher values increase parallax speed.
    A value of 10 moves the background with the port.
    -1 Disables Parallax control (Useful for self-scrolling BKGs)
    parallax_y[x] : Parallax rate for the 'y' axis of layer 'x'.

    ===========================================================================*/

    // Loop for setting parallax for specified number of backgrounds.
    var i1;
    for (i1=0; i1<num_bkgs; i1+=1)
    {
    if parallax[i1] != -1 // If Sentinel value is not used
    {
    if parallax[i1] != 0 // Division by Zero Trap
    background_x[i1] = view_xview[0]- view_xview[0]*(parallax[i1]/10.0)
    else // Error Trap for Zero
    background_x[i1] = view_xview[0]
    //If parallax is also applied to the 'y' axis
    if parallax_y[i1] !=0
    {
    background_y[i1] = view_yview[0] - view_yview[0]*parallax_y[i1]
    }
    }
    }


    _________________
    My Website isHere.
    My Youtube isHere.

    Main Administrator & Founder of Super Mario Brother 2012 Doomsday


    If you must ask, yes I'm a whovian.

      Current date/time is Sun Oct 22, 2017 7:28 pm