Gamestudio Links
Zorro Links
Newest Posts
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
4 registered members (AndrewAMD, exile, flink, monarch), 1,558 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Confusion w/earthball camera movement #315323
03/14/10 18:46
03/14/10 18:46
Joined: Oct 2009
Posts: 49
L
Lecithin Offline OP
Newbie
Lecithin  Offline OP
Newbie
L

Joined: Oct 2009
Posts: 49
I've been studying the Earthball script and have been messing with the coding so that I may understand C-lite better. Everything in Earthball makes sense to me excluding the final few lines where the camera movement is calculated.

Before function main() there is a VECTOR defined
Code:
VECTOR vSpeed, vAngularSpeed, vForce, vMove;



the following is in function main() in while(1)
Code:
vForce.x = -5*(key_force.x + mouse_force.x);	// pan angle
vForce.y = 5*(key_force.y + mouse_force.y);	// tilt angle
vForce.z = 0;	// roll angle
vec_accelerate(vMove,vAngularSpeed,vForce,0.8);
vec_add(camera.pan,vMove);



I understand the key_force and mouse_force functions but I'm not sure how vec_accelerate works in this example.

It seems to me that vMove would be 0 at this point since it's never called or calculated before vec_accelerate, the same with vAngularSpeed. I'm confused because if the distance argument (vMove) and the speed arguement (vAngularSpeed) are 0 then what is the point of vec_accelerate at this point?

I'm sure this is very simple I'm just new to Gamestudio and vector's so I'm confused as to what is going on here.

I know what is happening here (we're calculating our rotation and accelerating it based off the arrow keys and mouse movement) I just can't seem to put 2+2 together.

And for that matter, what exactly does VECTOR do, I can't seem to find it in the documentation.

The next section of code is very similar to this so I'm hoping if I can make sense of this I can figure out the next as well.

Re: Confusion w/earthball camera movement [Re: Lecithin] #315472
03/15/10 19:49
03/15/10 19:49
Joined: Oct 2009
Posts: 49
L
Lecithin Offline OP
Newbie
Lecithin  Offline OP
Newbie
L

Joined: Oct 2009
Posts: 49
did I ask the question improperly? Basically I don't understand the vectors vAngularSpeed and vMove since they don't seem to have any values input to them before they're called in the while(1) statement.

Re: Confusion w/earthball camera movement [Re: Lecithin] #315488
03/16/10 00:13
03/16/10 00:13
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
They do not have to have values, because thoses are the vectors that are calculated by vec_accelerate.
Code:
vec_accelerate( VECTOR* distance,VECTOR* speed,VECTOR* accel,var friction);


The first two parameters are used as return values, thus you would use the distance vector for your c_move instruction.
The speed vector is an input and return value at the same time, because it is used for the next calculation iteration of the vec_accelerate and also modified by it. At the beginning of an acceleration the speed of an object is zero (in most cases). You could set it to something nonzero if your object is either already moving or if you want it that way (for whatever reasons).

the last two parameters (accel and friction) are just used for input and calculation.

Hope this clears it up a little bit.
By the way: This is all covered in the manual:
http://www.conitec.net/beta/avec_accelerate.htm

But I also admit that sometimes the manual is a litte bit confusing (and for beginners maybe even more).

Hope you are not mad at me now wink

edit:
The calculation is explained more detailed at the accelerate instruction (which is the same but just for one dimension):
http://www.conitec.net/beta/aaccelerate.htm

Last edited by Xarthor; 03/16/10 00:15.

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