School of Computer Science Space School 2015 Programming a Lunar Lander Game.

Slides:



Advertisements
Similar presentations
Create a Simple Game in Scratch
Advertisements

Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
Create a Simple Game in Scratch
Scratch is a Visual Programming Language
Mission Technology Introduction to Scratch! June 2007.
Harry Potter Scratch Game
A Christmas Scratch game
Code Club Session 3 Shark Eats Fish. Picture of finished product here.
Write Your First Computer Game!. Coding: Programming Languages Just like you can speak Chinese to someone who understands Chinese to tell them what to.
Learn… Create… Program. Manipulation of Multiple Media Connects with youth culture Scratch is a new graphical programming language designed to support.
Fish Chomp. The screen where you can see what happens when you play your game is called the STAGE. The SCRIPT BANK is where the types of instructions.
Every week: Sign in at the door If you are new: Fill in Registration Form Ask a Mentor how to get started Make sure you are on the Athenry Parents/Kids.
Scratch the Cat. Object Oriented Programing Writing computer programs Based on Objects Instead of Actions Based on Data Instead of Logic.
Introduction to Scratch!
Using MIT Scratch for Programming and Control Exercise 3 Ball Game Year 9 ICT Autumn Term 2007.
We will be creating a spaceship that simulates real movements in space. The spaceship will fire a laser beam that can destroy targets. The spaceship will.
2015 CSE/EGR Summer Camps 1 Computer Science Concepts 1. What is an algorithm? 2. Binary information coding 3. Programming concepts via Scratch Designed.
Fish Chomp. The screen where you can see what happens when you play your game is called the STAGE. The SCRIPT BANK is where the types of instructions.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.
Image #1 Getting Started
Scratch Another computer programming language Developed by MIT in 2003
Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008.
Computer Programming Modeling a Passive Solar Home.
Monday, October 26 th Entry Task Write two questions you have about chapter 4 and/or the test. Schedule: Chapter 4 quiz 19.1 Electric charge Homework:
Variables and Random Numbers Computer App Session 4.
By Mr. Putnam. In Catfall, the goal of the game is to touch the falling cats with the mouse. Every time you touch a cat, your score goes up by one point.
Marble Racer. The screen where you can see what happens when you play your game is called the STAGE. The SCRIPT BANK is where the types of instructions.
Using MIT Scratch for Programming and Control Exercise 1 Creating movement Year 11 DTG 2012.
How to create a sprite Delete a sprite (e.g. the cat) by right clicking on it and choosing delete. Go to the bottom right hand corner of the stage and.
Using MIT Scratch for Programming and Control Exercise 4 – Cat and Dog game Year 9 ICT Autumn Term 2007.
How to create a basic game in Scratch. The Scratch Stage The Scratch stage is 480 pixels wide and 360 pixels high x increasesx decreases.
Today's Ninja Challenge: Write Your First Computer Game!
ICT/COMPUTING RULES Only use software allowed by the teacher
Computer Programming Modeling a Passive Solar Home.
Teaching Kids Programming with Chromebook Digital Convergence Lab, NIU.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
Introducing Scratch Learning resources for the implementation of the scenario
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
Review for Final June 13, 2016.
Scratch Programming Cards
Scratch Helicopter Game
Create a Halloween Computer Game in Scratch
Commands in Scratch.mit.edu
Broadcasting (Adding a new level)
Games Programming in Scratch
Scratch for Interactivity
Scratch Unit Overview We are going to look at computer programming and how to create your very own computer game The piece of software we will be using.
Scratch – Simple Programming
Scratch for Interactivity
Loopy Motion Control.
Introduction to Object-Oriented Programming
Introduction to.
Learn… Create… Program
Scratch – Simple Programming
Go to =>
Learn… Create… Program
Welcome to SCRATCH.
Go to =>
Go to =>
Image #1 Getting Started
Game Over Module 4 Lesson 2.
Learn… Create… Program
Learn… Create… Program
Creating a Simple Game in Scratch
CSC 221: Introduction to Programming Fall 2018
Catch Game Cards Catch Game Cards Make a Card Go to the Top Fall Down
Scratch – Simple Programming
Presentation transcript:

School of Computer Science Space School 2015 Programming a Lunar Lander Game

School of Computer Science Programming Program –Series of instruction for a computer to follow Programming Language –Precise language designed to give instructions to computers –Very strict rules and vocabulary –Can be read and understood by people –May need to be compiled first so computer can understand it

School of Computer Science Programming Languages In Space missions –Apollo: AGC Assembly –Space Shuttle: HAL/S –Ariane 5: ADA At St Andrews –First year: Java –Second year: C, Haskell, assembly language –Third & Fourth year: Depends on chosen modules After graduation –Whatever your employer decides! Today –Scratch

School of Computer Science Your task Write a simple Lunar Lander Game –Learn how to build a program in Scratch –Become familiar with some basic programming structures –Understand the impact of changes in code on behaviour of program –And of course… Have some fun!

School of Computer Science What is Scratch? Visual Programming Language –Drag-and-drop –Easy to learn –Powerful Create –Interactive stories –Games –Animations

School of Computer Science How Does Scratch work? Create Backdrops –Still background images Create Sprites –Images / characters Control each sprite with a script –Drag-and-drop blocks to build your script –Blocks fit together like jigsaw pieces –Almost no typing! Run your program –Watch the results on the stage

School of Computer Science Stage Sprites Blocks Script Scratch Editor Backdrops

