Running Forward Objects Scrolling Past Easy Solution

0 favourites
  • 6 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • Hello, all.

    Have a quick question.

    Has anyone found an easy coding solution for something like a semi FPS shooter motorcycle type game objects scrolling past?

    Let me explain this better.

    I have a great top down solution from this site for towers, which is basically done ingeniously with layer scaling of the same sprite (slightly larger scale on stacked layers) and just scroll to behavior on the player sprite produces amazing effects on the towers, totally believable fake 3D perspective.

    For this, imagine something like a motorcycle driving on a road in less than first person, so the road basically takes up 3/4 of the screen with a sky above. Has anyone come up with a coding solution for say trees, rocks, or other sprites going by which is efficient, easy to code, and highly believable?

    I imagine this would involve some sort of scaling of the objects going by like rocks or maybe layer scaling as well.

    Also, the road would take up the whole screen horizontally, so I guess the perspective lines would be different.

    One way to do it manually would be to draw out all the perspective lines maybe as a reference, from a central point maybe a quarter of the screen down and then use LERP to estimate in between positions? But this sounds awfully coding intensive, so thinking someone who knows this process better mathematically may have already done it in a jiffy.

  • Hmmm....?

    If I follow what you are asking you have obstacles coming towards you in a driving game and you want them to get larger as they get closer right?

    I would use the objects Y position and when it reaches certain numbers along the traveled path increase the scale of the object.

    It won't be perfectly smooth but if objects are moving fast you won't notice it much.

    I used that only for a bowling ball being thrown so the object went small as distance increased.

    If you don't want to use the Y position you could set up some invisible sprites across the screen that any time the objects touch them it increases the scale of the object.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well, I wanted something cooler.

    My current idea is to draw out lines from the perspective center point with an array [auto spawn] (about a quarter of the way down the screen), then sort of a radial from that point to all the points on the bottom of the screen.

    That takes care of perfect perspective lines.

    Then I guess I would have to make sure there's no overlap depending on the drawn line, which is some accuracy loss, maybe not, I'll have to see.

    Then depending on where the object is spawned, like a rock, there would be collision detection with that perspective line (not sure how to make it stick so it would travel along the line, I'm sure someone here has done something similar. I just hope they're reading and will chime in hopefully).

    Then I could also play with scale (depending on how close to the bottom edge of the screen) depending on position or collision with a scale object, but again by trial and error.

    I was hoping there was a perfect math solution for this (easy code).

  • LOl!

    OK well I hope you figure that out.

    What you described is the same principle I just described and I just simplified it. The math is based on your object Y or X position.

  • Ok that was weird. It wasn't really an LOL type situation.

    From playing around, I guess my question is: has anyone figured out the relationship between the slope of a perspective line and a scale algorithm?

  • "Well, I wanted something cooler."

    You gave an example for a driving game in your OP and I gave you a simple solution but hey if that is not cool enough for you best of luck.

    That is why I LOL'd.

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