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

Game Making - Intro

What am I Learning today?

I am learning how to create a simple game in pygame from a set of instructions

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 your code template, there is a copy in your Pygame Project Powerpoint.
  • Save your PowerPoint into One Drive as 'pygame project'


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 intro.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 - Putting it all together - Intro Page Click to see more

    Activity 5

    Now you know how to add text and images to your screen come up with a fancy intro for your game like the one below


    Task 7 - Lesson Review/Homework Click to see more

    Complete your intro page for your pygame project

    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: Game Development2

    Student_Comment_4 not found

    Task Notes/Comments - Add here Click to see more

    Comments/Notes