Skip to content

Commit 21c0e64

Browse files
committed
Getting there
1 parent c3eecee commit 21c0e64

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

targetSprite.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ def setXy(self, x, y):
8787
print("aici")
8888
# print(_("debug-prefix"), _("new-sprite-position", x=x, y=y, name=self.name), file=sys.stderr)
8989
#rect = self.sprite.get_rect(topleft=(self.x - self.target.costumes[self.target.currentCostume].rotationCenterX, self.y - self.target.costumes[self.target.currentCostume].rotationCenterY))
90-
offset = pygame.Vector2(self.target.costumes[self.target.currentCostume].rotationCenterX, self.target.costumes[self.target.currentCostume].rotationCenterY)
90+
offset = pygame.Vector2(self.target.costumes[self.target.currentCostume].rotationCenterX - self.sprite.get_rect().width / 2, self.target.costumes[self.target.currentCostume].rotationCenterY - self.sprite.get_rect().height / 2)
9191
offset.rotate_ip(90 + self.direction)
9292
self.image = pygame.transform.rotozoom(self.sprite, 90 - self.direction, 1)
9393
# offset = pygame.Vector2(0, 0)
94-
self.rect.x = scratch.WIDTH // 2 + self.x + offset.x
95-
self.rect.y = scratch.HEIGHT // 2 - self.y + offset.y
94+
self.rect.centerx = scratch.WIDTH // 2 + self.x + offset.x
95+
self.rect.centery = scratch.HEIGHT // 2 - self.y + offset.y
9696
print(self.rect.x, self.rect.y, "/", self.x, self.y, "/", offset.x, offset.y)
9797
# TODO update current rotation centre to correct sprite position
9898

0 commit comments

Comments
 (0)