Parallax Question

Discussion in 'Programming' started by nlolotte, Jun 11, 2019 at 11:52 AM.

  1. nlolotte

    nlolotte Member

    Joined:
    Aug 3, 2016
    Posts:
    465
    Hello,

    How do I keep a layer with in view on the Y axis but also accommodate for parallax scrolling?

    I have the following code:

    Code:
    if obj_player.y > view_h-48
    {
    layer_y(Houses_Close,camera_get_view_y(view_camera[0])+128);
    layer_y(Houses_Far,camera_get_view_y(view_camera[0])+64);
    layer_y(Mountains,camera_get_view_y(view_camera[0])+16);
    }
    
    I tried:

    Code:
    if obj_player.y > view_h-48
    {
    layer_y(Houses_Close,camera_get_view_y(view_camera[0])/2+"value");
    layer_y(Houses_Far,camera_get_view_y(view_camera[0])/2+"value");
    layer_y(Mountains,camera_get_view_y(view_camera[0])/2+"value");
    }
    This does allow for the effect but the layers aren't always in view. My room height is 1024. Any help would be appreciated.

    Thanks,

    Nathaniel
     
  2. zATARA_0

    zATARA_0 Member

    Joined:
    Apr 10, 2019
    Posts:
    40
    you could use 'clamp' to make sure they stay within the range you want.

    clamp(view_camera[0])/2+"value", 0, room_height);
     
  3. nlolotte

    nlolotte Member

    Joined:
    Aug 3, 2016
    Posts:
    465
    Thanks for your reply,

    I tried this just now but it doesn't seem to give me the desired results. The layer still leaves the view window.
     
    Last edited: Jun 11, 2019 at 11:59 PM
  4. zATARA_0

    zATARA_0 Member

    Joined:
    Apr 10, 2019
    Posts:
    40
    alter the clamp amounts by the size of the thing that goes out of the window maybe.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice