Skip to content

Commit 2ef2249

Browse files
Small fixes, removed build since we're using RTD
2 parents 8e984a6 + bc18fff commit 2ef2249

File tree

102 files changed

+185
-19156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+185
-19156
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.idea
2+
docs/build
23
.DS_Store

Challenges/Brownian Motion/script.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ class Particle {
88
}
99

1010
check_bounds() {
11-
if (this.position.x >= width - this.size || this.position.x <= this.size) {
11+
if (this.position.x >= width - this.size ||
12+
this.position.x <= this.size) {
1213
this.velocity.x *= -1;
1314
}
1415

15-
if (this.position.y >= height - this.size || this.position.y <= this.size) {
16+
if (this.position.y >= height - this.size ||
17+
this.position.y <= this.size) {
1618
this.velocity.y *= -1;
1719
}
1820
}
@@ -29,7 +31,8 @@ class Particle {
2931

3032
draw() {
3133
fill(this.color);
32-
ellipse(this.position.x, this.position.y, this.size * 2, this.size * 2);
34+
ellipse(this.position.x, this.position.y,
35+
this.size * 2, this.size * 2);
3336
}
3437
}
3538

@@ -41,12 +44,14 @@ function setup() {
4144

4245
// Create new particles with random properties and store references to them
4346
for (let i = 0; i < 10; i++) {
44-
particles.push(new Particle(
45-
createVector(random(100, width - 100), random(100, height - 100)),
46-
createVector(random(-5, 5), random(-5, 5)),
47-
random(20, 50),
48-
color(random(255), random(255), random(255))
49-
));
47+
particles.push(
48+
new Particle(
49+
createVector(random(100, width - 100), random(100, height - 100)),
50+
createVector(random(-5, 5), random(-5, 5)),
51+
random(20, 50),
52+
color(random(255), random(255), random(255))
53+
)
54+
);
5055
}
5156
}
5257

Lessons/01 Drawing/script.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@ function setup() {
44

55
function draw() {
66
// Draw a line
7-
line(0, 0, 400, 400);
7+
// line(0, 0, 400, 400);
88

99
// Draw a circle
1010
// ellipse(200, 200, 200, 200);
11-
11+
ellipse(400, 400, 200, 200)
1212

1313
// Draw a square
1414
// rect(200, 200, 200, 200);
15-
15+
rect(200, 200, 200, 200);
1616

1717
// Draw a line
1818
// line(0, 0, 300, 300);
19+
line(0, 0, 300, 300);
20+
stroke(100); //width of line
1921

2022
// Draw a colored circle
21-
// fill(0, 255, 100);
22-
// ellipse(200, 200, 200, 200);
23+
fill(0, 255, 100);
24+
ellipse(200, 200, 200, 200);
2325
}

Lessons/02 Variables/index.html

Lines changed: 0 additions & 12 deletions
This file was deleted.

Lessons/02 Variables/script.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

Lessons/03 Draw/script.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ let y = 255;
77
let radius = 250;
88

99
function draw() {
10-
ellipse(x, y, radius, radius);
10+
//background(0);
11+
//ellipse(x, y, radius, radius);
1112
// Every time draw is called, x is updated to 2 + its initial value
12-
x = x + 2;
13+
// x = x + 2;
1314

1415

1516
// Background allows us to set a background color
@@ -19,8 +20,8 @@ function draw() {
1920

2021

2122
// We can also change colors using variables
22-
// background(255);
23-
// fill(x, y - x, 0);
24-
// ellipse(x, y, radius, radius);
25-
// x = x + 1;
23+
background(255);
24+
fill(x, y - x, x);
25+
ellipse(x, y, radius, radius);
26+
x = x + 1;
2627
}

Lessons/04 Conditionals/index.html

Lines changed: 0 additions & 12 deletions
This file was deleted.

Lessons/04 Conditionals/script.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

Lessons/05 Loops/script.js

Lines changed: 113 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,122 @@
11
function setup() {
2-
createCanvas(1000, 500);
2+
createCanvas(1000, 600);
33
}
44

5-
let x = 0;
6-
let y = 255;
7-
let radius = 250;
5+
// function ell(a) {
6+
// ellipse(100 * a, 100, 50, 50);
7+
// }
8+
//
9+
// function add(a, b) {
10+
// let answer = a + b;
11+
// return answer;
12+
// }
13+
//
14+
// let sum = add(10, 5);
15+
//
16+
817

9-
function draw() {
10-
ellipse(x, y, radius, radius);
11-
x = x + 2;
1218

19+
// let xchange = 10;
20+
// let ychange = 10;
21+
// let x = 100;
22+
// let y = 100;
23+
// let r = 50;
24+
// function draw() {
25+
// background(0);
26+
// ellipse(x, y, r*2, r*2);
27+
// x = x + xchange;
28+
// y = y + ychange;
29+
//
30+
// fill(255);
31+
// if (x >= 1000 || x < r) {
32+
// xchange = -xchange
33+
// }
34+
// if (y >= 600 || y < r) {
35+
// ychange = -ychange
36+
// }
37+
// if (mouseIsPressed) {
38+
// x = mouseX;
39+
// y = mouseY;
40+
// }
41+
//
42+
// }
1343

14-
// Background allows us to set a background color
15-
// background(255);
16-
// ellipse(x, y, radius, radius);
17-
// x = x + 2;
1844

45+
let change = 5;
46+
let x = 0;
47+
function draw() {
48+
background(0);
49+
if (x >= 1000) {
50+
change = -5;
51+
}
52+
else if (x <= 0) {
53+
change = 5;
54+
}
55+
x = x + change;
1956

20-
// We can also change colors using variables
21-
// background(255);
22-
// fill(x, y - x, 0);
23-
// ellipse(x, y, radius, radius);
24-
// x = x + 1;
57+
ellipse(x, 100, 100, 100);
2558
}
59+
60+
61+
62+
63+
64+
//
65+
//
66+
//
67+
//
68+
//
69+
//
70+
// let i = 10;
71+
//
72+
// while (i < 20) {
73+
// ellipse(10, 10, 10, 10);
74+
// }
75+
//
76+
//
77+
//
78+
// let i = 11;
79+
//
80+
// if (i > 5) {
81+
// if (i > 10) {
82+
// ellipse(100, 100, 100, 100);
83+
// }
84+
// else if (i > 6) {
85+
// ellipse(50, 50, 50, 50);
86+
// }
87+
// else {
88+
// ellipse(25, 25, 25, 25);
89+
// }
90+
// }
91+
//
92+
// let j = 9;
93+
// for (let i = 0; j < 10; i++) {
94+
// ellipse(50, 50, 50, 50);
95+
// }
96+
//
97+
//
98+
//
99+
// let i = 0;
100+
// let j = 0;
101+
// for (; i < 10; j++) {
102+
// ellipse(50, 50, 50, 50);
103+
// }
104+
//
105+
//
106+
// let i = 10;
107+
// let j = i;
108+
//
109+
// i = i + 10;
110+
// // What is j right now?
111+
//
112+
// j = j + 5
113+
// // What is j right now?
114+
//
115+
// j = i
116+
// // What is j now?
117+
//
118+
//
119+
//
120+
//
121+
//
122+
//

Lessons/07 Classes and Objects/script.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,30 @@ class Character {
2222
}
2323
}
2424

25-
function draw() {
25+
let Dora = new Character("Dora the Explorer", "Female", 0, 100, 100)
2626

27+
28+
class Ball {
29+
constructor(position, speed, radius, color) {
30+
this.position = position;
31+
this.speed = speed;
32+
this.radius = radius;
33+
this.color = color;
34+
}
35+
36+
check_walls() {
37+
if (this.position.x >= width) {
38+
this.speed = -this.speed;
39+
}
40+
41+
if (this.position.x <= 0) {
42+
this.speed = -this.speed;
43+
}
44+
}
2745
}
46+
47+
48+
49+
let Ball1 = new Ball(10, 10, 10, 50, (10, 20, 30))
50+
51+
Ball1.check_walls()

0 commit comments

Comments
 (0)