当前位置: 首页>>代码示例>>Python>>正文


Python GameState.key_flags方法代码示例

本文整理汇总了Python中gamestate.GameState.key_flags方法的典型用法代码示例。如果您正苦于以下问题:Python GameState.key_flags方法的具体用法?Python GameState.key_flags怎么用?Python GameState.key_flags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gamestate.GameState的用法示例。


在下文中一共展示了GameState.key_flags方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_Copy

# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import key_flags [as 别名]
 def test_Copy(self):
     s = GameState()
     u = GameState()
     u.ball.pos_x = 100
     u.ball.pos_y = 200
     u.ball.vel_x = 300
     u.ball.vel_y = 400
     u.paddle_left.pos_y = -100
     u.paddle_left.vel_y = -200
     u.paddle_right.pos_y = -300
     u.paddle_right.vel_y = -400
     u.frame = 30
     u.key_flags = 300
     u.Copy(s)
     self.assertTrue(s.ball.pos_x == u.ball.pos_x)
     self.assertTrue(s.ball.pos_y == u.ball.pos_y)
     self.assertTrue(s.ball.vel_x == u.ball.vel_x)
     self.assertTrue(s.ball.vel_y == u.ball.vel_y)
     self.assertTrue(s.paddle_left.pos_y == u.paddle_left.pos_y)
     self.assertTrue(s.paddle_left.vel_y == u.paddle_left.vel_y)
     self.assertTrue(s.paddle_right.vel_y == u.paddle_right.vel_y)
     self.assertTrue(s.paddle_right.pos_y == u.paddle_right.pos_y)
     self.assertTrue(s.frame == u.frame)
     self.assertTrue(s.key_flags == u.key_flags)
     pass
开发者ID:ryutaroikeda,项目名称:triplepong,代码行数:27,代码来源:gamestate_test.py

示例2: test_Serialize_and_Deserialize

# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import key_flags [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
开发者ID:ryutaroikeda,项目名称:triplepong,代码行数:30,代码来源:gamestate_test.py

示例3: test_PlayFrame

# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import key_flags [as 别名]
 def test_PlayFrame(self):
     '''Test frame count and key_flags in PlayFrame.
     '''
     e = UDPGameEngine()
     s = GameState()
     frame = s.frame
     s.key_flags = GameEvent.EVENT_FLAP_LEFT_PADDLE
     e.PlayFrame(s, s.key_flags, e.bitrec)
     self.assertTrue(s.frame == frame + 1)
开发者ID:ryutaroikeda,项目名称:triplepong,代码行数:11,代码来源:udpgameengine_test.py

示例4: test_ReadAndWriteEvent_State_2

# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import key_flags [as 别名]
 def test_ReadAndWriteEvent_State_2(self):
     evt = GameState()
     evt.frame = 100
     evt.ball.pos_x = 3
     evt.ball.pos_y = 6
     evt.paddle_left.pos_y = 5
     evt.paddle_left.vel_y = -9
     evt.paddle_right.pos_y = -19
     evt.paddle_right.vel_y = 54
     evt.key_flags = 4
     self.template_ReadAndWriteEvent(evt)
开发者ID:ryutaroikeda,项目名称:triplepong,代码行数:13,代码来源:udpeventsocket_test.py


注:本文中的gamestate.GameState.key_flags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。