School of Computer Science Lunar Lander Backdrop Select the Space Theme Choose the space backdrop Find the Backdrops section –bottom left of the window Choose backdrop from library

School of Computer Science Sprites Find the Sprites section Remove the cat sprite –Right-click -> delete Choose sprite from library Select the Space Theme Choose the Spaceship Select the Things Category Choose the Rocks

School of Computer Science Sprites (2) Add 3 more Rocks Paint your own landing pad Draw 2 short horizontal lines –Choose 2 bright colours

School of Computer Science Sprites (3) Arrange the sprites on the stage Shrink the Spaceship –Select Shrink from the toolbar –Click on the Spaceship on the stage

School of Computer Science Moving the Spaceship Want to simulate what it is like to move in space Activate lateral thrusters to move ship left or right –Will not stop until it hits something! Activate vertical thrusters to move ship upwards –Has to fight against gravity –With no thrust it will fall to the ground faster and faster! The more thrust the faster the movement

School of Computer Science Moving the Spaceship Need to store: –Our lateral movement –Our vertical movement When left/right arrow is pressed –Decrease/increase the lateral movement When up arrow is pressed –Increase the vertical movement As time passes –Decrease the vertical movement to simulate gravity

School of Computer Science Adding Script Make sure the Spaceship is selected Make sure the Scripts tab is selected

School of Computer Science Adding Variables Make a new variable to store lateral thrust Select Data –Click Make a Variable –Type lateral_thrust –Click OK Make another new variable to store vertical thrust

School of Computer Science Vertical Movement: Gravity Start program when green flag is pressed Select Events –Drag-and-drop When clicked onto the script panel Select Data –Drag-and-drop Set vertical_thrust to 0 Select Control –Drag-and-drop a forever block

School of Computer Science Vertical Movement: Gravity (2) Select Data –Drag-and-drop Change vertical_thrust by 1 –Change value to -0.1 Select Motion –Drag-and-drop Change y by 10 Select Data –Drag-and-drop vertical_thrust Run your program by clicking the green flag above the Stage

School of Computer Science Vertical Movement: Thrust Move up when up arrow is pressed Select Events –Drag-and-drop When space key pressed –Change to up arrow Select Data –Drag-and-drop change vertical_thrust by 1 –Change value to 0.5 Run your program –press up arrow to see what happens!

School of Computer Science Lateral Movement Move sideways when left or right arrow is pressed Select Data –Drag-and-drop Set vertical_thrust to 0 –Change to lateral_thrust Select Motion –Drag-and-drop Change x by 10 Select Data –Drag-and-drop lateral_thrust

School of Computer Science Lateral Movement: Left Move left when left arrow is pressed Select Events –Drag-and-drop When space key pressed –Change space to left arrow Select Data –Drag-and-drop change vertical_thrust by 1 –Change values to lateral_thrust and -0.5 Run your program –press left arrow to see what happens!

School of Computer Science Lateral Movement: Right Move right when right arrow is pressed Select Events –Drag-and-drop When space key pressed –Change space to right arrow Select Data –Drag-and-drop change vertical_thrust by 1 –Change values to lateral_thrust and 0.5 Run your program –press right arrow to see what happens!

School of Computer Science Game Over So far… –Ship falls with gravity –Ship controlled with up, left & right arrow keys Game never finishes –forever block keeps going forever Need to stop repeating once our end conditions are met –Ship lands on landing pad - Win –Ship crashes into rocks - Lose

School of Computer Science You Win! End game when ship lands on landing pad Drag-and drop blocks out of forever Drag-and-drop the forever from script panel to blocks panel Select Control –Drag-and-drop repeat until Drag-and-drop blocks into repeat until

School of Computer Science You Win! (2) Select Sensing –Drag-and-drop touching color –Click on the little coloured box –Click on the bottom colour of your landing pad Select Looks –Drag-and-drop Say Hello! –Change to Yay! You win! Run your program –Try to land on the pad

School of Computer Science You Lose! End game when ship hits rocks Select Operators –Drag-and-drop or onto repeat until –Drag-and-drop touching color onto or

School of Computer Science You Lose! (2) Select Sensing –Drag-and-drop touching color –Click on the little coloured box –Click on the light-grey of the rocks

School of Computer Science You Lose! (3) Select Control –Drag-and-drop if then else –Duplicate touching color –Drag-and-drop onto if then else Select Looks –Drag-and-drop Say Hello! –Change to Oh No! You crashed!

School of Computer Science Finished!

School of Computer Science Challenges See if you can do any of the following: Make sure the ship is at the top each time the game starts Make the ship drift to the left or right when the game starts Only say You Win if the ship’s vertical speed is less than 2 Make ship use fuel – when you run out you cannot use thrusters Add an alien flying across the screen – if the ship hits it you lose

School of Computer Science Hints Make sure the ship is at the top each time the game starts –Hint: set the ship’s y before the repeat until Make the ship drift to the left or right when the game starts –Hint: set lateral thrust to a non-zero number before the repeat until Only say You Win if the ship’s vertical speed is less than 2 –Hint: you need another if then else after the repeat until

School of Computer Science Hints Make ship use fuel – when you run out you cannot use thrusters –Hint: you need another variable. Check it before changing thrust and reduce it after you change thrust Add an alien flying across the screen – if the ship hits it you lose –Hint: you need another sprite with its own script to make it move. –Hint: Add another condition to the spaceships repeat until to check whether it is touching the alien sprite