Download presentation
Presentation is loading. Please wait.
Published byMarjorie Matthews Modified over 8 years ago
1
Graphics in Python On entry: Run Python 2.78 from N: drive/computing and ICT VLE: Computing home page - check your feedback Success criteria: ●Understands the process of computer animation ●Can use simple Python instructions to draw a shape ●Understand how loops allow shapes to be redrawn Learning Intention: sequencing instructions to make simple animations in Python
2
What is ‘animation’? How does animation work? Watch video clip from lesson 6
3
Learning Intention: sequencing instructions to make simple animations in Python Can you translate how we animate into an algorithm for Python? Set position of shape Draw Shape Delete shape Repeat
4
Learning Intention: sequencing instructions to make simple animations in Python Repeat
5
Learning Intention: sequencing instructions to make simple animations in Python Repeat """ Sample Python/Pygame Programs Simpson College Computer Science http://programarcadegames.com/ http://simpson.edu/computer-science/ Explanation video: http://youtu.be/vRB_983kUMc """ import pygame # Define some colours using RGB values BLACK = ( 0, 0, 0) WHITE = ( 255, 255, 255) GREEN = ( 0, 255, 0) RED = ( 255, 0, 0)
6
Learning Intention: sequencing instructions to make simple animations in Python Repeat 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() # Starting x position of the rectangle rect_x = 50
7
Learning Intention: sequencing instructions to make simple animations in Python Rep eat # -------- 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 black. Don't put other drawing commands # above this, or they will be erased with this command. screen.fill(BLACK) # PUT YOUR CODE FOR ANIMATING 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() pygame.draw.rect(screen, WHITE, [rect_x, 50, 50, 50]) rect_x += 1
8
Learning Intention: sequencing instructions to make simple animations in Python Choose your task based on your confidence! Hard Complete the tutorial sections to animate a simple shape. Complete all but the ‘mega- challenges’ sections for an outstanding work award. Harder Work through the tutorials at a snappy pace, completing the mega challenges! Hardest Explore the random element to add a more natural look to your own animations. Mega-challenge ****really hard****: Can you use ‘Def’ to create a function to draw shapes before the while loop, and then use the procedure to draw the shape?
9
Learning Intention: sequencing instructions to make simple animations in Python Your screen pygame.draw.rect(screen, WHITE, [rect_x, 50, 50, 50])
10
Learning Intention: sequencing instructions to make simple animations in Python rect_x += 1 What does this line of code do? What does changing the 1 do?
11
Learning Intention: sequencing instructions to create graphics in Python Plenary What have you learnt? What would you like to learn next? Success criteria: ● Understands the process of computer animation ● Can use simple Python instructions to draw a shape ● Understand how loops allow shapes to be redrawn
12
Homework Update your blog with code, screenshots and reflections from all lessons. Code academy Final hand in deadline – last Friday of term
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.