def coli_block(self): global score coli = [] l, r, a, b = self.block_size, SIZE_B, self.ball.ball_pos[ 0] + SIZE_B, self.ball.ball_pos[1] + SIZE_B for x in range(0, self.num[0]): for y in range(0, self.num[1]): if self.blocks[x][y]: if pygame.sprite.collide_rect(self.ball, self.blocks[x][y]): coli.append((x, y)) if len(coli) == 0: pass #elif len(coli)==1: else: for x, y in coli: self.block_g.remove(self.blocks[x][y]) self.blocks[x][y] = None p1, p2 = coli[0][0], coli[0][1] x, y = self.block_pos[p1][p2] if (calc.rect(l, r, x, y - r, a, b)) or (calc.rect( l, r, x, y + l, a, b)): self.ball.ball_angle = 360 - self.ball.ball_angle #상하 elif (calc.rect(r, l, x - r, y, a, b)) or (calc.rect( r, l, x + l, y, a, b)): self.ball.ball_angle = 180 - self.ball.ball_angle #좌우 elif (calc.circle(r, x, y, a, b)) * (calc.square( r, x - r, y - r, a, b)): self.ball.ball_angle = 225 #좌상단 elif (calc.circle(r, x + l, y, a, b)) * (calc.square( r, x + l, y - r, a, b)): self.ball.ball_angle = 315 #우상단 elif (calc.circle(r, x, y + l, a, b)) * (calc.square( r, x - r, y + l, a, b)): self.ball.ball_angle = 135 #좌하단 elif (calc.circle(r, x + l, y + l, a, b)) * (calc.square( r, x + l, y + l, a, b)): self.ball.ball_angle = 45 #우하단 else: self.ball.ball_angle = 90 ''' else: for x,y in coli: self.block_g.remove(self.blocks[x][y]) self.blocks[x][y]=None self.ball.ball_angle=90 ''' score += len(coli) self.num_b -= len(coli)
def test_calcSquare(a, b, c, answer): assert square(a, b, c) == answer
def test_square(self): result = square(5) self.assertEqual(result, 25)
def test_square(self): self.assertEqual(calc.square(2), 4) self.assertEqual(calc.square(9), 81) '''with self.assertRaises(ValueError):
def test_calc_square(test_input, expected_output): result = calc.square(test_input) assert result == expected_output
def squ(): s = square(7) return s
import calc calc.square(10) x = calc.cube(10) print(x)
def test_square(test_input, test_output): result = calc.square(test_input) assert result == test_output