diff --git a/neomojimixer.js b/neomojimixer.js index ff07864..414b9d5 100644 --- a/neomojimixer.js +++ b/neomojimixer.js @@ -6,11 +6,20 @@ let body = []; let mouth = []; let arms = []; +//FOr all the different colours of the arms there will be each a own arraz +let arms_orange = []; +let arms_blue = []; +let arms_lightgrey = []; +let arms_red = []; +let arms_white = []; +let arms_yellow = []; + //Index to easily find when to roll back to the first/last element in the list let inex_eyes = 0; let index_body = 0; let index_mouth = 0; let index_arms = 0; +let index_color = 0; //shotnames for HTML elements to interact with @@ -56,6 +65,9 @@ function loadParts(parts) { parts.type.mouth.forEach(fillArrayMouth); parts.type.arms.forEach(fillArrayArms); + //find the indexes of each part of the corresponding color and write those into the color arrays + fillArraysArms(); + //Randomize initial view randomize(); @@ -80,36 +92,78 @@ function loadParts(parts) { } function fillArrayEyes(item){ - var name = item.name; - var url = item.url; + let name = item.name; + let url = item.url; eyes.push ([name, url]); //Two dimensional array, Second dimension holds name on index 0 and url at index 1 } function fillArrayBody(item){ - var name = item.name; - var url = item.url; - body.push ([name, url]); //Two dimensional array, Second dimension holds name on index 0 and url at index 1 + let name = item.name; + let url = item.url; + let color = item.color; + body.push ([name, url, color]); //Two dimensional array, Second dimension holds name on index 0 and url at index 1 } function fillArrayMouth(item){ - var name = item.name; - var url = item.url; + let name = item.name; + let url = item.url; mouth.push ([name, url]); //Two dimensional array, Second dimension holds name on index 0 and url at index 1 } function fillArrayArms(item){ - var name = item.name; - var url = item.url; - arms.push ([name, url]); //Two dimensional array, Second dimension holds name on index 0 and url at index 1 + let name = item.name; + let url = item.url; + let color = item.color; + arms.push ([name, url, color]); //Two dimensional array, Second dimension holds name on index 0 and url at index 1 } +function fillArraysArms(){ + for (let i=0; i