Question: python hello world shapes import pygame import sys from pygame.locals import * # Set up pygame. pygame.init ( ) # Set up the window. windowSurface

python hello world shapes
import pygame
import sys
from pygame.locals import *
# Set up pygame.
pygame.init()
# Set up the window.
windowSurface = pygame.display.set_mode((500,400),0,32)
pygame.display.set_caption('Hello world!')
# Set up the colors.
BLACK =(0,0,0)
WHITE =(255,255,255)
RED =(255,0,0)
GREEN =(0,255,0)
BLUE =(0,0,255)
# Set up the fonts.
basicFont = pygame.font.SysFont(None,48)
# Set up the text.
text = basicFont.render('Hello world!', True, WHITE, BLUE)
textRect = text.get_rect()
textRect.centerx = windowSurface.get_rect().centerx
textRect.centery = windowSurface.get_rect().centery
# Draw the white background onto the surface.
windowSurface.fill(BLUE)
# Draw a green polygon onto the surface.
pygame.draw.triangle(windowSurface, BLUE, ((146,0),(291,106),(236,277),(56,277),(0,106)))
# Draw some blue lines onto the surface.
pygame.draw.line(windowSurface, RED, (60,60),(120,60),4)
pygame.draw.line(windowSurface, GREEN, (120,60),(60,120))
pygame.draw.line(windowSurface, BLACK, (60,120),(120,120),4)
# Draw a blue circle onto the surface.
pygame.draw.circle(windowSurface, GREEN, (300,50),20,0)
# Draw a red ellipse onto the surface.
pygame.draw.ellipse(windowSurface, BLACK, (300,250,40,80),1)
# Draw the text's background rectangle onto the surface.
pygame.draw.rect(windowSurface, GREEN, (textRect.left -20,
textRect.top -20, textRect.width +40, textRect.height +40))
# Get a pixel array of the surface.
pixArray = pygame.PixelArray(windowSurface)
pixArray[480][380]= BLUE
del pixArray
# Draw the text onto the surface.
windowSurface.blit(text, textRect)
# Draw the window onto the screen.
pygame.display.update()
# Run the game loop.
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
change so that line 36 is polygon attribute

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!