Distance to horizon

You must understand the Game Editor concepts, before post here.

Distance to horizon

Postby jlorinser » Sun Jun 24, 2007 12:09 am

Hi,

I'm trying to calculate the distance between 2 actors in a simulated 3D environment. An enemy starship comes at the player's ship (located at the bottom of the screen) from the "horizon" (located roughly at 1/4 of the screen height from the top) towards the player.

I´m moving the enemy starship slower at the horizon and speeding it as it moves to the bottom of the screen using:

Code: Select all
MoveTo("Enemy", 0, 0, (Enemy.y / 600) * 2, "Player", "");

and this works well to create the illusion of depth, but the distance is ovbiously also decreased at the speed of movement.

I tried using the distance function, but the problem is that it calculates the distance linearly and thus the enemy starship does not "cover more space" (per pixel moved on the y axis) at the top of the screen than what it does almost at the bottom.

I'm stuck at this point :x . Anyone have a solution?

Thanks in advance
jlorinser
 
Posts: 11
Joined: Mon Feb 05, 2007 5:38 am
Score: 1 Give a positive score

Postby metal_pt » Tue Jun 26, 2007 11:52 am

Hmmm.

What about creating a Z variable?
the real distance could be something like:
realdistance=sqrt(pow(distance(x, y, enemy.x, enemy.y),2)+pow(Z,2));

Best regards
]v[eta[_ - Using GE since June, 15 2007
Currently using v1.3.8 Registered
metal_pt
 
Posts: 117
Joined: Sat Jun 16, 2007 12:57 pm
Location: Sintra, Portugal
Score: 2 Give a positive score

Postby jlorinser » Thu Jun 28, 2007 7:43 pm

Thanks metal_pt,

What would the value of Z be? would it be the distance traveled (starting from horizon)?

Thanks again...
jlorinser
 
Posts: 11
Joined: Mon Feb 05, 2007 5:38 am
Score: 1 Give a positive score

Postby metal_pt » Thu Jun 28, 2007 8:03 pm

Well, in my mind, z should be the virtual depth of the ship.
]v[eta[_ - Using GE since June, 15 2007
Currently using v1.3.8 Registered
metal_pt
 
Posts: 117
Joined: Sat Jun 16, 2007 12:57 pm
Location: Sintra, Portugal
Score: 2 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron