Hello,
I’m creating a simple breakout (Brick Breaker) game for a school project and I’m trying to use the CMUcam5 to track an object and move the game paddle accordingly to the relative position of the object. As of right now, I have the paddle moving either left or right, if the object appears to be either left or right to the center of the camera. But I’m trying to improve the tracking and have the paddle move simultaneously to the relative position of the object. My code for the movement of the paddle is below:
def paddleUpdate(self):
count = pixy_get_blocks(100, blocks)
if count > 0:
for index in range (0, count):
if blocks[index].x<150:
if self.paddle[-1][0].x < 790:
for paddle in self.paddle:
paddle[0].x += 10
elif blocks[index].x>150:
if self.paddle[0][0].x > 0:
for paddle in self.paddle:
paddle[0].x -= 10