You will be writing code in the Python programming language, which you may have learnt in the Python module.

Similar documents
Quiz. Introduction: Python. In this project, you ll make a quiz game to challenge your friends. Activity Checklist.

In this project, you ll learn how to use a turtle to draw awesome shapes and patterns.

In this project, you ll learn how to create your own webpage to tell a story, joke or poem. Think about the story you want to tell.

You are going to learn how to make a timer, so that you can use it to challenge your friends!

Intro to Python Programming

A cipher is a type of secret code, where you swap the letters around so that noone can read your message.

In this project, you ll learn how to create a webpage for your favourite recipe.

Add in a new balloon sprite, and a suitable stage backdrop.

Lost in Space. Introduction. Step 1: Animating a spaceship. Activity Checklist. You are going to learn how to program your own animation!

Lost in Space. Introduction. Scratch. You are going to learn how to program your own animation! Activity Checklist.

Polygons and Angles: Student Guide

In this project, you ll learn how to use CSS to create an animated sunrise.

In this project, you will create a showcase of your HTML projects and learn about links and embedding resources.

Make a game in which you play the notes of a song as they scroll down the stage.

In this project, you ll create a set of linked rooms where each room is a different web page which you can decorate with HTML.

Mailman Max. The postcode is a great way to work out the next sorting office a letter should go to, so you ll use that.

nbn Troubleshooting Guide Fibre to the Curb (FTTC)

Let s create a grid of pixels that you can use for creating pixel art. CSS provides table styles for grid and table layouts.

Programming Project 1

ICS 61 Game Systems and Design Introduction to Scratch

TTS Rainbow Matrix TEACHER GUIDE

ASCII Art. Introduction: Python

SPRITES Moving Two At the Same Using Game State

Decisions, Decisions. Testing, testing C H A P T E R 7

CMSC 201 Fall 2018 Lab 04 While Loops

Using Flash Animation Basics

User s Guide

DIRECTV Message Board

OrbBasic Lesson 1 Goto and Variables: Student Guide

Creating an Animated Navigation Bar in InDesign*

PowerPoint Basics: Create a Photo Slide Show

OrbBasic 1: Student Guide

Sphero Lightning Lab Cheat Sheet

CoderDojo Activity Cards: The Cards (Animation2.html): How to use: Student comes to mentor, and together they choose a card to do next.

Text Input and Conditionals

Introduction to VPython for E&M This tutorial will guide you through the basics of programming in VPython

Game Design Unity Workshop

Animations that make decisions

Calculus II. Step 1 First, here is a quick sketch of the graph of the region we are interested in.

Programming with Python

What You're Building 2. Getting Started 3 Introduction 4 Iteration or how we will get to Finished App. 4

Using Dreamweaver CC. Logo. 4 Creating a Template. Page Heading. Page content in this area. About Us Gallery Ordering Contact Us Links

Use lists. Use loops. Use conditionals. Define and use functions. Create and use code modules

SlickEdit Gadgets. SlickEdit Gadgets

Windows Movie Maker lets you edit videos from video and photo files. It is free from Microsoft.

Creating Breakout - Part 2

user guide AbiBird You will need The AbiBird Sensor and An iphone with ios 10+ OR A Smartphone with Android 5+

Introduction to VPython This tutorial will guide you through the basics of programming in VPython.

Unit 21 - Creating a Navigation Bar in Macromedia Fireworks

How to decrypt 3ds ROM s: This Guide is STRICTLY for 3DS s that are on firmware s I will go back and make this

Unit 9 Tech savvy? Tech support. 1 I have no idea why... Lesson A. A Unscramble the questions. Do you know which battery I should buy?

PYTHON YEAR 10 RESOURCE. Practical 01: Printing to the Shell KS3. Integrated Development Environment

Gdes2000 Graphic Design and the Internet

(try adding using css to add some space between the bottom of the art div and the reset button, this can be done using Margins)

The first program: Little Crab

Self-Teach Exercises: Getting Started Turtle Python

Interactive Tourist Map

BB4W. KS3 Programming Workbook INTRODUCTION TO. BBC BASIC for Windows. Name: Class:

Wanted! Introduction. Step 1: Styling your poster. Activity Checklist. In this project, you ll learn how to make your own poster.

Introduction to Computer Programming for Non-Majors

Pong in Unity a basic Intro

Procedures: Algorithms and Abstraction

Making use of other Applications

Erasmus+ Project: Yestermorrow Year 1 Maths: Pythagorean Theorem

KS3 Computer Science. Micro Python Booklet

Smoother Graphics Taking Control of Painting the Screen

What s the base case?

Using IDLE for

Pibrella & Python. What is it? Table of Contents

Quick Guide. Choose It Maker 2. Overview/Introduction. ChooseIt!Maker2 is a motivating program at first because of the visual and musical

In this project, you ll create a mystery letter that looks like each word has been cut from a different newspaper, magazine, comic or other source.

Create Turtles with Python

1.7 Limit of a Function

: Intro Programming for Scientists and Engineers Assignment 1: Turtle Graphics

Introduction to VPython This tutorial will guide you through the basics of programming in VPython.

Welcome to Desktop Publishing with InDesign!

What Is R-MIX Tab? IMPORTANT NOTES. What Is V-Remastering Technology? Copyrights. Licenses/Trademarks. Additional Precautions

Lab 2: Booleans, Strings, Random Numbers, Recursion, Variables, Input function

TWO PLAYER REACTION GAME

Topic. Section 4.1 (3, 4)

Math-2. Lesson 3-1. Equations of Lines

Warping & Blending AP

1/Build a Mintronics: MintDuino

