-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes.txt
136 lines (83 loc) · 2.74 KB
/
notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
Learning JavaScript by Building a Basic Tetris Game
by Ania Kubow
https://www.youtube.com/watch?v=rAUn1Lom6dw
During the intro she was quick to offer help in YouTube comments or Twitter
Intro:
Setup IDE
- she uses Atom and installs Shell Command
- show invisibles, show indent guide, use soft tabs
- she downloaded and installed a number of extensions around 5:00 mark
- linter-js-standard
Initial Code:
app.js:
The DOMContentLoaded event fires when the initial html document has been completely loaded and parsed; this is without waiting for the css, images, etc.
Showed Google Sheet with mock-up of page.
- 20x10 grid
- need 200 divs
- could have used a for loop in js to build.
CSS Section:
by default divs stack up down the page
- to get them to fill our yellow outter div we need to use flex-bots (sp?)
Explaning variables:
variables have global or local scope
const and let
let vs var
let allows you to declare vars with a block scope
var - function + global scoped
let - block scoped
const - block scoped constant
Working with Arrays:
store lists of data
each element has an index
first index is 0; last is array.length-1
Arrow Functions and forEach:
- new in es6
old way:
hello = function () {
return 'Hello World'
}
new way:
hello = () => 'Hello World'
hello = (val) => 'Hello World' + val
hello = val => 'Hello World' + val
itemArray.forEach( item => item + 2)
forEach Call Back:
.forEach( value, index, object )
Example:
let names = [ 'Erik', 'Ania', 'Dave' ]
names.forEach( name => {
console.log(name + ' is the best')
})
Drawing Tetrominoes using classList.add():
Math.random()
.length // how long array is
Math.floor() // round down to nearest integer
Times and Intervals:
Covered the interval concept
if/else if/else
New one for me:
itemArray.some(false, true, false) // looking for a true element in array
Using Modules to define our place on the grid:
just wrote code
Keycodes and events:
Keycode.info // website with all keyboard event codes
Choosing Items from Arrays:
easy
Displaying the "next up" tetromino:
Adding a start and pause game function:
This lesson was where we added logic to the start button to run the game
Splice():
Used to remove, replace or add items to arrays
It mutates the array
itemArray.splice( startIndex, deleteCount )
itemArray.splice( startIndex, 0 ) // with a deleteCount of 0, nothing gets deleted
itemArray.splice( startIndex ) // removes everything after index
all calls to splice return what was spiced *and* modify the array
Splice(), concat(), and appendChild():
concat: merge 2 arrays togeter
Game over using some() and innerHTML:
write the gameOver()
Assigning colors to our Tetrominoes:
Contact Ania Kubow if need help or to show off project
@ania_kubow
Ania Kubow - YouTube