How do I get parallaxed XY of an object?

Get help using Construct 2

Post » Sun Mar 23, 2014 3:31 am

I'd like to get the Parallaxed coordinates of an object... so in essence, where it's actually drawn on the screen..

I'm making a minimap and I have some background objects that use parallax 25,25.. I'd like them represented on the minimap.. but they don't line up because of the parallax delay (scrollrate).

The 'camera' is lerping to position: lerp(scrollx, player.X, 0.9*dt (and same for the Y)

Can anyone offer a suggestion? I know it's probably not possible with a simple equation since the scrollrate depends on when the player is moving (and how fast). And on a map it wouldn't really accurately say where an object is... but the parallax effect can help make something seem giant or really far away (depth wise) and I still would like to represent it in the minimap.

Thanks!
B
88
S
29
G
14
Posts: 1,154
Reputation: 15,003

Post » Sun Mar 23, 2014 3:40 am

I am not in front of C2, but maybe the expressions:

Self.x +(100-LayerParallaxX(Self.LayerName))*WindowWidth/100
Self.y +(100-LayerParallaxY(Self.LayerName))*WindiwHeight/100

Would return the actual x and y position relative to the layout

Edit:replace self by your object name
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Sun Mar 23, 2014 6:16 am

That didn't work...However I failed to mention I'm trying this on an unbound layout.

So my MiniMap for enemies that are on the same layer as the player is:

Every Tick Set Position (of Enemy_Indicator) to:
Player_indicator.X + (alien.X - Player.X) / MiniMapZoom
Player_indicator.Y + (alien.Y - Player.Y) / MiniMapZoom

The player indicator I am treating as the "center".. since it's like Zans Minimap (from minecraft). This works perfectly for all object on the same layer. MiniMapZoom is the scale of the map (increments of 10).

So when you begin the level, the player is not moving and all object's positions are the same distance for all layers. It's not until the player moves does the the Xs grow apart. The drawn parallaxed position would seem to have to include the player's speed or the scroll amount of the screen...

Something like:

Every Tick Set Position (of Planet_Indicator) to:
Player_indicator.X + (Planet.X * (LayerParallax(3) / 100) - Player.X) / MiniMapZoom
Player_indicator.Y + (Planet.Y * (LayerParallax(3) / 100) - Player.Y) / MiniMapZoom

but this doesn't work... whatever the calculation is, the modifier would have to equal 0 at the beginning before the player starts moving.. then it would have to accumulate as the player started to move. I've been working on this too long and can't see it... I can feel the answer.. but it eludes me!
B
88
S
29
G
14
Posts: 1,154
Reputation: 15,003

Post » Sun Mar 23, 2014 5:38 pm

here is a capx I am working on... the object on the "far away" layer(30,30) is not working right on the minimap...

https://dl.dropboxusercontent.com/u/362 ... nimap.capx
B
88
S
29
G
14
Posts: 1,154
Reputation: 15,003


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests