Need help with fake z-depth.

For questions about using Classic.

Post » Sat Apr 04, 2009 11:36 am

Im prototyping a 2d shootergame with fake 3d depth (think double dragon).
Right know the game knows what z-depth an object has based on what sprite its above, and that works. Problem with that though is that its hella inflexible and complex.
Is there a way to tell an object its z-depth based on what coordinates the object has?

You could create a private variable and tell it the object y, but that would be too exact. I would like Construct to tell the object what position it has every 20 pixels.
So, an object placed x.20 y.460 would have 23 in z-depth.
x.600 y.423 = z-depth 21
x.200 y.469 = z-depth 23
I think you get the point.

I also would like to know if there is a way to measure the distance between two points, that would be really usefull for a multiplayer camera.
ex = Distance between A & B = 100 pixels, the camera would then zoom out a sufficent ammount to cover both players.
B
2
G
4
Posts: 23
Reputation: 1,096

Post » Sat Apr 04, 2009 12:52 pm

Depends on what you want, but I think this is probably nearly it.

I'd do it like this (roughly).

> For: "Order", 1 to LayoutHeight / 20
> System: Number 'Object.Y' is between LoopIndex("Order") * 20, (LoopIndex("Order") * 20) + 20

Sprite/Family: Set 'Zorder' private variable to LoopIndex("Order")
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Sat Apr 04, 2009 1:36 pm

You could also have a shadow object that would tell the x/z and the distance between the sprite and the shadow the y. If you don't want a shadow you could make it invisible.

Also, there's a command dist(x, y, x2, y2) that gets the distance between two points.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,422

Post » Sun Apr 05, 2009 2:11 pm

Excellent Arima and Rich, Thank you :)
B
2
G
4
Posts: 23
Reputation: 1,096

Post » Sun Apr 05, 2009 3:16 pm

for each ordered, and you give objects a pv/use their .y pos for their depth?
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests