Skip to content

Commit

Permalink
added prettier to eslint (CodingTrain#1989)
Browse files Browse the repository at this point in the history
  • Loading branch information
duskvirkus authored Dec 13, 2019
1 parent 9ce9148 commit be0b789
Show file tree
Hide file tree
Showing 457 changed files with 3,536 additions and 4,307 deletions.
6 changes: 3 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ module.exports = {
plugins: ['prettier'],
rules: {

// 'prettier/prettier': ['error', {
// singleQuote: true
// }],
'prettier/prettier': ['error', {
singleQuote: true
}],

'no-cond-assign': ['error', 'except-parens'],

Expand Down
5 changes: 2 additions & 3 deletions CodingChallenges/CC_001_StarField/P5/Star.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function Star() {
this.y = random(-height, height);
this.pz = this.z;
}
}
};

this.show = function() {
fill(255);
Expand All @@ -36,6 +36,5 @@ function Star() {

stroke(255);
line(px, py, sx, sy);

}
};
}
19 changes: 12 additions & 7 deletions CodingChallenges/CC_002_MengerSponge/P5/box.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,33 @@
function Box(x, y, z, r) {
this.pos = createVector(x, y, z);
this.r = r;
this.generate = function () {

this.generate = function() {
let boxes = [];
for (let x = -1; x < 2; x++) {
for (let y = -1; y < 2; y++) {
for (let z = -1; z < 2; z++) {
let sum = abs(x) + abs(y) + abs(z);
let newR = this.r / 3;
let newR = this.r / 3;
if (sum > 1) {
let b = new Box(this.pos.x + x * newR, this.pos.y + y * newR, this.pos.z + z * newR, newR);
let b = new Box(
this.pos.x + x * newR,
this.pos.y + y * newR,
this.pos.z + z * newR,
newR
);
boxes.push(b);
}
}
}
}
return boxes;
}
};

this.show = function () {
this.show = function() {
push();
translate(this.pos.x, this.pos.y, this.pos.z);
box(this.r);
pop();
}
};
}
4 changes: 2 additions & 2 deletions CodingChallenges/CC_003_Snake_game/P5/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ function setup() {
}

function pickLocation() {
let cols = floor(width/scl);
let rows = floor(height/scl);
let cols = floor(width / scl);
let rows = floor(height / scl);
food = createVector(floor(random(cols)), floor(random(rows)));
food.mult(scl);
}
Expand Down
21 changes: 10 additions & 11 deletions CodingChallenges/CC_003_Snake_game/P5/snake.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ function Snake() {
this.total = 0;
this.tail = [];

this.eat = function (pos) {
this.eat = function(pos) {
let d = dist(this.x, this.y, pos.x, pos.y);
if (d < 1) {
this.total++;
return true;
} else {
return false;
}
}
};

this.dir = function (x, y) {
this.dir = function(x, y) {
this.xspeed = x;
this.yspeed = y;
}
};

this.death = function () {
this.death = function() {
for (let i = 0; i < this.tail.length; i++) {
let pos = this.tail[i];
let d = dist(this.x, this.y, pos.x, pos.y);
Expand All @@ -36,9 +36,9 @@ function Snake() {
this.tail = [];
}
}
}
};

this.update = function () {
this.update = function() {
for (let i = 0; i < this.tail.length - 1; i++) {
this.tail[i] = this.tail[i + 1];
}
Expand All @@ -51,14 +51,13 @@ function Snake() {

this.x = constrain(this.x, 0, width - scl);
this.y = constrain(this.y, 0, height - scl);
}
};

this.show = function () {
this.show = function() {
fill(255);
for (let i = 0; i < this.tail.length; i++) {
rect(this.tail[i].x, this.tail[i].y, scl, scl);
}
rect(this.x, this.y, scl, scl);

}
};
}
11 changes: 5 additions & 6 deletions CodingChallenges/CC_004_PurpleRain/P5/drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
// http://patreon.com/codingtrain
// Code for: https://youtu.be/KkyIDI6rQJI


function Drop() {
this.x = random(width);
this.y = random(-500, -50);
this.z = random(0, 20);
this.len = map(this.z, 0, 20, 10, 20);
this.yspeed = map(this.z, 0, 20, 1, 20);

this.fall = function () {
this.fall = function() {
this.y = this.y + this.yspeed;
var grav = map(this.z, 0, 20, 0, 0.2);
this.yspeed = this.yspeed + grav;
Expand All @@ -20,12 +19,12 @@ function Drop() {
this.y = random(-200, -100);
this.yspeed = map(this.z, 0, 20, 4, 10);
}
}
};

this.show = function () {
this.show = function() {
var thick = map(this.z, 0, 20, 1, 3);
strokeWeight(thick);
stroke(138, 43, 226);
line(this.x, this.y, this.x, this.y + this.len);
}
}
};
}
11 changes: 5 additions & 6 deletions CodingChallenges/CC_005_Space_invaders/P5/drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ function Drop(x, y) {
this.show = function() {
noStroke();
fill(150, 0, 255);
ellipse(this.x, this.y, this.r*2, this.r*2);
}
ellipse(this.x, this.y, this.r * 2, this.r * 2);
};

