diff --git a/.idea/jorcademy-template.iml b/.idea/jorcademy-template.iml
index d0876a7..f89fc57 100644
--- a/.idea/jorcademy-template.iml
+++ b/.idea/jorcademy-template.iml
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index f0e7683..f7263c6 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/engine.py b/engine.py
index aaeba08..6836e2b 100644
--- a/engine.py
+++ b/engine.py
@@ -12,9 +12,15 @@
running = True
# Set app icon
-pygame_icon = pygame.image.load('assets/jorcademy.png')
+pygame_icon = pygame.image.load('assets/jc_icon.png')
pygame.display.set_icon(pygame_icon)
+
+def render_objects_on_screen():
+ for obj in jc.draw_buffer:
+ obj.draw(screen)
+
+
while running:
# poll for events
# pygame.QUIT event means the user clicked X to close your window
@@ -28,6 +34,7 @@
# Render game
game.draw()
+ render_objects_on_screen()
# flip() the display to put your work on screen
pygame.display.flip()
@@ -35,4 +42,4 @@
clock.tick(60) # limits FPS to 60
-pygame.quit()
\ No newline at end of file
+pygame.quit()
diff --git a/game.py b/game.py
index b177447..a3265b1 100644
--- a/game.py
+++ b/game.py
@@ -1,11 +1,16 @@
from jorcademy import *
+RED: color = (255, 0, 0)
+GREEN: color = (0, 255, 0)
+BLUE: color = (0, 0, 255)
+
def setup() -> None:
screen(800, 600)
- title("Best game ever")
backdrop(255, 255, 255)
def draw() -> None:
- pass
+ ellipse(RED, 400, 300, 100, 200)
+ rect(GREEN, 400, 300, 100, 100)
+ text("Hell yeah!", BLUE, 400, 100)
diff --git a/jorcademy.py b/jorcademy.py
index ea5bddd..ef42756 100644
--- a/jorcademy.py
+++ b/jorcademy.py
@@ -1,9 +1,15 @@
import pygame
+from primitives import *
+from typing import Tuple
# Game settings
screen_size = (100, 100)
screen_title = "JorCademy Engine"
background_color = (0, 0, 0)
+draw_buffer = []
+
+# Create type aliases
+color = Tuple[int, int, int]
# Change screen size
@@ -25,20 +31,25 @@ def backdrop(r: int, g: int, b: int):
# Draw a circle
-def circle():
- pass
+def ellipse(c: (int, int, int), x: float, y: float, w: float, h: float):
+ e = Ellipse(c, x, y, w, h)
+ draw_buffer.append(e)
# Draw a rectangle
-def rect():
- pass
+def rect(c: (int, int, int), x: float, y: float, w: float, h: float):
+ r = Rectangle(c, x, y, w, h)
+ draw_buffer.append(r)
+
+
+# Draw a string of text
+def text(content: str, c: (int, int, int), x: float, y: float):
+ font = pygame.font.Font(None, 48)
+ text_surface = font.render(content, True, c)
+ t = Text(content, text_surface, c, x, y, None, None)
+ draw_buffer.append(t)
+
-# Draw a triangle
-def triangle():
- pass
-# Draw a string of text
-def text():
- pass
diff --git a/primitives.py b/primitives.py
new file mode 100644
index 0000000..d05bbc8
--- /dev/null
+++ b/primitives.py
@@ -0,0 +1,65 @@
+import pygame
+
+
+class DrawableObject:
+ def __init__(self, x, y, w, h):
+ self.x = x
+ self.y = y
+ self.width = w
+ self.height = h
+ self.object_name = "Drawable"
+
+ def get_type(self):
+ return self.object_name
+
+ def draw(self, context: pygame.display):
+ pygame.draw.circle(context, self.x, self.y, 100)
+
+
+class Ellipse(DrawableObject):
+ def __init__(self, color, x, y, w, h):
+ super().__init__(x, y, w, h)
+ self.object_name = "Ellipse"
+ self.color = color
+
+ def draw(self, context: pygame.display):
+ center = (self.x, self.y)
+ circle_rect = pygame.Rect(center[0] - self.width / 2,
+ center[1] - self.height / 2,
+ self.width,
+ self.height)
+ pygame.draw.ellipse(context,
+ self.color,
+ circle_rect,
+ self.width)
+
+
+class Rectangle(DrawableObject):
+ def __init__(self, color, x, y, w, h):
+ super().__init__(x, y, w, h)
+ self.object_name = "Rectangle"
+ self.color = color
+
+ def draw(self, context: pygame.display):
+ center = (self.x, self.y)
+ rectangle_rect = pygame.Rect(center[0] - self.width / 2,
+ center[1] - self.height / 2,
+ self.width,
+ self.height)
+ pygame.draw.rect(context, self.color, rectangle_rect, self.width)
+
+
+class Text(DrawableObject):
+ def __init__(self, content, surface, color, x, y, w, h):
+ super().__init__(x, y, w, h)
+ self.object_name = "Tex"
+ self.color = color
+ self.contents = content
+ 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)
+