BE A MOVIE MAKER! Before we import our pictures, we want to change the default frame rate -- in other words, how fast our movie will run.

Exercise 1.1 A First NetLogo Session Turtle commands and properties

CS12020 (Computer Graphics, Vision and Games) Worksheet 1

Making a maze with Scratch

How to Use the Explore Service Area Tool: By Geography.

Solution: It may be helpful to list out exactly what is in each of these events:

vividwireless USB modem

Introduction to Computer Science with MakeCode for Minecraft

Welcome. Welcome to Channel Robot s Slice Version 4. Thanks for buying the product, and we hope you enjoy your time with it.

Common iphone problems, tips and tricks

Pupil Name. Year. Teacher. Target Level. Key Stage 3 Self-Assessment Year 9 Python. Spelling Test No 3. Spelling Test No 2. Spelling Test No 1

2.0: The Storyboard Editor

PaintPot. Figure 2-1. The PaintPot app

AO3. 1. Load Flash. 2. Under Create New click on Flash document a blank screen should appear:

Understanding an App s Architecture

(Python) Chapter 3: Repetition

SPRITES Making Things Move Around The Screen

Transcription:

Tightrope Introduction: In this project you will create a game in which you have to tilt your Sense HAT to guide a character along a path. If you fall off the path, you have to start again from the beginning! You will be writing code in the Python programming language, which you may have learnt in the Python module. Step 1: Draw a path First let s draw the path that your character must follow. Activity Checklist Open the Tightrope Starter Trinket: jumpto.cc/tightrope-go. The code to set up the Sense HAT has been included for you. Let s start by creating variables to store the colours you want to use. 1

Remember that to set the colour of an individual LED, you need to say how much red, green and blue it should have. To create yellow, you ll need maximum red and green, and no blue: (If you prefer, you can go to jumpto.cc/colours and choose any colour you like! You ll also need black pixels (or any colour you like) around the path. To draw your path, you first need to create a list containing the colour of each pixel. 2

To save typing, you can copy the code from snippets.py in your project. Next, you need to call set_pixels to display your path image on the Sense HAT. Click Run to test your code. You should see a yellow pixel in the places that you ve used your y variable, and no colour in the places that you ve used x. 3

Challenge: Create your own path Can you edit your path variable to create a path to follow? Make sure that your path starts at the top-left of the display. Step 2: Draw your player Let s add the character to your game. 4

Activity Checklist First, create another colour variable for your character. Here s how to create blue: Next you need to create variables to store your character s x and y position. To start with, we ll set these both to 0, which is the top-left of the Sense HAT. To display your character, use set_pixel. You need to tell set_pixel the x and y position of the pixel to set, as well as the colour. Test your code, and you should now see your character in the top-left of the screen. 5

Step 3: Roll, pitch and yaw You ll be tilting the Sense HAT to move your character. Let s start by finding out the orientation (the position) of your Sense HAT. Activity Checklist The Sense HAT can detect its roll, pitch and yaw. Try dragging the Sense HAT to change its roll, pitch and yaw values to 6

see how it moves. Press the reset button to put the Sense HAT back to the starting position when you ve finished testing. We only need the pitch and the roll for this project, so add 2 lines of code to get these values from the Sense HAT. Print the pitch and roll to test them out. Run your code to test it, and change the pitch of the Sense HAT to tilt it to the right. You ll notice that the printed pitch value doesn t change! 7

The problem is that you are only getting and printing the pitch and roll once. To do this repeatedly, you ll first need to indent all of your code for setting the pixels, as well as getting and printing the pitch and roll values. You can then add while True: above the indented code to run it forever. 8

Test your code again, and this time you should see the printed pitch value change. Step 4: Moving the character Now let s move your character when the Sense HAT is tilted. Activity Checklist Let s move your character to the right if the Sense HAT s pitch is between 270 and 315 degrees. Add this code to change the character s x position if the pitch is between 270 and 315 : 9

Make sure that this code is indented, so that the character moves repeatedly if the Sense HAT is tilted. Tilt your Sense HAT so that the pitch is between 270 and 315 degrees. You should see that your character moves to the right, but keeps going off the display! You will also see an error, because the character s x position goes above 7, which is not a valid position on the display. 10

To fix this, you only want to move your character to the right if its current position is less than 7. Test your improved code, and you should now see that your character moves until it gets to the right side of the display. We also want to move your character to the left when the pitch is between 45 and 90 degrees. Add this code to move your character to the left if the pitch is between 45 and 90, but only if the character isn t already at the far left of 11

the display. Test your code to make sure that you can tilt your character back to the left. Next, let s add code to change your character s y-position, moving it down when the roll value is between 45 and 90. test this code to see if you can tilt the Sense HAT to move your character down. If you want to slow your game down, you can add short sleep at the end of your while True: loop. 12

Challenge: Moving up! Can you add code to move your character up (by changing your chary variable by -1 ) when the roll is between 270 and 315? The code you ll need to add will be very similar to the code for moving your character to the left. Step 5: Going back to the start Let s put your character back to the start when it falls off the path. Activity Checklist You may have noticed that nothing happens when the character falls off the path. 13

To fix this, we re going to send the character back to the start if they re standing on a black pixel. Let s start by getting the colour of the pixel the character has moved to. If the colour of the current pixel is black, then send the character back to the start. Test your code and you should see your character move back to the start if they fall off the path. 14

Challenge: Changing the difficulty Ask some friends to test your game. Did they find it too easy or too hard? If so, you could make some changes: Change the path the character has to follow; Change the pitch and roll values that move your character; Add a short or longer sleep at the end of your loop. 15