We Are Adventure Gamers 6.1 Making a Text-Based Adventure Game
Total Page:16
File Type:pdf, Size:1020Kb
Unit We are adventure gamers 6.1 Making a text-based adventure game 1 About this unit Software: Python and IDLE, or trinket.io Apps: Pythonista or Python 3.4 for iOS (iOS), SL4A (Android), or trinket.io via Safari or other browser, Bluetooth keyboards are recommended for tablets Hardware: Laptop/desktop computers. Python works very well on the Raspberry Pi Outcome: A text-based adventure game UNIT SUMMARY they will have encountered previously. Encourage pupils to look for similarities and differences. It is In this unit, the pupils learn a few commands of a important that pupils first plan their program before text-based programming language (Python), enabling they start writing the code. progression from Scratch. They create a simple, text- Python is used here in a form where commands based adventure game. are executed in sequence, just as blocks are used in Scratch. The pupils meet Python’s commands CURRICULUM LINKS for repetition and selection, work with variables and a list, and use text-based input and output. Computing PoS They create their own functions to provide a clearer structure for their program. Design, write and debug programs that accomplish The pupils will encounter a new type of error (bug) specific goals, including controlling or simulating in Python programming – the syntax error – where physical systems; solve problems by decomposing spelling or punctuation mistakes prevent Python them into smaller parts. from understanding the code they write. Fixing Use sequence, selection and repetition in these mistakes is vital in text-based programming. programs; work with variables and various forms of input and output. LEARNING EXPECTATIONS Use logical reasoning to explain how some simple algorithms work and to detect and correct errors in This unit will enable the children to: algorithms and programs. learn some of the syntax of a text-based Suggested subject links programming language English: Using Python (or other text-based use commands to display text on screen, accept languages) helps reinforce the importance of typed user input, store and retrieve data using spelling, punctuation and grammar. The pupils will variables and select from a list need to interpret Python’s error messages and plan a text-based adventure with multiple ‘rooms’ spot the mistakes in their programs. and user interaction English: The unit provides an excellent opportunity thoroughly debug the program. to develop the pupils’ descriptive writing and The assessment guidance on page 10 will help storytelling. you to decide whether the children have met these The context of the adventure game could be expectations. related to another area of the curriculum, to a class reader or to broader PSHE themes. Typically, VARIATIONS TO TRY adventure games use medieval ‘swords and sorcery’ settings, but you may prefer to give a A text-based adventure can be created using clearer, curriculum-focused theme to pupils’ work. Scratch or other visual programming languages if the additional demands of Python prove too much TRANSLATING THE COMPUTING PoS for some or all pupils. There are dedicated systems for creating text- The pupils will be designing, writing and debugging based adventure games (‘interactive fiction’) such a program with a specific goal in mind. They will be as Twine and Inform 7. Simple ‘choose your own working in a text-based language, allowing them adventure’ games can be created using HTML, to compare and contrast this with Scratch, which wikis or presentation software. 12 25962 SOC Year 6 UPDATE V2.indd 12 01/07/2016 15:02 before embarking on this unit. Work through the 2 Getting ready steps of the unit and perhaps explore some of the online tutorials suggested in Useful links. THINGS TO DO Watch the two CPD videos: ‘Getting started with Read the ‘Quick start guide’ on the inside front Python’ and ‘Next steps with Python’. cover and the Core steps sections of Running the Think about grouping for this project – pairs would task on pages 14–19. work well, but ensure both partners contribute to Think about a context for the pupils’ adventure both the content writing and the programming. games – the pupils could choose a topic that Read the School and Home sections of Running they find interesting, or you may prefer to give a the task on pages 14–19. Do you want to use any clear curriculum focus to their work – making an of the extras provided? interactive story based on a class reader, or a Ensure you have sufficient computers/laptops/ history or geography topic could work well. Not all tablets booked in advance. pupils would find a traditional ‘swords and sorcery’ adventure interesting. THINGS YOU NEED Decide which software/tools are most accessible/ Laptop/desktop computers with either Python appropriate for use with your class. See Variations installed or access to Trinket. Parental consent to try for some alternatives to Python for this unit. is needed for pupils to register for accounts on Download and ensure you have access to your Trinket, but it can be used without registering, and chosen software/tools (see Useful links). Python programs can be copied and pasted to a Look at appropriate software tutorials. It’s worth text editor to save locally. investing some time in exploring Python for yourself Paper and pens for planning the story. MY RISING STARS RESOURCES INCLUSION Unit poster – Some Python syntax Think about how best to scaffold pupils’ learning, Handout – Some common Python commands perhaps using help sheets or example code – a Pupil self-assessment information template for a completed adventure is available CPD videos – ‘Getting started with Python’; online. You might allow pupils to tackle this unit ‘Next steps with Python’ using Scratch or a similar language. Walkthrough videos of writing a simple text Some pupils might find it helpful to use speech-to- adventure text or text-to-speech software when programming Sample planning graph in a text-based language. Python includes Adventure game template file (see also: trinket.io/ access to the operating system’s text-to-speech python/7c35eac386) capabilities using the pyttsx ‘wrapper’. ONLINE SAFETY USEFUL LINKS WWW Although Python programming is unlikely to pose Software and tools many online safety-related risks, Python does Python: www.python.org. provide programmable access to shell/operating Google drawings: docs.google.com/drawings. system commands so it must be used responsibly Trinket (online Python interpreter) trinket.io. on personal computers or school networks. Ask Pythonista for iOS: itunes.apple.com/gb/app/ your network manager to make sure that it is pythonista/id528579881. installed safely. Scripting layer for Android (including Python): Pupils can use the online trinket.io Python github.com/damonkohler/sl4a. interpreter. To save work online they will need to Online tutorials register, which requires parental consent. If pupils www.learnpython.org/. publish their work online, remind them that they Codecademy Python course: www.codecademy. are responsible for the content they create. Also com/learn/python. remind them not to share personal information www.edx.org/course/cs-all-introduction-computer- publicly via Trinket. science-harveymuddx-cs005x. Pupils might like to base their adventure game on published stories – discuss the intellectual property Information and ideas implications of this with them. Further Python activities from Code Club: www. codeclubprojects.org/en-GB/python/. Introduction to Interactive Fiction at www.willhines. net/if/harold3/IntroductionToIF.pdf. 13 25962 SOC Year 6 UPDATE V2.indd 13 01/07/2016 15:02 25962 SOC Year 6 UPDATE V2.indd 14 14 3 Running the task – We are adventure gamers Software: Python and IDLE or trinket.io Apps: Pythonista or Python 3.4 for iOS (iOS), SL4A (Android), or trinket.io. Bluetooth keyboards are recommended for tablets Hardware: Laptop/desktop computers. Python works very well on the Raspberry Pi Outcome: A text-based adventure game Note: The steps below assume you’ll be using Python’s IDLE development environment installed on laptop or desktop computers. If you’re using a different tool to access Python (e.g. trinket.io or Pythonista) some steps will need minor changes Core steps Extensions Step 1: Getting started with Python SCHOOL RESOURCES Remind pupils that in Scratch they build a program using the Ask the pupils to get Python to print out blocks that are provided, but in Python they’ll need to write (i.e. the seven times table. Can they get it to Python and IDLE, trinket.io or other type) their program. print out the first ten square numbers? Python interpreter and editor Show the pupils how to launch the IDLE development environment. What about the first ten powers of two? Demonstrate how Python can work out some simple arithmetic Clue: A command for the seven times questions, e.g. 7 * 8, 12 + 34, 2 * * 5. Can they work out table would be: POSSIBLE OUTCOME FOR THIS STEP: the difference between 32 / 5 and 32 / / 5? for i in range (1,13): Demonstrate how Python can print text on screen. Start with print (7*i) a simple command like ( ). Draw their print “Hello, world!” Is the result they expected? Can they attention to the brackets and the quotation marks here. Ask work out what range(10) means? What them to experiment with getting Python to say other things. happens if they type print (range(10)) Demonstrate how Python does repetition, using a program on its own? such as the following. for i in range(10): print ["Hello, world!"] Show how this is entered in Python’s interactive shell. Emphasise the importance of the colon and the indent here. HOME The pupils could try typing the following: for i in ["red","green","blue"]: Encourage pupils to demonstrate Python print ("I like the colour",i) to their parents, perhaps using trinket.io.