Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
1 registered members (AndrewAMD), 599 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: visible traces [Re: Random] #391549
01/13/12 19:36
01/13/12 19:36
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline OP
User

Joined: Feb 2010
Posts: 886
Ok, I found out.
I hade this, direct under the trace function:

Quote:
c_scan(my.x, my.pan, vector(360, 60, 5000), IGNORE_ME | SCAN_ENTS | SCAN_LIMIT);
if (you)
{
if(you.entity_typ == 1)
{
my_goal = you;
vec_set(temp, my_goal.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
my.tilt = 0;

while (vec_dist (my.x, my_goal.x) > 50)
{
c_move(my, vector(5 * time_step, 0, 0), nullvector, IGNORE_PASSABLE | GLIDE);
wait (1);
}
}
}


After deleting the scan function, everything worked.



Re: visible traces [Re: Random] #391552
01/13/12 20:03
01/13/12 20:03
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline OP
User

Joined: Feb 2010
Posts: 886
Just a last question.

I notice, that you can`t use random cases while the trace(example):
Quote:

if(trace_hit)
{

var direction;
direction = integer(random(2));
if(direction == 0)
{
my.pan -= 5 * time_step;
}
if(direction == 1)
{
my.pan = 5 * time_step;
}
}


Does anybody has an idea how to make this passable?

PS: thanks for the tips, it helped me alot! wink



Re: visible traces [Re: Random] #391554
01/13/12 20:17
01/13/12 20:17
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline
User
Carlos3DGS  Offline
User

Joined: Oct 2008
Posts: 513
remember time_step is usally a small value, and the higher the framerate the smaller it is.
I have had issues with rotations in the past due to that problem.

just as an example...
lets say a certain data type (like your pan for example) only had 3 decimal positions, and its current value is 90.001
now imagine 5*time_step=0.0000001

so now you add 90.001 + 0.0000001 and you get the same 90.001
Why? Because the value is so small it is beyond the decimal precision your variable can hold, so anything smaller just gets ignored.

Think of it like trying to put 0.001 into an integer... This is kind of the same problem, only now what is being "ignored" are decimals smaller than what can fit in "var" (I think pan is var, not sure though)

An esy workaround would be to use a varaible with more precision to store the values:
Code:
float pan_container;
BOOL direction;

if(trace_hit)
{
     direction = integer(random(2));
     if(direction == 0)
     {
         pan_container -= 5 * time_step;
     }
     else
     {
         pan_container += 5 * time_step;
     }
     my.pan=pan_container;
}


If you want to learn more about each data type do a search in the manuall for variables. Or you can look in google or any programming book/website for:
BOOL
INTEGER (int)
FIXED (var)
FLOAT (float)
DOUBLE (double)

those are the main types you will be using.
if you stumble on things like half, word, longword, quadword... just ignore it, that is usually for ensamblador and other low processor instructions you will never use in any high level programming language like this.

Last edited by Carlos3DGS; 01/13/12 20:33.

"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1
Re: visible traces [Re: Carlos3DGS] #391558
01/13/12 20:32
01/13/12 20:32
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Code:
if(random(2)>1)
{   my.pan -= 5 * time_step;   }
else
{   my.pan += 5 * time_step;   }



ALSO :: notice in YOUR code for 'direction==1', you are not ADDING to pan, you are replacing it..



Last edited by EvilSOB; 01/13/12 20:40. Reason: remove a flawed example

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: visible traces [Re: Random] #391559
01/13/12 20:47
01/13/12 20:47
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Originally Posted By: Random
I notice, that you can`t use random cases while the trace

That's not right. Neither do traces affect the random number generator, nor the other way around. The piece of code you posted is almost correct. I guess you wanted to write "my.pan += 5 * time_step" in the second if statement.

Besides there is a much more elegant approach that saves you two if statements.

Code:
if (trace_hit)
  my->pan += (5 * time_step * sign(0.5 - integer(random(2)));




Always learn from history, to be sure you make the same mistakes again...
Re: visible traces [Re: EvilSOB] #391560
01/13/12 20:48
01/13/12 20:48
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline OP
User

Joined: Feb 2010
Posts: 886
I know what you mean, but if I try your first example "EvilSOB", I would have the same result as my code.
The same with "Carlos3DGS`s" and "Uhrwerk`s" example.
(Of course, thank you very much, you three)

I also tried to put it in a while loop:

Click to reveal..
if(trace_hit)
{
direction = integer(random(2));
if(direction == 0)
{
while(trace_hit){my.pan -= 5 * time_step;
wait(1);}
}
...


But of-course my object just stops moving because of the wait...

PS: I really like your approach "Uhrwerk" grin

Last edited by Random; 01/13/12 20:55.


Page 2 of 2 1 2

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