Parallax BG controller cancels my BG Hor. Speed.... help!

M

Mister Bread

Guest
Hey everyone, I have my parallax bg's working perfectly. However, my code disables my moving foreground clouds and I can't seem to figure out how to get around it.

This is my Step Event for my parallax bg controller :

Code:
background_x[0] = view_xview[0];
background_y[0] = view_yview[0];

background_x[1] = view_xview[0];
background_y[1] = view_yview[0];

background_x[2] = view_xview[0];
background_y[2] = view_yview[0];

background_x[3] = view_xview[0];
background_y[3] = view_yview[0];

background_x[4] = view_xview[0];
background_y[4] = view_yview[0];

background_x[5] = view_xview[0];
background_y[5] = view_yview[0];

background_x[6] = view_xview[0];
background_y[6] = view_yview[0];

view_xview += 5*(keyboard_check(vk_right) - keyboard_check(vk_left))

for (var i = 0; background_visible[i]; i++)
{
    background_x[i] = parallax[i] * view_xview;
}
The for loop is the controller for the parallax while the other code centers the backgrounds to my view.

My only problem is figuring out how to make background[6], my foreground clouds "background", to still have horizontal movement.

I've used background_x[6] += 1 in a separate controller before, but this parallax code cancels it...

Is there any way to recode the for loop to have background[6] be excluded? Or... should I find a different route to have foreground moving clouds..?

Thank you for your help!
 
M

Mister Bread

Guest
All you gotta do is add background_hspeed[0] to background_x[0] and so on. ;)
Doesn't work... Since my parallax bg for loop sets the x position of the backgrounds, it won't move. Using the background_hspeed function or in the room editor.
 
M

Mister Bread

Guest
And while you're here, any tips to make vertical parallax function similarly? I tried to use a similar code but I can't seem to figure that one out for some reason
 
Last edited by a moderator:

obscene

Member
Of course it works.... here's part of my own parallax code...

background_x[2]+=background_hspeed[2]+xmoved*.97
background_y[2]+=background_vspeed[2]+ymoved*.97
// (xmoved and ymoved in my case are how much the camera moved during the step)

You just add.
 
M

Mister Bread

Guest
That's odd... I can't seem to get mine to work. I'll fiddle with it more.

And regarding parallax, any tips on doing y-axis parallax?
 

obscene

Member
Should work identical to horizontal. I can only tell you how I do it and hope it helps...

First I have a camera object that follows the player or whatever target it's set to. After it moves (and the view moves along with it, I take a measurement...
Code:
// Calculate view movement since last step
xmoved=view_xview-xview_previous
ymoved=view_yview-yview_previous
xview_previous=view_xview // Save for next step
yview_previous=view_yview
Afterwards I take xmoved and ymoved to calculate the new background positions. In my case, 0 - 4 are backgrounds and 5 - 7 are foregrounds...
Code:
    background_x[0]+=background_hspeed[0]+xmoved*.99
    background_y[0]+=background_vspeed[0]+ymoved*.99
    background_x[1]+=background_hspeed[1]+xmoved*.87
    background_y[1]+=background_vspeed[1]+ymoved*.87
    background_x[2]+=background_hspeed[2]+xmoved*.78
    background_y[2]+=background_vspeed[2]+ymoved*.78
    background_x[3]+=background_hspeed[3]+xmoved*.69
    background_y[3]+=background_vspeed[3]+ymoved*.69
    background_x[4]+=background_hspeed[4]+xmoved*.6
    background_y[4]+=background_vspeed[4]+ymoved*.6
    
    background_x[5]+=background_hspeed[5]+xmoved*-.75
    background_y[5]+=background_vspeed[5]+ymoved*-.75
    background_x[6]+=background_hspeed[6]+xmoved*-.9
    background_y[6]+=background_vspeed[6]+ymoved*-.9
    background_x[7]+=background_hspeed[7]+xmoved*-1.05
    background_y[7]+=background_vspeed[7]+ymoved*-1.05
 
M

Mister Bread

Guest
Thank you, I really appreciate the help. I'll have to give this a shot and see if it helps.

I'm still getting used to parallax scrolling and the coding involved. It's hard to wrap my head around.
 
M

Mister Bread

Guest
Just using simple parallax scrolling code worked for my y-axis.

Code:
background_x[3] = view_xview[0];
background_y[3] = view_yview[0]/1.125+100;

background_x[4] = view_xview[0];
background_y[4] = view_yview[0]/1.25+200;

background_x[5] = view_xview[0];
background_y[5] = view_yview[0]/1.5+400;
for example...

It created a new issue, but I'll start a different topic for that.

However, I still cannot get my foreground to move. I had background_x[6] += 1 in the step event, tried doing what @obscene suggested... and nothing. Can't get the foreground to move on its own. Dunno what I'm doing wrong there...
 
Top