本文整理汇总了Python中gamestate.GameState.keybits方法的典型用法代码示例。如果您正苦于以下问题:Python GameState.keybits方法的具体用法?Python GameState.keybits怎么用?Python GameState.keybits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gamestate.GameState
的用法示例。
在下文中一共展示了GameState.keybits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_Serialize_and_Deserialize
# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import keybits [as 别名]
def test_Serialize_and_Deserialize(self):
s = GameState()
s.ball.pos_x = 100
s.ball.pos_y = -50
s.ball.vel_x = -43
s.ball.vel_y = 6
s.paddle_left.pos_y = 90
s.paddle_left.vel_y = 4
s.paddle_right.pos_y = 2
s.paddle_right.vel_y = 87
s.key_flags = 3
s.frame = 112734590
s.keybits = 1 << 63
# Ignore the EventType header.
b = s.Serialize()[4:]
t = GameState()
t.Deserialize(b)
self.assertTrue(t.ball.pos_x == s.ball.pos_x)
self.assertTrue(t.ball.pos_y == s.ball.pos_y)
self.assertTrue(t.ball.vel_x == s.ball.vel_x)
self.assertTrue(t.ball.vel_y == s.ball.vel_y)
self.assertTrue(t.paddle_left.pos_y == s.paddle_left.pos_y)
self.assertTrue(t.paddle_left.vel_y == s.paddle_left.vel_y)
self.assertTrue(t.paddle_right.pos_y == s.paddle_right.pos_y)
self.assertTrue(t.paddle_right.vel_y == s.paddle_right.vel_y)
self.assertTrue(t.key_flags == s.key_flags)
self.assertTrue(t.frame == s.frame)
pass