Skip to content

Commit

Permalink
Updated teaching material and code
Browse files Browse the repository at this point in the history
  • Loading branch information
noelking committed Mar 9, 2013
1 parent e8d97a6 commit 1a7ea6c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
30 changes: 28 additions & 2 deletions 001 - Balloon Game/002 Time to blow up the balloon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,32 @@ We always add variables to the very top of the page when you open your JavaScrip
see all your variables in the one place. If you do this in every JavaScript file you create, it will make your
life easier as you will know where you have created your variables

#### NOTE
You variable name should explain what the variable is, so when you look
at your code you know straight away what it is.

Create your first function
----
Functions are acivities that do one only. Think of a game every time you press a key
it causes an activity which is handled by the function.

A function has the following rules
* starts with the word function
* then the function name (you can put what ever name you want, no spaces through)
* now put the open and close brackets ()
* add the open backet for your function {
* close your function with }

````javascript
function setup() {

}
````

__NOTE__
If we create variables at the top of file outside functions means these variables can be used anywhere in the javascript.


You file should now look like this.

````javascript
Expand Down Expand Up @@ -328,15 +351,18 @@ To set the balloon width use
balloon.style.width = width + 'px';
````


````javascript
function blow() {
var width = parseInt(balloon.style.width);
width = width + increaseBy;
balloon.style.width = width + 'px';
}
````


Stop the balloon growing
--------
Great are balloon is now huge but who feels its too big? Its time to put a stop to this



Questions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

var balloon;
var increaseBy = 50;
var currentBlow;

function loadGame() {
balloon = document.getElementById("balloon");
Expand Down

0 comments on commit 1a7ea6c

Please sign in to comment.