I am making a cat and mouse concept game inspired by a numberphile video I watched a couple years ago. My main goal is to be able to rotate a rectangle around a circle while always tangent.
the filled in rectangle should be facing towards the right
I believe I know how to make a rectangle rotate around a circle, it's just making it tangent to it all the time is the difficult part.
Here is some of the relevant code:
class Cat:
def __init__(self, surface:pygame.Surface, bound:Boundry) -> None:
self.surf = surface
self.boundry = bound
self.w, self.h = 20, 30
self.x = self.boundry.x + self.boundry.radius * + math.cos(0) - self.w // 2
self.y = self.boundry.y + self.boundry.radius * math.sin(0) - self.h
self.angle = math.atan2(self.x, self.y)
self.rect_surface = pygame.Surface((self.x, self.y))
self.rect = pygame.Rect((self.x, self.y), (self.w, self.h))
def draw(self):
pygame.draw.rect(self.surf, (255, 0, 0), self.rect)
Also github incase you want to contribute: https://github.com/cranberry0620/Cat-Mouse