Date | Subject |
---|---|
20 February | Basics |
12 March | Phaser Systems |
2 April | Pixel Art |
16 April | Sound Effects and Music |
18-20 April | Ludum Dare Game Jam |
+
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
// Single line comment
/*
Multiline
comment
*/
// Declaring a variable
let cardboardBox;
// Assigning a value to a variable
cardboardBox = 'cat';
// Declaring and assigning
let answerToUniverseAndEverything = 42;
// Using a variable
cardboardBox;
Data type | Explanation | Example |
---|---|---|
String | Text in quotation marks | let workshopLeader = 'Theo' |
Number | Any number | let one = 1; let pi = 3.14; |
Boolean | True or False, Yes or No, 1 or 0 |
let awesome = true; |
Array | A collection of data | let dataTypes = ['string', 1, false]; |
Object | Everything else | let game = new Phaser.Game(); |
Operator group | Symbols | Explanation | Example |
---|---|---|---|
Arithmetic | +, -, *, / |
Calculations | 2 * 5 + 4; |
Comparison | ===, !==, <, >, <=, >= |
Comparing numbers and objects | one < 2; |
Logical | !, &&, || |
not, and, or | !true; |
Assignment | = |
Assigning to a variable | let answer = 5; |
!false
← True
4 < 3
← False
0 <= 0
← True
1 > 2 - 3 || false && 2 !== 'two'
← True
let result = 2;
if(result < 0) {
// If the expression is true go in this codeblock
alert('The result is negative');
} else if (result > 0) {
// If statements can be chained
alert('The result is positive');
} else {
// If previous expressions are false, go to this codeblock
alert('The result is zero');
}
// A loop expression contains three parts
// initialization; end condition; step action
for (let i = 0; i < 5; i++){
console.log(i);
}
// Function declaration
function multiply(num1, num2) {
let result = num1 * num2;
// This function returns a result
return result;
}
// Calling a function
multiply(2, 5);