Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,203 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to use Vectors? #158577
10/03/07 21:38
10/03/07 21:38
Joined: Oct 2006
Posts: 45
J
juggalo10101 Offline OP
Newbie
juggalo10101  Offline OP
Newbie
J

Joined: Oct 2006
Posts: 45
ive been reading up on vectors but theres not alot of info on how to use them. I know what they do but how do i make them? Better yet how would i say "if entity_1 close to player then do something"
thanks,
juggalo10101

Re: How to use Vectors? [Re: juggalo10101] #158578
10/03/07 21:50
10/03/07 21:50
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Positions represent 3 coordinates in 3D space. So, your player's position has 3 coordinates: x,y,z.

A vector can be interpreted as "arrow" from the origin (x=0, y=0, z=0) to a specific point/position in space. Additionally, a vector can be interpreted as well as direction from the origin to this point.

You can add and subtract vectors by adding/subtracting their components. You can even rotate and scale vectors. Just imagine them as arrows and try to add, scale and rotate them. Subtraction is a bit trickier, though: if you subtract one position/vector A form another B (B-A), the result vector returns the direction from point A to B. So, if you would add to the result vector the A vector, your would get the vector which represents the position B.

To determine the distance between two points, you take both vectors of these points, subtract them (so that you get the direction) and calculates the LENGTH of the vector. Just imagine an arrow from A to B.. the length of the arrow is the distance between A and B. In Lite-C you can use vec_length for a given vector to determine his length. But you can also use the function vec_dist to determine the distance between two points/vectors.

So, assume you want to check if you come close to your opponent, which is the you pointer now:

Code:
if (vec_dist(my.x, you.x) < 50) {
//do something
}



There are a lot of tutorial on vector math and what vectors are on the internet, just google them!

Re: How to use Vectors? [Re: HeelX] #158579
10/03/07 22:48
10/03/07 22:48
Joined: Oct 2006
Posts: 45
J
juggalo10101 Offline OP
Newbie
juggalo10101  Offline OP
Newbie
J

Joined: Oct 2006
Posts: 45
ah thank you i understand it now

Re: How to use Vectors? [Re: juggalo10101] #158580
10/04/07 11:31
10/04/07 11:31
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
I think you should do the lite-c Workshop. You can learn there many things


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1