[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] bit operations
- To: pygame-users@xxxxxxxx
- Subject: [pygame] bit operations
- From: inigo delgado <inigo.delgado@xxxxxxxxx>
- Date: Mon, 4 Oct 2010 12:18:30 +0200
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Mon, 04 Oct 2010 06:18:48 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=dREsvKC22XuLi4zwfY2n6rHkvtWUM+5DdbIdarl6u6E=; b=t7cFTfDtSc12ZmMSkS4MK5srwPBweM29H8Lin1aa2j6B80dUS8CfD9Uw7YxgI1VcLv Rj16145/s1t9EBFPS6vLzzdBRFlIERHO/cgCswXb7fJwLdF7wwXj47p7ToFmRGTNL46G gHP5/pNZUf6kTsIMts+vCkPLzskeiyTptV1s8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=HMqSQ3OeX5lNCEwLG/jBTBF3FydIDofQmMXyO9IU31jvmVx6WKBKiRM6eTrYNSeqGo mmUKTGQMSbZB2PVRu5LyBeZfzaORQCSL1OGVEdrvEX4Hz0ugurFKXMXLwfUV95GR8wqu wZE3ELTRmlyAK1oSK2GsNavgaE/PuJznOfrTA=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Hi:
This is more a python question... And may be stupid... but i cannot see it... please help.
I want to make my game playable online. So I have to send all the info to the client and then he will draw corresponding frames in corresponding positions in the screen...
So I want to send a list of integers to the client [(x, y) coords, image(ship/explosion...) index, frame index (they are many frames for each ship/explosion...).... )]
So I decided to 'pack' them in order to send less bytes in a array (x,y never should be > 2048, so I can send this coords in 22 bits -3 bytes instead of 4-) doing something like this code that I've done to test :
t = 0.0 + (1 << 48) + (2 << 40) + (3 << 32) + (4 << 24) + (5 <<16) + (6 << 8) + 7 # So I have all the info in one number
print "t is " + `t`
j = (t >> 48)
print j
And I've this output:
t is 283686952306183.0
j = (t >> 48)
TypeError: unsupported operand type(s) for >>: 'float' and 'int'
why this error? :(