Skip to content

Commit

Permalink
[FEATURE] Implemented text rotation.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickname2002 committed Jul 2, 2023
1 parent 1b278ce commit 7c7ebda
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
9 changes: 2 additions & 7 deletions game.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
from jorcademy import *

angle = 0


def setup() -> None:
screen(800, 600)
pass


def draw() -> None:
global angle
#text((128, 0, 128), 600, 300, 200, 100, angle)
ellipse((255, 255, 255), 400, 300, 1, 1)
angle += 1
pass
11 changes: 7 additions & 4 deletions primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,13 @@ def __init__(self, content, surface, color, x, y, w, h, rotation=0):
self.surface = surface

def draw(self, context: pygame.display):
# Set the position of the text
text_position = self.surface.get_rect()
text_position.center = (self.x, self.y) # Centered on the screen
context.blit(self.surface, text_position)
# Rotate surface
self.surface = pygame.transform.rotate(self.surface, self.rotation)
rect = self.surface.get_rect()
rect.center = (self.x, self.y)

# Draw surface
context.blit(self.surface, rect)


# Derived class - representing an image object
Expand Down

0 comments on commit 7c7ebda

Please sign in to comment.