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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Akow, degenerate_762), 1,430 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 5 of 5 1 2 3 4 5
Re: [Anet] physics movement setup [Re: Dark_samurai] #338639
08/19/10 21:08
08/19/10 21:08
Joined: Jul 2010
Posts: 12
Germany
Z
Zwiebli Offline
Newbie
Zwiebli  Offline
Newbie
Z

Joined: Jul 2010
Posts: 12
Germany
Hi,
I have a question concerning the saving of the keys in bits of a skill. It worked till I wanted to read the 7th bit. The var check3 showed 0. This is how I wrote it:

my.skill1 = 0;
my.skill1 |= 1;
my.skill1 |= 1<<1;
my.skill1 |= 1<<2;
my.skill1 |= 1<<3;
my.skill1 |= 1<<4;
my.skill1 |= 1<<5;
my.skill1 |= 1<<6;
my.skill1 |= 1<<7;
check2 = (my.skill1&0x00000001);
check2 = (my.skill1&0x00000002)>>1;
check2 = (my.skill1&0x00000004)>>2;
check2 = (my.skill1&0x00000008)>>3;
check2 = (my.skill1&0x000000016)>>4;
check2 = (my.skill1&0x000000032)>>5;
check2 = (my.skill1&0x000000064)>>6;
check3 = (my.skill1&0x0000000128)>>7;
Thanks for any help

Re: [Anet] physics movement setup [Re: Zwiebli] #338703
08/20/10 18:24
08/20/10 18:24
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
You are mixing hexadecimal with decimal.

Hex:
0x01
0x02
...
0x09
0x0A
...
0x0F
0x10

So you could write it this way (decimal):
(my.skill1 & 1)
(my.skill1 & 2) >> 1
...
(my.skill1 & 128) >> 7

Last edited by Dark_samurai; 08/20/10 18:25.

ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: [Anet] physics movement setup [Re: Dark_samurai] #338709
08/20/10 19:19
08/20/10 19:19
Joined: Jul 2010
Posts: 12
Germany
Z
Zwiebli Offline
Newbie
Zwiebli  Offline
Newbie
Z

Joined: Jul 2010
Posts: 12
Germany
Is there a site where this is explained? I just pasted it from your Anet-manuel in the tipps & tricks section and thought it works analog till the 32nd bit. I didn`t even understand what the "0x000..." actually stands for.
thanks for the help

Re: [Anet] physics movement setup [Re: Zwiebli] #338745
08/21/10 08:34
08/21/10 08:34
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Hexadecimal is explained here: http://en.wikipedia.org/wiki/Hexadecimal

Maybe this helps you understand how using flags (= using single bits of a variable) works: http://www.rohitab.com/discuss/index.php?showtopic=25162


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: [Anet] physics movement setup [Re: Dark_samurai] #359433
02/17/11 18:09
02/17/11 18:09
Joined: Jul 2010
Posts: 12
Germany
Z
Zwiebli Offline
Newbie
Zwiebli  Offline
Newbie
Z

Joined: Jul 2010
Posts: 12
Germany
Hm sorry could you show me an example how to write/read the last bit of a skill? I still quite understand how it works...
thanks a lot

Re: [Anet] physics movement setup [Re: Zwiebli] #359437
02/17/11 18:29
02/17/11 18:29
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
A skill is a var (= float). Which means it consists of 4 byte. Each byte has 8 bit.

--> 4 Byte = 32 bit

If you want to set the last bit of a skill you have to do a OR operation with
1000 0000 0000 0000 0000 0000 0000 0000 (binary!).
--> As you see the 32. bit is 1
Because we can't write binary numbers in lite-c, we have to calculate the according hex or decimal number:
0x80000000 (hex)
2147483648 (Dec)

my.skill[1] = my.skill[1] | 0x80000000; //sets the 32. bit

For clearing a bit, you have to make an AND operation with 0111 1111 1111 1111 1111 1111 1111 1111 (binary) = 0x7FFFFFFF (hex)

my.skill[1] = my.skill[1] & 0x7FFFFFFF; //resets the 32. bit


This may sound complicated but if you look into binary operations (AND/OR) and how binary numbers and hexadecimal works it is pretty easy wink


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: [Anet] physics movement setup [Re: Dark_samurai] #359452
02/17/11 19:34
02/17/11 19:34
Joined: Jul 2010
Posts: 12
Germany
Z
Zwiebli Offline
Newbie
Zwiebli  Offline
Newbie
Z

Joined: Jul 2010
Posts: 12
Germany
but if i set the last bit of skill1 shouldn`t it have the value 2147483648 afterwards if i set skill1 to zero before? Because only the value zero is displayed instead of 2147483648.

But thanks for the explanation it helped a lot laugh
If i want to read out the value of the last bit should it look something like this? :

right_key = (my.skill1 & 0x80000000)>>31

and thanks for the quick answer

Last edited by Zwiebli; 02/17/11 20:06.
Re: [Anet] physics movement setup [Re: Zwiebli] #359517
02/18/11 08:36
02/18/11 08:36
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Exactly!

The problem is, that skills are floats => 10000...(binary) != 2147483648

If you will do this with an int instead of a float, you will see that it is 2147483648 after the OR operation.


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Page 5 of 5 1 2 3 4 5

Moderated by  HeelX, Spirit 

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