Gamestudio Links
Zorro Links
Newest Posts
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
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,498 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
"remember" a variable #301137
12/08/09 15:53
12/08/09 15:53
Joined: Jul 2008
Posts: 128
Ukraine
BastovBros Offline OP
Member
BastovBros  Offline OP
Member

Joined: Jul 2008
Posts: 128
Ukraine
Hi again, I never did such thing before, so I am not sure hiw this should work. The problem is, I want to "remember" the angle at a cirtain instance, so that I can use this value which was "memorized" as a parameter further. For example, some object is constantly spinning, I want to remember its angle when it has turned by 90 degrees only, and use it as a fixed parameter, though it still continues to spin. I cannot use loop because then the angle would be checked all the time, not only the one which is 90 degrees. Hope you understood my problem.
Thanks in advance


a generator of dull questions smile
Re: "remember" a variable [Re: BastovBros] #301150
12/08/09 16:20
12/08/09 16:20
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
I don't understand fully, but what you are asking should be easily achievable by doing some comparisons using 'if'/'else'.

Care to explain further, maybe with some code.

Re: "remember" a variable [Re: DJBMASTER] #301154
12/08/09 16:36
12/08/09 16:36
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
or use something like pan - pan % 90.

Re: "remember" a variable [Re: DJBMASTER] #301159
12/08/09 16:44
12/08/09 16:44
Joined: Jul 2008
Posts: 128
Ukraine
BastovBros Offline OP
Member
BastovBros  Offline OP
Member

Joined: Jul 2008
Posts: 128
Ukraine
OK, I am trying to create a catapult movement without physics. I have one object which rotates freely. the second object is inside the first object and has the same angle. vec_set(object2,object1); vec_set (object2.pan, object1.pan);. Then when the first object has the angle say vector(0,10,20). And if I press a button, the second object should catapult from the first one and I want to use this angle (vector(0,10,20)) to calculate its movement. However, I also need to ignore now vec_set(object2.pan,object1.pan), because I need only that angle, which I "memorized" (vector(0,10,20( to find the trajectory of movement, no matter how the object1 is rotated now. So my question is how to memorize an angle at the instant when the button was pressed to use it further?
Another example: a ball is constantly rotating by 1 degree: 0+1=1, 1+1=2, 2+1 =3. For example I want to "memorize"this angle 3, so that I can make a variable velocity = 3; and then use c_move(me, vector(velocity,0,0),nullvector, GLIDE);. And I cannot just set velocity = ball.pan, because the ball continues to rotate 3+1=4, 4+1=5, which would constantly change the velocity value.
Sorry, if I am bad in explanations laugh


a generator of dull questions smile
Re: "remember" a variable [Re: Joey] #301160
12/08/09 16:54
12/08/09 16:54
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
So, you want to have an object spin in place, but you want to keep track of the pan value it had on startup?

The easiest way to do this is to store the entity's original pan value in a skill so you can use it in other functions and stuff, like this:

Code:
ENTITY* spinning_ent;

action spinning_action()
{
  spinning_ent = my; // I am the spinning entity
  my.skill1 = my.pan; // store my original pan in SKILL1

  while(my) // while I exist
  {
    my.pan += time; // increase my pan value

    wait(1);
  }
}

action comparing_action()
{
  while(my) // while I exist
  {
    if( spinning_ent != null ) // validity check
    {
      my.pan = spinning_ent.skill1; // always set me to look in the direction you were originally set to
    }

    wait(1);
  }
}



Note that I only use an entity pointer for the spinning object to make the comparisons between the two actions valid in this example. If you are finding the pointer referencing the spinning object some other way, you don't need to use an entity pointer like "spinning_ent".


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: "remember" a variable [Re: Redeemer] #301358
12/09/09 21:43
12/09/09 21:43
Joined: Jul 2008
Posts: 128
Ukraine
BastovBros Offline OP
Member
BastovBros  Offline OP
Member

Joined: Jul 2008
Posts: 128
Ukraine
OK, never mind about this question. I have another one, this one more clear I hope: I have a cube entity, which can rotate. It has a vector which is directed along its local z axis. Now I roll the cube by 45 degrees. The vector is now 45 degrees from the absolute z axis, so the absolute z axis can be discribed as vector*cos(45). How to dexcribe the absolute x, y and z axes if the cube is rotated in 3 dimensions. And another question is how to make the cube then move along this vector?


a generator of dull questions smile
Re: "remember" a variable [Re: BastovBros] #301363
12/09/09 22:27
12/09/09 22:27
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
If you take a look at the function 'c_move' you will see it has 2 vector parameters - 'reldist' and 'absdist'.

'reldist' is used to move using entity coordinates (local), and so the local axis change depending upon the entity rotation.

'absdist' is used to move using world coordiantes (global). No matter how your entity is rotated, it will move in the absolute world axis.

Going through the lite-c workshop will help you to solve these problems.

Last edited by DJBMASTER; 12/09/09 22:32.

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