How do i work out the maths behind what i just did

0 favourites
  • 8 posts
From the Asset Store
Be discreet and rescue your friends from behind enemy lines.
  • ive made my own little parallax system (i find it easier to learn that way )

    But i cant work out the maths.

    I have a 200 width tile passing through a 100 width layout at 40 pixels a second, and this takes 2.5 seconds.

    As youl see in the capx ive managed to get myself into numbers such as 0.828 seconds (when the speed is 60) .

    Whats the maths behind this so i can easily calculate this when i need it .

    Phew

    dl.dropbox.com/u/84483952/parallax%20%281%29.capx have

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You could perhaps use this formula:

    speed * time = distance

    but solve for time:

    time = distance/speed

    distance is 100 since you create the tiledBgs with an x of -100

    so you get this:

    100/40 = 2.5

    100/50 = 2

    100/60 = 1.666

    The last number you had is closer to 50/60 = 0.8333 which also works since the tiledBg texture is 50 pixels wide, you just end up with more overlap.

    You can get the same effect without the warmup time by just positioning the tiledBg's in you layout and setting their speed. Then replace all your events with one every tick event:

    Every tick

    set x to self.x%50-50

    Change the 50s to whatever the texture width is.

  • Wow!!, i shall study this and try understand it , i get myself in some real messes with this :P

    Great response.

    I was trying to explain this in church earlier using bricks in the wall lol. Someone thought it was going down half a second for every 10 pixels added or something.

    Thanks for the time.

  • Parallax can be a pain to wrap your head around! Good luck!

  • im usualy ok, ill make the width of the tile 50000 if i have to , but that has to be effecting performance.

    This game here has about 10 layers, all with width of 50000 :P

    youtube.com/watch

    I know Adam (englishacorn) has a cool way of doing it, but i dont completely get it . Saying that i dont get half my own things.

  • You can get the same effect without the warmup time by just positioning the tiledBg's in you layout and setting their speed. Then replace all your events with one every tick event:

    Every tick

    set x to self.x%50-50

    Change the 50s to whatever the texture width is.

    working brilliant...

    whats does the command self actualy mean though?

  • From the manual:

    https://www.scirra.com/manual/78/expressions

    he expression Self can be used as a short-cut to refer to the current object. For example, in an action for the Player object, Self.X refers to Player.X.

  • You can get the same effect without the warmup time by just positioning the tiledBg's in you layout and setting their speed. Then replace all your events with one every tick event:

    Every tick

    set x to self.x%50-50

    Change the 50s to whatever the texture width is.

    Ive been doing this, but i find that the width/height of the texture doesnt work, just some obscure number i have to take a long time guessing (im sure its related somehow, any idea?)

    Here for instance. im doing it with height instead of width and the only number that works seemlessly is 130, which doesnt seem to have anything to do with the height. ?

    Here is the capx

    thanks for your time.

    dl.dropbox.com/u/84483952/130.capx

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)