Calulate Higest Distance

Get help using Construct 2

» Sun May 10, 2015 4:16 pm

I have multipile player objects. I want to zoom my game out enough to they all will be seen.

I think that this is most easily be done by just calculating distance between objects and doing re-scaling with it. Higher number, less zoom. If you have better idea to do the same, I'll accept it as answer as well.

So, how to calculate higest distance between like +4 same objects?
~~~~Jabutosama
B
14
S
3
Posts: 68
Reputation: 1,449

» Sun May 10, 2015 4:29 pm

Using the search I found these two topics:

viewtopic.php?t=69772

viewtopic.php?t=73576
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

» Sun May 10, 2015 4:54 pm

this isn't answer good enough because they work if there is two objects, but number of objects I have can change a lot, even during the game.
~~~~Jabutosama
B
14
S
3
Posts: 68
Reputation: 1,449

» Sun May 10, 2015 5:21 pm

I guess it will only work with four variables and then something like this:

LowestX
HighestX
LowestY
HighestY

every tick
Set lowestX to 99999999
Set HighestX to -9999999
Set lowestY to 99999999
Set HighestY to -9999999

for each player
if player.x < LowestX
> set Lowest.X to player.x

etcetera

and then you can change the example from above with these Global Variable values
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

» Sun May 10, 2015 5:29 pm

you could also do a:

for each sprite (ordered by sprite.x, ascending): set lowestx to sprite.x; stop loop
for each sprite (ordered by sprite.x, descending): set highestx to sprite.x; stop loop
etc.

set scrollx to (highestx+lowestx)/2
set scrolly to (highesty+lowesty)/2

and calculate the zoom according to your aspect ratio etc.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

» Sun May 10, 2015 5:30 pm

mindfaQ wrote:you could also do a:

for each sprite (ordered by sprite.x, ascending): set lowestx to sprite.x; stop loop
for each sprite (ordered by sprite.x, descending): set highestx to sprite.x; stop loop
etc.

set scrollx to (highestx+lowestx)/2
set scrolly to (highesty+lowesty)/2

and calculate the zoom according to your aspect ratio etc.

Much better solution.
I'm so not into loops, haha..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Return to How do I....?

Who is online

Users browsing this forum: Biim and 20 guests