Drawing Challenges in Python
Drawing Challenges in Python
Drawing Challenges in Python
Completed? (add a
note if you wish)
Completed
Completed
Completed
Completed
Completed
Can you draw rectangles of different sizes in different locations with different border
thicknesses?
***dont forget to indent*** Can you draw a triangle using:
Completed
Completed
Can you draw a variety of polygons around the screen, adapting the code above?
Can you use the code below to add text to your screen? ***Dont forget to indent in line
with the other text!****
Completed
Completed
Can you add some of your own text at different locations around the screen?
Can you use the loop below to draw repeated images?
Completed
Completed
Can you edit the loop youve just added to draw the lines in different locations on the screen?
Can you edit the loop to draw lines spaced out differently?
Can you edit the loop to draw rectangles or other shapes?
Further drawing challenges:
You may wish to explore more commands from:
http://www.pygame.org/docs/ref/draw.html
or
http://programarcadegames.com/index.php?chapter=introduction_to_graphics&lang=en#se
ction_5 (scroll down quite a bit!)
Further reading:
http://pygame.org/
http://programarcadegames.com/
Completed
Completed
Completed
Completed
"""
Exploring graphics
Sample Python/Pygame Programs
Simpson College Computer Science
http://programarcadegames.com/
http://simpson.edu/computer-science/
"""
import pygame
# Define some colours using RGB values
BLACK = ( 0, 0, 0)
WHITE = ( 255, 255, 255)
GREEN = ( 0, 255, 0)
RED = ( 255, 0, 0)
pygame.init()
# Set the width and height of the screen [width, height]
size = (700, 500)
screen = pygame.display.set_mode(size)
pygame.display.set_caption("My Game")
# Loop until the user clicks the close button.
done = False
# Used to manage how fast the screen updates
clock = pygame.time.Clock()
# -------- Main Program Loop ----------while not done:
# --- Main event loop
for event in pygame.event.get(): # User did something
if event.type == pygame.QUIT: # If user clicked close
done = True # Flag that we are done so we exit this loop
# --- Game logic should go here
# --- Drawing code should go here
# First, clear the screen to white. Don't put other drawing commands
# above this, or they will be erased with this command.
screen.fill(WHITE)
# PUT YOUR CODE FOR DRAWING BENEATH THIS COMMENT
# --- Go ahead and update the screen with what we've drawn.
pygame.display.flip()
# --- Limit to 60 frames per second
clock.tick(60)
# Close the window and quit.
# If you forget this line, the program will 'hang'
# on exit if running from IDLE.
pygame.quit()