def setUp(self): self.world = entities.World() entities.GameEntity.world = self.world self.paddle = entities.Paddle( Vector2(0, FIELD_HEIGHT - entities.Paddle.HEIGHT)) self.heading = Vector2(0, 1) # Going downwards self.paddle.heading = self.heading
def test_paddle_instantiate_in_middle_of_field(self): """Instantiate the ball in the middle of the field""" x = (FIELD_WIDTH - entities.Paddle.WIDTH) / 2.0 y = (FIELD_HEIGHT - entities.Paddle.HEIGHT) / 2.0 paddle = entities.Paddle(Vector2(x, y)) self.assertEqual(paddle.location.x, x) self.assertEqual(paddle.location.y, y)
def setUp(self): self.world = entities.World() entities.GameEntity.world = self.world px = FIELD_WIDTH - entities.Paddle.WIDTH * 2 py = 0 self.right_paddle = entities.Paddle((px, py)) ball_dir = Vector2(1, 0) # Going straight right self.ball = entities.Ball( (px - entities.Ball.WIDTH, py)) # Place it before the paddle self.ball.heading = ball_dir
def setUp(self): self.world = entities.World() entities.GameEntity.world = self.world px = entities.Paddle.WIDTH py = 0 self.left_paddle = entities.Paddle((px, py)) ball_dir = Vector2(-1, 0) # Going straight left self.ball = entities.Ball( (px + entities.Paddle.WIDTH, py)) # Place it before the paddle self.ball.heading = ball_dir
def test_paddle_automatically_added_to_world(self): paddle = entities.Paddle() self.assertIn(paddle, self.world)
def test_paddle_create_no_location(self): paddle = entities.Paddle() self.assertEqual(paddle.location.x, 0) self.assertEqual(paddle.location.y, 0)
def setUp(self): self.world = entities.World() entities.GameEntity.world = self.world self.paddle = entities.Paddle(Vector2(0, 0)) self.heading = Vector2(0, -1) # Going upwards self.paddle.heading = self.heading
def setUp(self): entities.GameEntity.world = entities.World() self.paddle_pos = Vector2(100, 50) self.paddle = entities.Paddle(self.paddle_pos)
def setUp(self): self.px = 100 self.py = 50 self.paddle = entities.Paddle(location=Vector2(self.px, self.py))