How do I change player speed based on screen location ratio

Get help using Construct 2

Post » Thu Apr 21, 2016 3:06 am

I know there's some handy algorithm i should have learned in school that will probably make this one step.

But basically i have a side scrolling flying game, and i want the background speed to scroll faster the closer to the right hand side of the screen you move, and slower the closer to the left you are.

on the far left, the slowest the background should ever move is 30, and the furthest to the right you can move is about 3 quarters the width of the layout, and the background should be moving is 200

thanks math genius's!
B
87
S
44
G
16
Posts: 1,002
Reputation: 17,932

Post » Thu Apr 21, 2016 4:54 am

ok i think i figured it out, and it was way simpler than i was thinking it was going to be.

bg.speed = distance(player.x, player.y, viewportLeft(0), player.y)

thus, the further the player is from the left hand side of the screen, the faster the bullet speed

duh
B
87
S
44
G
16
Posts: 1,002
Reputation: 17,932


Return to How do I....?

Who is online

Users browsing this forum: datiel12, tarek2 and 61 guests