diff --git a/.idea/jorcademy_python_template.iml b/.idea/jorcademy_python_template.iml
new file mode 100644
index 0000000..9d102e2
--- /dev/null
+++ b/.idea/jorcademy_python_template.iml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 21e0a8a..a971a2c 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/__pycache__/game.cpython-311.pyc b/__pycache__/game.cpython-311.pyc
index 109f5cd..75bc68c 100644
Binary files a/__pycache__/game.cpython-311.pyc and b/__pycache__/game.cpython-311.pyc differ
diff --git a/__pycache__/jorcademy.cpython-311.pyc b/__pycache__/jorcademy.cpython-311.pyc
index b694a8a..8eb7ee6 100644
Binary files a/__pycache__/jorcademy.cpython-311.pyc and b/__pycache__/jorcademy.cpython-311.pyc differ
diff --git a/__pycache__/primitives.cpython-311.pyc b/__pycache__/primitives.cpython-311.pyc
index d921550..d24d963 100644
Binary files a/__pycache__/primitives.cpython-311.pyc and b/__pycache__/primitives.cpython-311.pyc differ
diff --git a/assets/fonts/pixel.ttf b/assets/fonts/pixel.ttf
new file mode 100644
index 0000000..dcca687
Binary files /dev/null and b/assets/fonts/pixel.ttf differ
diff --git a/game.py b/game.py
index 25c5ef4..dfd7ce8 100644
--- a/game.py
+++ b/game.py
@@ -6,4 +6,4 @@ def setup() -> None:
def update() -> None:
- pass
+ pass
\ No newline at end of file
diff --git a/jorcademy.py b/jorcademy.py
index da1d1d1..5c6f155 100644
--- a/jorcademy.py
+++ b/jorcademy.py
@@ -81,10 +81,16 @@ def rect(c: color, x: float, y: float, w: float, h: float, rotation=0) -> None:
# Draw a string of text
-def text(content: str, c: color, x: float, y: float, rotation=0) -> None:
- font = pygame.font.Font(None, 48)
+def text(content: str, size: int, c: color, x: float, y: float, font="Nunito") -> None:
+ # Fetch font
+ try:
+ font = pygame.font.Font("./assets/" + font, size)
+ except:
+ font = pygame.font.SysFont(font, size)
+
+ # Draw font
text_surface = font.render(content, True, c)
- t = Text(content, text_surface, c, x, y, None, None, rotation)
+ t = Text(content, text_surface, c, x, y, None, None, size, font)
draw_buffer.append(t)
diff --git a/primitives.py b/primitives.py
index 152e898..c21e7a0 100644
--- a/primitives.py
+++ b/primitives.py
@@ -72,21 +72,20 @@ def draw(self, context: pygame.display):
# Derived class - representing a text object
class Text(DrawableObject):
- def __init__(self, content, surface, color, x, y, w, h, rotation=0):
- super().__init__(x, y, w, h, rotation)
+ def __init__(self, content, surface, color, x, y, w, h, size, font):
+ super().__init__(x, y, w, h)
self.object_name = "Text"
self.color = color
self.contents = content
self.surface = surface
+ self.size = size
+ self.font = font
def draw(self, context: pygame.display):
- # 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)
+ # 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)
# Derived class - representing an image object