SlideShare a Scribd company logo
1 of 25
Download to read offline
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()
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

What's hot

Python basic Program
Python basic ProgramPython basic Program
Python basic Programnuripatidar
 
Math 133 – unit 2 individual project name/tutorialoutlet
Math 133 – unit 2 individual project name/tutorialoutletMath 133 – unit 2 individual project name/tutorialoutlet
Math 133 – unit 2 individual project name/tutorialoutletCleasbyz
 
Introducing the Microsoft Virtual Earth Silverlight Map Control CTP
Introducing the Microsoft Virtual Earth Silverlight Map Control CTPIntroducing the Microsoft Virtual Earth Silverlight Map Control CTP
Introducing the Microsoft Virtual Earth Silverlight Map Control CTPgoodfriday
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Korhan Bircan
 

What's hot (6)

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

Viewers also liked

Programming physics games with Python and OpenGL
Programming physics games with Python and OpenGLProgramming physics games with Python and OpenGL
Programming physics games with Python and OpenGLDaniel Pope
 
Qwizdom - Maths Probability
Qwizdom  - Maths ProbabilityQwizdom  - Maths Probability
Qwizdom - Maths ProbabilityQwizdom UK
 
Maths (indices assignment)
Maths (indices assignment)Maths (indices assignment)
Maths (indices assignment)Anamta Ali Pasha
 
Rendering: Vertices, Indices, UVs and Shaders
Rendering: Vertices, Indices, UVs and ShadersRendering: Vertices, Indices, UVs and Shaders
Rendering: Vertices, Indices, UVs and ShadersDavid Goemans
 
Mc Ex[1].3 Unit 3 Indices, Surds And Number Systems
Mc Ex[1].3  Unit 3 Indices, Surds And Number SystemsMc Ex[1].3  Unit 3 Indices, Surds And Number Systems
Mc Ex[1].3 Unit 3 Indices, Surds And Number Systemsguest9f21a4
 
Grade 9 Maths - Fractions 1
Grade 9 Maths - Fractions 1Grade 9 Maths - Fractions 1
Grade 9 Maths - Fractions 1Nathan Dennis
 
NOTE MATH FORM 3 - INDICES
NOTE MATH FORM 3 - INDICESNOTE MATH FORM 3 - INDICES
NOTE MATH FORM 3 - INDICESNad0209
 
Docker & IoT: protecting the Datacenter
Docker & IoT: protecting the DatacenterDocker & IoT: protecting the Datacenter
Docker & IoT: protecting the DatacenterAlex Ellis
 

Viewers also liked (8)

Programming physics games with Python and OpenGL
Programming physics games with Python and OpenGLProgramming physics games with Python and OpenGL
Programming physics games with Python and OpenGL
 
Qwizdom - Maths Probability
Qwizdom  - Maths ProbabilityQwizdom  - Maths Probability
Qwizdom - Maths Probability
 
Maths (indices assignment)
Maths (indices assignment)Maths (indices assignment)
Maths (indices assignment)
 
Rendering: Vertices, Indices, UVs and Shaders
Rendering: Vertices, Indices, UVs and ShadersRendering: Vertices, Indices, UVs and Shaders
Rendering: Vertices, Indices, UVs and Shaders
 
Mc Ex[1].3 Unit 3 Indices, Surds And Number Systems
Mc Ex[1].3  Unit 3 Indices, Surds And Number SystemsMc Ex[1].3  Unit 3 Indices, Surds And Number Systems
Mc Ex[1].3 Unit 3 Indices, Surds And Number Systems
 
Grade 9 Maths - Fractions 1
Grade 9 Maths - Fractions 1Grade 9 Maths - Fractions 1
Grade 9 Maths - Fractions 1
 
NOTE MATH FORM 3 - INDICES
NOTE MATH FORM 3 - INDICESNOTE MATH FORM 3 - INDICES
NOTE MATH FORM 3 - INDICES
 
Docker & IoT: protecting the Datacenter
Docker & IoT: protecting the DatacenterDocker & IoT: protecting the Datacenter
Docker & IoT: protecting the Datacenter
 

Similar to Teaching Python to 9 Year Old Girl - map mover

Денис Ковалев «Python в игровой индустрии»
Денис Ковалев «Python в игровой индустрии»Денис Ковалев «Python в игровой индустрии»
Денис Ковалев «Python в игровой индустрии»DataArt
 
Python 03-parameters-graphics.pptx
Python 03-parameters-graphics.pptxPython 03-parameters-graphics.pptx
Python 03-parameters-graphics.pptxTseChris
 
Criando meu 1º game com android
Criando meu 1º game com androidCriando meu 1º game com android
Criando meu 1º game com androidDaniel Baccin
 
