SlideShare a Scribd company logo
Girl Coder
Map Mover
Blank Screen
1) import pygame and sys libraries
2) initialize pygame (hint: pygame. )
3) set size of main game screen to 480 by 320 (hint: size = )
4) load screen display (hint: screen = pygame.display. )
5) while loop (tip: indent everything under this)
6) for event loop (tip: pygame.event.get())
7) check for game quit. (hint: if event.type == )
8) quit pygame
9) exit system
10) update display (hint: pygame.display. )
Map Load
Above while loop insert the line below
Change map_name to the actual name of
your map file.
map = pygame.image.load("map_name.png")
Map Show
In while loop
Indent one tab and insert the code in the pink box
immediately above the line
pygame.display.update()
screen.blit(map, (0, 0))
Set Map x and y Variables
Above while loop
map_x = 0
map_y = 0
Use Variables for Map Position
In while loop, edit map blit statement
old: screen.blit(map, (0, 0))
new: screen.blit(map, (map_x, map_y))
Replace the line above with the line below.
Move Map
In while loop add the code in the pink box to
move the map to the left, making the girl
appear to move the right.
Place below for loop code block
map_x = map_x - 1
Create Variable for Direction
Insert line below above while loop
direction = “right”
If Direction and Move
In while loop
Indent one tab and insert the two lines in the pink box
below the for loop code block - below sys.exit()
if direction == “right”:
map_x = map_x -1
if Statements for all 4 Directions
if direction == “right”:
map_x = map_x -1
Use the two lines below as an example and create if statements for left, up,
and down. Test the game after you create each direction by changing the
direction variable near the top of your program code.
direction = “right”
In your code, edit the line below to test each direction.
Keyboard Input - Down
In while loop, find for event loop. It looks like the code
in the blue box. Once you find it, put the code in the pink
box below it with one indent past the for.
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_DOWN:
direction = "down"
for event in pygame.event.get():
Test Keyboard Input
direction = “up”
At the top of your code, set the initial direction to “up”
Run the game. After the map starts moving, press the down
arrow on your keyboard.
4 Direction Keyboard Input
Using the two lines of code below as an
example, create if statements for up, right, and
left.
if event.key == pygame.K_DOWN:
direction = "down"
Test your program after you set each direction.
Girl Load
Above while loop, insert the line below
girl= pygame.image.load("girl.png")
Girl Show
In while loop
Indent one tab and place line in pink box above
pygame.display.update()
and below screen.blit(map, (map_x, map_y)
screen.blit(girl, (100, 100))
Adjust the numbers 100, 100 so that the girl is in the center
of the screen.
Bounds Detection
Edit move statements
if direction == "left":
if map_x < 0:
map_x = map_x + 1
if direction == "up":
if map_y < 0:
map_y = map_y + 1
Right Boundary
if direction == "right":
if map_x > -1216 + 480:
map_x = map_x - 1
1216 is the width of the map. Change the number if the
map is bigger or smaller.
480 is the width of the screen.
Down Boundary
if direction == "down":
if map_y > -896 + 320:
map_y = map_y - 1
896 is the height of the map. Change the number if the
map is bigger or smaller.
320 is the height of the screen.
Yay! You’re Finished
Additional Information follows
Vocabulary
import libraries
pygame initialization
main while loop or main game loop
for loop
if statement
for loop code block
for loop
code
block
import pygame, sys
pygame.init()
size = (480, 320)
screen = pygame.display.set_mode(size)
map = pygame.image.load("caitlyn_map.
png")
girl = pygame.image.load("girl.png")
map_x = 0
map_y = 0
direction = "up"
while True:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_DOWN:
direction = "down"
if event.key == pygame.K_UP:
direction = "up"
if event.key == pygame.K_RIGHT:
direction = "right"
if event.key == pygame.K_LEFT:
direction = "left"
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if direction == "left":
if map_x < 0:
map_x = map_x + 1
if direction == "up":
if map_y < 0:
map_y = map_y + 1
if direction == "down":
if map_y > -896 + 320:
map_y = map_y - 1
if direction == "right":
if map_x > -1216 + 480:
map_x = map_x - 1
screen.blit(map,(map_x,map_y))
screen.blit(girl, (240-32,160-32))
pygame.display.update()
Teaching Python to 9 Year Old Girl -  map mover
Target Students
9 year old girl
Completed the following drills at least 5 times per drill over
several months:
● The Blank Screen
● The Stationary Square
● The Moving Square
Alternate Lessons
If the student is older than 9 and has a mobile phone,
suggest these:
● Mouse and Touchscreen Control
● Going Mobile - Python on Android

More Related Content

PPTX
PUZZLE IN C PROGRAMMING
PPTX
Puzzle in c program
PDF
Notes 3-1
PDF
Julia Set
PDF
Tutorial flash
PPT
Using BigDecimal and double
PDF
Maperitive
PPTX
PUZZLE IN C PROGRAMMING
Puzzle in c program
Notes 3-1
Julia Set
Tutorial flash
Using BigDecimal and double
Maperitive

What's hot (6)

PPTX
Python basic Program
DOC
Math 133 – unit 2 individual project name/tutorialoutlet
PPTX
Introducing the Microsoft Virtual Earth Silverlight Map Control CTP
PDF
Useful Tools for Making Video Games - XNA (2008)
PPT
Darkonoid
PDF
JavaCro'14 - JCalc Calculations in Java with open source API – Davor Sauer
Python basic Program
Math 133 – unit 2 individual project name/tutorialoutlet
Introducing the Microsoft Virtual Earth Silverlight Map Control CTP
Useful Tools for Making Video Games - XNA (2008)
Darkonoid
JavaCro'14 - JCalc Calculations in Java with open source API – Davor Sauer
Ad

Viewers also liked (8)

ODP
Programming physics games with Python and OpenGL
PPT
Qwizdom - Maths Probability
DOCX
Maths (indices assignment)
PPT
Rendering: Vertices, Indices, UVs and Shaders
PDF
Mc Ex[1].3 Unit 3 Indices, Surds And Number Systems
PPTX
Grade 9 Maths - Fractions 1
PPS
NOTE MATH FORM 3 - INDICES
PDF
Docker & IoT: protecting the Datacenter
Programming physics games with Python and OpenGL
Qwizdom - Maths Probability
Maths (indices assignment)
Rendering: Vertices, Indices, UVs and Shaders
Mc Ex[1].3 Unit 3 Indices, Surds And Number Systems
Grade 9 Maths - Fractions 1
NOTE MATH FORM 3 - INDICES
Docker & IoT: protecting the Datacenter
Ad

Similar to Teaching Python to 9 Year Old Girl - map mover (20)

PDF
Pygame presentation
PPTX
Vanmathy python
PPT
Pygame : créer des jeux interactifs en Python.
PDF
Денис Ковалев «Python в игровой индустрии»
PPT
"Pemrograman Python untuk Pemula dan Ahli"
PPTX
Python 03-parameters-graphics.pptx
PDF
Criando meu 1º game com android
DOCX
Android Studio (Java)The SimplePaint app (full code given below).docx
PDF
Description For this part of the assignment, you will create a Grid .pdf
PDF
The following GUI is displayed once the application startsThe sug.pdf
PPTX
WP7 HUB_XNA overview
PPTX
Snake_game.pptx introduction to snake game
PDF
Introduction to Pygame (Lecture 7 Python Game Development)
PPTX
WP7 HUB_XNA
PDF
The Ring programming language version 1.5 book - Part 9 of 31
PDF
The Ring programming language version 1.7 book - Part 53 of 196
PDF
Java ProgrammingImplement an auction application with the followin.pdf
DOCX
Computer graphics
PPT
Programming simple games with a raspberry pi and
PPT
MIDP: Game API
Pygame presentation
Vanmathy python
Pygame : créer des jeux interactifs en Python.
Денис Ковалев «Python в игровой индустрии»
"Pemrograman Python untuk Pemula dan Ahli"
Python 03-parameters-graphics.pptx
Criando meu 1º game com android
Android Studio (Java)The SimplePaint app (full code given below).docx
Description For this part of the assignment, you will create a Grid .pdf
The following GUI is displayed once the application startsThe sug.pdf
WP7 HUB_XNA overview
Snake_game.pptx introduction to snake game
Introduction to Pygame (Lecture 7 Python Game Development)
WP7 HUB_XNA
The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.7 book - Part 53 of 196
Java ProgrammingImplement an auction application with the followin.pdf
Computer graphics
Programming simple games with a raspberry pi and
MIDP: Game API

Recently uploaded (20)

PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
01-Introduction-to-Information-Management.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
RMMM.pdf make it easy to upload and study
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
01-Introduction-to-Information-Management.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Anesthesia in Laparoscopic Surgery in India
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
A systematic review of self-coping strategies used by university students to ...
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
Final Presentation General Medicine 03-08-2024.pptx
Microbial diseases, their pathogenesis and prophylaxis
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
102 student loan defaulters named and shamed – Is someone you know on the list?
Supply Chain Operations Speaking Notes -ICLT Program
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
RMMM.pdf make it easy to upload and study
FourierSeries-QuestionsWithAnswers(Part-A).pdf

Teaching Python to 9 Year Old Girl - map mover

  • 2. Blank Screen 1) import pygame and sys libraries 2) initialize pygame (hint: pygame. ) 3) set size of main game screen to 480 by 320 (hint: size = ) 4) load screen display (hint: screen = pygame.display. ) 5) while loop (tip: indent everything under this) 6) for event loop (tip: pygame.event.get()) 7) check for game quit. (hint: if event.type == ) 8) quit pygame 9) exit system 10) update display (hint: pygame.display. )
  • 3. Map Load Above while loop insert the line below Change map_name to the actual name of your map file. map = pygame.image.load("map_name.png")
  • 4. Map Show In while loop Indent one tab and insert the code in the pink box immediately above the line pygame.display.update() screen.blit(map, (0, 0))
  • 5. Set Map x and y Variables Above while loop map_x = 0 map_y = 0
  • 6. Use Variables for Map Position In while loop, edit map blit statement old: screen.blit(map, (0, 0)) new: screen.blit(map, (map_x, map_y)) Replace the line above with the line below.
  • 7. Move Map In while loop add the code in the pink box to move the map to the left, making the girl appear to move the right. Place below for loop code block map_x = map_x - 1
  • 8. Create Variable for Direction Insert line below above while loop direction = “right”
  • 9. If Direction and Move In while loop Indent one tab and insert the two lines in the pink box below the for loop code block - below sys.exit() if direction == “right”: map_x = map_x -1
  • 10. if Statements for all 4 Directions if direction == “right”: map_x = map_x -1 Use the two lines below as an example and create if statements for left, up, and down. Test the game after you create each direction by changing the direction variable near the top of your program code. direction = “right” In your code, edit the line below to test each direction.
  • 11. Keyboard Input - Down In while loop, find for event loop. It looks like the code in the blue box. Once you find it, put the code in the pink box below it with one indent past the for. if event.type == pygame.KEYDOWN: if event.key == pygame.K_DOWN: direction = "down" for event in pygame.event.get():
  • 12. Test Keyboard Input direction = “up” At the top of your code, set the initial direction to “up” Run the game. After the map starts moving, press the down arrow on your keyboard.
  • 13. 4 Direction Keyboard Input Using the two lines of code below as an example, create if statements for up, right, and left. if event.key == pygame.K_DOWN: direction = "down" Test your program after you set each direction.
  • 14. Girl Load Above while loop, insert the line below girl= pygame.image.load("girl.png")
  • 15. Girl Show In while loop Indent one tab and place line in pink box above pygame.display.update() and below screen.blit(map, (map_x, map_y) screen.blit(girl, (100, 100)) Adjust the numbers 100, 100 so that the girl is in the center of the screen.
  • 16. Bounds Detection Edit move statements if direction == "left": if map_x < 0: map_x = map_x + 1 if direction == "up": if map_y < 0: map_y = map_y + 1
  • 17. Right Boundary if direction == "right": if map_x > -1216 + 480: map_x = map_x - 1 1216 is the width of the map. Change the number if the map is bigger or smaller. 480 is the width of the screen.
  • 18. Down Boundary if direction == "down": if map_y > -896 + 320: map_y = map_y - 1 896 is the height of the map. Change the number if the map is bigger or smaller. 320 is the height of the screen.
  • 19. Yay! You’re Finished Additional Information follows
  • 20. Vocabulary import libraries pygame initialization main while loop or main game loop for loop if statement
  • 21. for loop code block for loop code block
  • 22. import pygame, sys pygame.init() size = (480, 320) screen = pygame.display.set_mode(size) map = pygame.image.load("caitlyn_map. png") girl = pygame.image.load("girl.png") map_x = 0 map_y = 0 direction = "up" while True: for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_DOWN: direction = "down" if event.key == pygame.K_UP: direction = "up" if event.key == pygame.K_RIGHT: direction = "right" if event.key == pygame.K_LEFT: direction = "left" if event.type == pygame.QUIT: pygame.quit() sys.exit() if direction == "left": if map_x < 0: map_x = map_x + 1 if direction == "up": if map_y < 0: map_y = map_y + 1 if direction == "down": if map_y > -896 + 320: map_y = map_y - 1 if direction == "right": if map_x > -1216 + 480: map_x = map_x - 1 screen.blit(map,(map_x,map_y)) screen.blit(girl, (240-32,160-32)) pygame.display.update()
  • 24. Target Students 9 year old girl Completed the following drills at least 5 times per drill over several months: ● The Blank Screen ● The Stationary Square ● The Moving Square
  • 25. Alternate Lessons If the student is older than 9 and has a mobile phone, suggest these: ● Mouse and Touchscreen Control ● Going Mobile - Python on Android