# triangle.py

# modified from code in Object-Oriented Python, by Irv Kalb

# a class representing a Pygame triangle with randomly chosen
# color, size and position. inherits from the Shape class

import pygame
from shape import *

class Triangle(Shape):
    def __init__(self, window, max_width, max_height):
        super().__init__(window, max_width, max_height)
        self.width = random.randrange(10, 100)
        self.height = random.randrange(10, 100)
        self.rect = pygame.Rect(self.x, self.y, self.width, self.height)

        
    def draw(self):
        pygame.draw.polygon(self.window, self.color, 
                            ((self.x, self.y + self.height),
                             (self.x, self.y),
                             (self.x + self.width, self.y)))