this.evaporate = function() {
this.toDelete = true;
}
};

this.hits = function(flower) {
var d = dist(this.x, this.y, flower.x, flower.y);
Expand All @@ -26,10 +26,9 @@ function Drop(x, y) {
} else {
return false;
}
}
};

this.move = function() {
this.y = this.y - 5;
}

};
}
11 changes: 5 additions & 6 deletions CodingChallenges/CC_005_Space_invaders/P5/flower.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@ function Flower(x, y) {

this.grow = function() {
this.r = this.r + 2;
}
};

this.shiftDown = function() {
this.xdir *= -1;
this.y += this.r;
}
};

this.move = function() {
this.x = this.x + this.xdir;
}
};

this.show = function() {
noStroke();
fill(255, 0, 200, 150);
ellipse(this.x, this.y, this.r*2, this.r*2);
}

ellipse(this.x, this.y, this.r * 2, this.r * 2);
};
}
13 changes: 6 additions & 7 deletions CodingChallenges/CC_005_Space_invaders/P5/ship.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@
// Code for: https://youtu.be/biN3v3ef-Y0

function Ship() {
this.x = width/2;
this.x = width / 2;
this.xdir = 0;

this.show = function() {
fill(255);
rectMode(CENTER);
rect(this.x, height-20, 20, 60);
}
rect(this.x, height - 20, 20, 60);
};

this.setDir = function(dir) {
this.xdir = dir;
}
};

this.move = function(dir) {
this.x += this.xdir*5;
}

this.x += this.xdir * 5;
};
}
7 changes: 2 additions & 5 deletions CodingChallenges/CC_005_Space_invaders/P5/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function setup() {
ship = new Ship();
// drop = new Drop(width/2, height/2);
for (var i = 0; i < 6; i++) {
flowers[i] = new Flower(i*80+80, 60);
flowers[i] = new Flower(i * 80 + 80, 60);
}
}

Expand Down Expand Up @@ -48,13 +48,11 @@ function draw() {
}
}

for (var i = drops.length-1; i >= 0; i--) {
for (var i = drops.length - 1; i >= 0; i--) {
if (drops[i].toDelete) {
drops.splice(i, 1);
}
}


}

function keyReleased() {
Expand All @@ -63,7 +61,6 @@ function keyReleased() {
}
}


function keyPressed() {
if (key === ' ') {
var drop = new Drop(ship.x, height);
Expand Down
22 changes: 10 additions & 12 deletions CodingChallenges/CC_006_Mitosis/P5/cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// Code for: https://youtu.be/jxGS3fKPKJA

function Cell(pos, r, c) {

if (pos) {
this.pos = pos.copy();
} else {
Expand All @@ -14,30 +13,29 @@ function Cell(pos, r, c) {
this.r = r || 60;
this.c = c || color(random(100, 255), 0, random(100, 255), 100);

this.clicked = function (x, y) {
this.clicked = function(x, y) {
var d = dist(this.pos.x, this.pos.y, x, y);
if (d < this.r) {
return true;
} else {
return false;
}
}
};

this.mitosis = function () {
this.mitosis = function() {
//this.pos.x += random(-this.r, this.r);
var cell = new Cell(this.pos, this.r * 0.8, this.c);
return cell;
}
};

this.move = function () {
this.move = function() {
var vel = p5.Vector.random2D();
this.pos.add(vel);
}
};

this.show = function () {
this.show = function() {
noStroke();
fill(this.c);
ellipse(this.pos.x, this.pos.y, this.r, this.r)
}

}
ellipse(this.pos.x, this.pos.y, this.r, this.r);
};
}
2 changes: 1 addition & 1 deletion CodingChallenges/CC_006_Mitosis/P5/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ function mousePressed() {
cells.splice(i, 1);
}
}
}
}
Loading

0 comments on commit be0b789

Please sign in to comment.