import pygame 
import os 

SCREEN = (640,480)
display = pygame.display.set_mode(SCREEN)

# DD. GAME_OBJECT
# gameObject = GameObject()
# interp. a game object in the editor with:
# - position x and y in the screen, where coordinate is the center of the object
# - image loaded in pygame
# - object_type: agent, wall, enemy, food
class GameObject():
    def __init__(self,position, angle, object_type, img_path,scale_factor):
        self.placed = False #stops following cursor once it's placed
        self.object_type = object_type
        self.image_path = img_path
        self.image = pygame.image.load(img_path)
        self.rect = self.image.get_rect()
        self.rect.center = position
        self.angle = angle
        self.scale_factor =scale_factor 
        self.turnClockwise()
        self.scale()

        
    def draw(self, display):
        display.blit(self.image, self.rect)
        
    def turnClockwise(self, degrees=0):
        # Preserve the current center position of the rectangle
        self.angle = (self.angle + degrees)%360
        previous_center = tuple(self.rect.center)
        # Rotate the image
        self.image = pygame.transform.rotate(self.image, -degrees)  # Use -self.angle for clockwise rotation
        self.rect = self.image.get_rect(center=previous_center)  # Reassign the rect with the updated center
    
    def scale(self):
        w,h = self.image.get_size()
        previous_center = tuple(self.rect.center)
        new_size = (int(w * (self.scale_factor)), int(h * (self.scale_factor)))
        self.image = pygame.transform.scale(self.image, new_size)
        self.rect = self.image.get_rect(center=previous_center)  # Reassign the rect with the updated center


# DD. GAME_MANAGER
# game = GameManager()
# interp. main container for our game in pygame
class GameManager():
    def __init__(self):
        self.reset()
        
    def reset(self):
        self.score = 0
<<embed_game_objects>>


gameManager = GameManager()
############### CODE ###################



def draw():
    display.fill("#1e1e1e")
    for logo in gameManager.all_game_objects:
        for go in logo:
            go.draw(display)
    pygame.display.flip()

def update():
    [pygame.quit() for event in pygame.event.get() if event.type == pygame.QUIT]

while True:
    draw()
    update()