pxt-calliope/docs/reference/js/lessons/meteorite.md

100 lines
4.4 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# meteorite lesson
2016-04-02 01:22:47 +02:00
a game in which you must dodge the meteorites with your ship.
2016-03-26 00:47:20 +01:00
## Topic
Functions
## Quick Links
* [tutorial](/microbit/lessons/meteorite/tutorial)
* [quiz](/microbit/lessons/meteorite/quiz)
* [quiz answers](/microbit/lessons/meteorite/quiz-answers)
## Class
Year 7
## Prior learning/place of lesson in scheme of work
Learn how to create **functions**, `function()` that perform a specific task and returns a result. We will be learning how to create a meteorite game using functions, forever loop, global variables, for loop, input on button pressed, if statements, math random, input on shake as well as simple commands, such as show string, show number, and pause.
## Documentation
* **function** : [read more...](/microbit/js/function)
* **call** : [read more...](/microbit/js/call)
* **global variable** : [read more...](/microbit/js/data)
* **arithmetic operators** : [read more...](/microbit/reference/types/number)
* **math random** : [read more...](/microbit/js/math)
* **forever** : [read more...](/microbit/reference/basic/forever)
* **for** : [read more...](/microbit/reference/loops/for)
* **fade out** : [read more...](/microbit/reference/led/fade-out)
* **fade in** : [read more...](/microbit/reference/led/fade-in)
* **on button pressed** : [read more...](/microbit/reference/input/on-button-pressed)
* **if** : [read more...](/microbit/reference/logic/if)
* **show string** : [read more...](/microbit/reference/basic/show-string)
* **show number** : [read more...](/microbit/reference/basic/show-number)
* **show string** : [read more...](/microbit/reference/basic/show-string)
* **plot** : [read more...](/microbit/reference/led/plot)
* **plot all** : [read more...](/microbit/reference/led/plot-all)
* **pause** : [read more...](/microbit/reference/basic/pause)
## Objectives
* learn how to create a function as a unit of code that performs a specific task and returns a result
* learn how to call an existing function in your script
* learn how to create a global variable as a place where you can store data so that you can use it later in your code, accessible across functions and in nested code blocks
* learn how arithmetic operators operate on numbers and return a number
* learn how to return a random number
* learn how to repeat code in the background forever
* learn how to gradually decrease the LED screen brightness until the LED lights are turned off
* learn how to gradually increase the LED screen brightness until the LED lights are turned on
* learn how to conditionally run code depending on whether a condition is true or not
* learn how to run code when an input button is pressed
* learn how to show a number on the micro:bit's LED screen
* learn how to show a string on the micro:bit's LED screen
* learn how to turn on a LED light on the LED screen. Learn how to specify which LED using x, y coordinates
* learn how to turn on all the 25 LEDs on the LED screen
* learn how to pause your code for the specified number of milliseconds
## Progression Pathways / Computational Thinking Framework
#### Algorithms
* Designs solutions (algorithms) that use repetition and two-way selection, ie if, then and else.(AL)
* Uses diagrams to express solutions.(AB)
* Uses logical reasoning to predict outputs, showing an awareness of inputs (AL)
* Represents solutions using a structured notation (AL) (AB)
#### Programming & Development
* Creates programs that implement algorithms to achieve given goals (AL)
* Declares and assigns variables(AB)
* Uses post-tested loop e.g.until,and a sequence of selection statements in programs,including an if,then and else statement(AL)
* Understands the difference between, and appropriately uses if and if, then and else statements(AL)
* Uses a variable and relational operators within a loop to govern termination (AL) (GE)
* Uses a range of operators and expressions e.g. Boolean, and applies them in the context of program control. (AL)
* Selects the appropriate data types(AL) (AB
#### Data & Data Representation
* Defines data types: real numbers and Boolean (AB)
Computational Thinking Concept: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation; GE = Generalisation
## Activity
* time: 20 min.
* [tutorial](/microbit/lessons/meteorite/tutorial)
## Extended Activity
* time: 20 min.
* [quiz](/microbit/lessons/meteorite/quiz)
## Homework
* Extended Activity: [quiz](/microbit/lessons/meteorite/quiz)