Computer Science LearnITWithMrC ⛯ Year 7 Year 8 Year 9 GCSE
Responsive image

Options Taster2

What am I Learning today?

I am learning how to use python to create animated graphics

Knowledge Organiser

×

Lesson

Task 1 - Getting Organised Click to see more

  • We are going to save our work for today into the PowerPoint below.

  • To download the PowerPoint by clicking on the image below


  • Save your PowerPoint as 'Pygame'


  • Task 2 - Introducing Pygame - Getting started Click to see more

    Setting up Pygame

    Using the code template

    • In the Powerpoint you have just downloaded and saved there is a slide containing the text for our coding template.
    • Copy the text into Thonny and then run your code.

    • When you run your code you should see a game window appear that is 640 by 480 like the example below.

  • Can you work out how to change the screen size to 1024 by 768 ?

  • Task 3 - Using co-ordinates Click to see more

  • When we want to draw something in pygame we have to use the screen co-ordinates.
  • Unlike programs like Scratch, Pygame and most game engines have the origin for their co-ordinates (x = 0 , y = 0) at the top left hand corner of the screen.
  • You can see here in our image above that a pixel, has been placed at the co-ordinates x = 30 , y = 40 which we would write (30,40) from the top left hand corner of the screen.
  • Using that basic understanding let's see if we can draw a line.

  • Drawing a line:

  • In order to draw a line we need the co-ordinates for the start of the line and the co-ordinates for the end of the line. We are going to start in the top left corner so thats easy it will be (0,0) and we are going to draw a line to the co-ordinates we used above (30,40)
  • This is the function we need to use in pygame to draw a line:

  • pygame.draw.line(Where?,color?,(start x? start y?) (end x?, end y?) line thickness?)
  • So lets fill it in with the co-ordinates we mentioned above (0,0)and (30,40) and we will use the colour green and a line thickness of 2

  • pygame.draw.line(screen, green, (0,0), (30,40), 2)
  • Look at the image below to see where to put this line of code in your template. hint: it goes between the lines that say 'your code starts here' and 'your code ends here'.

  • Run your code and you should get a small geen line drawn from the corner of your screen?


  • Can you draw a longer thicker line?
  • Can you draw another line that starts where your fist line ends?
  • Can you draw a shape like a triangle or a square?

  • Task 4 - Drawing shapes Click to see more

    Drawing a rectangle:

    In order to draw a rectangle we only need the co-ordinates for the top left hand corner of the rectangle and then the height and width in pixels.

  • pygame.draw.rect(screen, green, (30,40,50,20))
  • When you run your code it should look like this:


  • Can you draw a square?
  • Can you use a different colour?
  • Can you complete the next task it might seem familiar?

  • Task 5 - Extend it Click to see more

    Can you draw the Microsoft logo?

  • Using the rectangle command and the line command for the white cross in the middle?

  • Task 6 - Making circles Click to see more


  • Can you use the three drawing tools to make a cool image?

  • Task 7 - Lesson review Click to see more

    Summing it all up

    Lets look at the learning outcomes and decide which one best describes our current level of understanding :

    Tick the one you feel is closest to your level

    Learning Outcomes

    • I have a basic understanding of how with a little help from my teacher
    • I can show my teacher that without their help.
    • independently and I can also explain it to others and can complete any extension tasks I am given.

    🠜 Now update your learning objectivesClick on the Assessment image

    My Notes: Coding-p2

    Student_Comment_4 not found

    Task Notes/Comments - Add here Click to see more

    Comments/Notes

    Copyright © 2013 - 2024 LearnITwithMrC