Android Studio (Java)The SimplePaint app (full code given below).docx
Android Studio (Java)The SimplePaint app (full code given below).docxAndroid Studio (Java)The SimplePaint app (full code given below).docx
Android Studio (Java)The SimplePaint app (full code given below).docxamrit47
 
Description For this part of the assignment, you will create a Grid .pdf
Description For this part of the assignment, you will create a Grid .pdfDescription For this part of the assignment, you will create a Grid .pdf
Description For this part of the assignment, you will create a Grid .pdfformicreation
 
The following GUI is displayed once the application startsThe sug.pdf
The following GUI is displayed once the application startsThe sug.pdfThe following GUI is displayed once the application startsThe sug.pdf
The following GUI is displayed once the application startsThe sug.pdfarihantsherwani
 
WP7 HUB_XNA overview
WP7 HUB_XNA overviewWP7 HUB_XNA overview
WP7 HUB_XNA overviewMICTT Palma
 
The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5 book - Part 9 of 31The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5 book - Part 9 of 31Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196Mahmoud Samir Fayed
 
Java ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdfJava ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdfatulkapoor33
 
Computer graphics
Computer graphicsComputer graphics
Computer graphicsamitsarda3
 
Programming simple games with a raspberry pi and
Programming simple games with a raspberry pi andProgramming simple games with a raspberry pi and
Programming simple games with a raspberry pi andKellyn Pot'Vin-Gorman
 
Strategies for refactoring and migrating a big old project to be multilingual...
Strategies for refactoring and migrating a big old project to be multilingual...Strategies for refactoring and migrating a big old project to be multilingual...
Strategies for refactoring and migrating a big old project to be multilingual...benjaoming
 
The Ring programming language version 1.5.3 book - Part 58 of 184
The Ring programming language version 1.5.3 book - Part 58 of 184The Ring programming language version 1.5.3 book - Part 58 of 184
The Ring programming language version 1.5.3 book - Part 58 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184Mahmoud Samir Fayed
 

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

Pygame presentation
Pygame presentationPygame presentation
Pygame presentation
 
Vanmathy python
Vanmathy python Vanmathy python
Vanmathy python
 
Денис Ковалев «Python в игровой индустрии»
Денис Ковалев «Python в игровой индустрии»Денис Ковалев «Python в игровой индустрии»
Денис Ковалев «Python в игровой индустрии»
 
Python 03-parameters-graphics.pptx
Python 03-parameters-graphics.pptxPython 03-parameters-graphics.pptx
Python 03-parameters-graphics.pptx
 
Criando meu 1º game com android
Criando meu 1º game com androidCriando meu 1º game com android
Criando meu 1º game com android
 
Android Studio (Java)The SimplePaint app (full code given below).docx
Android Studio (Java)The SimplePaint app (full code given below).docxAndroid Studio (Java)The SimplePaint app (full code given below).docx
Android Studio (Java)The SimplePaint app (full code given below).docx
 
Description For this part of the assignment, you will create a Grid .pdf
Description For this part of the assignment, you will create a Grid .pdfDescription For this part of the assignment, you will create a Grid .pdf
Description For this part of the assignment, you will create a Grid .pdf
 
The following GUI is displayed once the application startsThe sug.pdf
The following GUI is displayed once the application startsThe sug.pdfThe following GUI is displayed once the application startsThe sug.pdf
The following GUI is displayed once the application startsThe sug.pdf
 
WP7 HUB_XNA overview
WP7 HUB_XNA overviewWP7 HUB_XNA overview
WP7 HUB_XNA overview
 
WP7 HUB_XNA
WP7 HUB_XNAWP7 HUB_XNA
WP7 HUB_XNA
 
The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5 book - Part 9 of 31The Ring programming language version 1.5 book - Part 9 of 31
The Ring programming language version 1.5 book - Part 9 of 31
 
The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196The Ring programming language version 1.7 book - Part 53 of 196
The Ring programming language version 1.7 book - Part 53 of 196
 
Java ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdfJava ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdf
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Programming simple games with a raspberry pi and
Programming simple games with a raspberry pi andProgramming simple games with a raspberry pi and
Programming simple games with a raspberry pi and
 
MIDP: Game API
MIDP: Game APIMIDP: Game API
MIDP: Game API
 
Strategies for refactoring and migrating a big old project to be multilingual...
Strategies for refactoring and migrating a big old project to be multilingual...Strategies for refactoring and migrating a big old project to be multilingual...
Strategies for refactoring and migrating a big old project to be multilingual...
 
The Ring programming language version 1.5.3 book - Part 58 of 184
The Ring programming language version 1.5.3 book - Part 58 of 184The Ring programming language version 1.5.3 book - Part 58 of 184
The Ring programming language version 1.5.3 book - Part 58 of 184
 
The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184
 
Programas Gambas
Programas GambasProgramas Gambas
Programas Gambas
 

Recently uploaded

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 

Recently uploaded (20)

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 

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()
  • 23.
  • 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