kevindekever
Member
|
Understanding this Line from RTS
File: Unit
float unique=RandomF();
atlas->add(_pos, scale, move_path.elms() ? atlas_move[Trunc(Time.time()*5+unique)&1] : attacking ? atlas_attack[Time.time()-last_action_time>=AttackDuration*0.5] : 0, mirror);
This is the important line for changing Images/Sprites. But don't understanding the red part.
|
|
10-10-2016 07:01 AM |
|
Zervox
Member
|
RE: Understanding this Line from RTS
Although there are other ways of doing it than is done there.
Have you tried logging the results to see the difference, that alone could tell plenty,
Code:
time = Time.time()
result = time*5+unique
LogN(S+(time*5+unique) + " : "+Trunc(time*5+unique)+ " : "+(Trunc(time*5+unique)&1));
(This post was last modified: 10-10-2016 08:31 AM by Zervox.)
|
|
10-10-2016 08:30 AM |
|
kevindekever
Member
|
RE: Understanding this Line from RTS
thanks for reply
i understand it generates 0 or 1
but why "*5" and "+unique"
trying to raise "2 Sprites" to "10 Sprites" for 1 Animation.
so replaced the "&1" with "&9" but this doesnt work....my new Zombie Unit flickers
it seems, that i have to write a new animation class
(This post was last modified: 10-10-2016 09:12 AM by kevindekever.)
|
|
10-10-2016 09:10 AM |
|
Esenthel
Administrator
|
RE: Understanding this Line from RTS
*5 is animation speed
unique is a unique value for every unit, this is to avoid all units on the screen animating the same frame in the same time
|
|
10-10-2016 09:17 AM |
|
kevindekever
Member
|
RE: Understanding this Line from RTS
ahh thank you
i will use modulo and this helped me
Trunc(Time.time()*5+unique)%10
i dont know what "&1" do but until "&7" works fine but "&9" gaves me strange behavior (flicker)
so mod is the better way for me
(This post was last modified: 10-10-2016 10:16 AM by kevindekever.)
|
|
10-10-2016 09:22 AM |
|
Esenthel
Administrator
|
RE: Understanding this Line from RTS
&1 is %2
&7 is %8
you can use & only for power of 2's
|
|
10-10-2016 11:49 PM |
|
kevindekever
Member
|
RE: Understanding this Line from RTS
Never used bitwise AND before in projects. Thanks for your explanation.
My Zombies are under control
(This post was last modified: 10-11-2016 07:45 AM by kevindekever.)
|
|
10-11-2016 07:45 AM |
|