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

Game Making

What am I Learning today?

I am learning how to understand the concept of Sprites and how they can used as game objects.
I am learning how to understand and use variables to change to keep track of the X and Y coordinates of a sprite.
I am learning how to understand the process of painting the screen with image(s) known as Bit Blitting or Blit.

Knowledge Organiser

×

Lesson

Task 1 - Getting Organised Click to see more

  • We are going to save all of our work for this topic into a PowerPoint like we did in our assessment.

  • To download the PowerPoint by clicking on the image below


    Open the code template we created last week, which we copied from our Powerpoint Slide and saved as 'template'

  • Save your python file as 'pygame'


Task 2 - Using Text Click to see more

Activity 1 - Adding Text

Complete the following:

  1. Start a new file with a blank template
  2. Save it as lesson6.py
  3. Add the following code into your variables area.
  4. ##### Your Variables go here ####
    fontName = pygame.font.match_font('arial')
    font = pygame.font.Font(fontName, 22)
    text_surface = font.render("this is text", True, red)
    XYPosition = [100,100]
  5. Add the following code into your code starts here area.
  6.     #### your code starts here ####
        screen.blit(text_surface, XYPosition)

Do not forget to indent your code




  • Can you change the text on the screen?
  • Can make the text a variable?
  • Can you position the text so it is always in the center of the screen, whatever the size of your screen is?
  • Can you make your text scroll?

  • Task 3 - Adding a text function Click to see more

  • Let's try and create a text drawing function that will allow us to draw text where ever we want on the screen using just one line of code.
  • First we need to define our function and work out what we need to put in it.

    Activity 2

    1. On line 7 Add the following line of code
    2. ## functions go here ##############
    3. On the line underneath lets define our function
    4. def textDraw(msgText, XYPosition,colour):
    5. Then indented on the next 4 lines we will add the following code:
    6. fontName = pygame.font.match_font('arial')
      font = pygame.font.Font(fontName, 22)
      text_surface = font.render(msgText, True, colour)
      screen.blit(text_surface, XYPosition)
    7. Replace the line:
    8. screen.blit(text_surface, XYPosition)
      with:
      textDraw( "Text from my function",XYPosition, red)

    Your code should look like the image below Run it, and see what happens?



  • Can make the text a variable?
  • Can you add multiple bits of text onto the screen?
  • Can you make your text scroll accross the screen?

  • Task 4 - Intro Screen Click to see more

    We want to add a 'click here to start' button to our game. For that we are going to have to put some text in the center of our screen and do something when it is clicked.

    Activity 3 - Game states

    The first this we need to do is give the game a state variable which will chage from intro to running when our text is clicked

    1. Add the following lines of code:
    2. Don't forget that they're part of the IF block, so will need to be indented with the tab key .

      Run the code to test it, and see what happens?


    Task 5 - Adding a background image Click to see more

    Activity 4

    Complete the following:

    1. Right click on the image below and save it in your Computer Science folder in the same folder as the python file you are working on.
    2. Save it as background.png
    3. Add the code below to Thonny
    4. Run the code to test it, and see what happens?

    Task 6 - Extension - Game over Click to see more

    Activity 5

    Complete the following:

    1. Add The code below to create a timer and a game over page for your game
    2. First add the variable for the timer
    3. Now add the gameoversection to your code.
    4. Run the code to test it, and see what happens?

    Task 7 - Extend it - Target Practice Click to see more

    Activity 6

    Complete the following:

    1. Right click on the image below and save it in your Computer Science folder in the same folder as the python file you are working on.
    2. Save it as target.png
    3. Add your previous code to your new game for some target practice

    Task 8 - 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 need to learn how to understand and use variables to change to keep track of the X and Y coordinates of a sprite.

    • I have a basic understanding of how I can understand and use variables to change to keep track of the X and Y coordinates of a sprite. with a little help from my teacher
    • I can show my teacher that I can understand and use variables to change to keep track of the X and Y coordinates of a sprite. without their help.
    • I can understand and use variables to change to keep track of the X and Y coordinates of a sprite. 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: Game Development

    Student_Comment_3 not found

    Task Notes/Comments - Add here Click to see more

    Comments/Notes

    Copyright © 2013 - 2026 LearnITwithMrC