def make_rect_at_center(x, y, w, h, rot=0): #pylint:disable-msg=C0103 """ Makes a collision rectangle. x, y specify the center of the rectangle. """ return Shapes.Rectangle(x, y, w, h, rot)
def make_rect_at_bottom_left(x, y, w, h, rot=0): #pylint:disable-msg=C0103 """ Makes a collision rectangle. x, y specify the bottom left corner of the rectangle. """ return Shapes.Rectangle(x + w / 2.0, y + w / 2.0, w, h, rot)
def main(): global objArr, isRunning, projection, camera createWindow() projection = glGetFloatv(GL_PROJECTION_MATRIX) # MATRICES VALUES.... camera = CameraManagement.Camera(projection) # Creates objects at origin 0,0,0 cube = Shapes.Cube(5) rectangle = Shapes.Rectangle(5, 5, 4, -5, 1, -2) pyramid = Shapes.Pyramid(-3, -4, 1) objArr = {cube, rectangle, pyramid} isRunning = True while isRunning: projection = glGetFloatv(GL_PROJECTION_MATRIX) #print (projection) glLoadIdentity try: glLoadMatrixf(camera.getMapped()) except: """""" getKeys() glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) for i in objArr: i.update() i.updateColor() #UPDATES DIMENSIONS OF EACH OBJECT pygame.display.flip() pygame.time.wait(50)
def mousePressEvent(self, event): #randomly choose a shape to draw shapenum = randint(0, 4) if shapenum == 0: #information to draw Rectangle rect = Shapes.Rectangle(event.x(), event.y()) self.__shapes.append(rect) elif shapenum == 1: #information to draw Squares square = Shapes.Squares(event.x(), event.y()) self.__shapes.append(square) elif shapenum == 2: #information to draw Ellipse elpse = Shapes.Ellipses(event.x(), event.y()) self.__shapes.append(elpse) elif shapenum == 3: #information to draw Circle circle = Shapes.Circles(event.x(), event.y()) self.__shapes.append(circle) elif shapenum == 4: #information to draw Triangle tri = Shapes.Triangles(event.x(), event.y()) self.__shapes.append(tri) self.update()
def test_RectangleArea(): rect1 = shp.Rectangle() rect1.width = 4 rect1.height = 2 expected = (rect1.height * rect1.width) desc = "Returns area of a rectangle from length and height." actual = rect1.area print_test_results(blank, desc, expected, actual) print str(rect1)
def test_shapes_r(): shape_rectangle_test = Shapes.Rectangle() shape_rectangle_test.height = 2.0 shape_rectangle_test.width = 4.0 desc = "" expected = 8.0 actual = shape_rectangle_test.area() print_test_results(test_shapes_r, desc, expected, actual) print str(shape_rectangle_test)
def test_find_rectangle_area(): '''Test length 2, width 4''' expected = 8 rectangle = sha.Rectangle() rectangle.length = 2 rectangle.width = 4 actual = rectangle.area print_test_results(test_find_rectangle_area, expected, actual) print str(rectangle)
def test_rectangle_area(): desc = 'Returns the the area of a retangle if we know its height and width' rectangle = Shapes.Rectangle() height = 2 width = 4 rectangle.width = width rectangle.height = height area = height * width expected = area actual = rectangle.area print_test_results(Shapes.Rectangle, desc, expected, actual) print str(rectangle) + '\n'
def test_rectangle_area(): desc = "Return area of a rectangle when given a width and height" test_rectangle = Shapes.Rectangle() test_rectangle.width = 4 test_rectangle.height = 2 rectangle_area = test_rectangle.area expected = 8 actual = rectangle_area print_test_results(test_rectangle_area, desc, expected, actual) print str(test_rectangle)