本文整理汇总了Python中gamestate.GameState.frame方法的典型用法代码示例。如果您正苦于以下问题:Python GameState.frame方法的具体用法?Python GameState.frame怎么用?Python GameState.frame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gamestate.GameState
的用法示例。
在下文中一共展示了GameState.frame方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_Copy
# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import frame [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
示例2: test_Serialize_and_Deserialize
# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import frame [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
示例3: test_ReadAndWriteEvent_State_2
# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import frame [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)