-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsketch.js
More file actions
58 lines (45 loc) · 1.17 KB
/
sketch.js
File metadata and controls
58 lines (45 loc) · 1.17 KB
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
//Shortcuts
const $ = function( id ) { return document.getElementById( id ); };
const random = function ( array ) { return array[Math.floor(Math.random()*array.length)]; };
//Elements for the story
let persos = ["Adventurous Billy", "Shy Mary", "Big Gorilla"];
let objets = ["Improvised Tent", "Eternal Campfire"];
//Story Class
class Story{
setSub(){
this.subject = random(persos);
$('subject').innerHTML = this.subject;
return this;
}
setGG(){
this.goodguy = random(persos);
$('goodguy').innerHTML = this.goodguy;
return this;
}
setBG(){
this.badguy = random(persos);
$('badguy').innerHTML = this.badguy
return this;
}
setFriend(){
this.friend = random(objets);
$('friend').innerHTML = this.friend;
return this;
}
setSol(){
this.solution = random(objets);
$('solution').innerHTML = this.solution;
return this;
}
}
//Declaration nouvelle story
const story = new Story();
//Fonctions
function setup(){
noCanvas();
load();
}
function load(){
story.setSub().setGG().setBG().setFriend().setSol();
}
//help chaining understanding: https://schier.co/blog/2013/11/14/method-chaining-in-javascript.html