Skip to content

Commit

Permalink
newCube
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonTod committed Feb 23, 2016
1 parent 7c594fa commit 3329765
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions js/rubik.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* Created by Simon on 23/02/2016.
*/
function newPiece(colors) {
var object = {colorX:colors[0], colorY:colors[1], colorZ:colors[2]};
return object;
}


function newCube() {
var cube = [];
for (var i=0; i<3; i++) {
cube[i] = [];
for (var j = 0; j < 3; j++) {
cube[i][j] = [null, null, null];
}
}
// bottom stage
var z = 'yellow';
var y = 'green';
cube[0][0][0] = newPiece(['orange',y,z]);
cube[1][0][0] = newPiece([null,y,z]);
cube[2][0][0] = newPiece(['red',y,z]);
y = null;
cube[0][1][0] = newPiece(['orange',y,z]);
cube[1][1][0] = newPiece([null,y,z]);
cube[2][1][0] = newPiece(['red',y,z]);
y = 'blue';
cube[0][2][0] = newPiece(['orange',y,z]);
cube[1][2][0] = newPiece([null,y,z]);
cube[2][2][0] = newPiece(['red',y,z]);

// middle stage
z = null;
y = 'green';
cube[0][0][1] = newPiece(['orange',y,z]);
cube[1][0][1] = newPiece([null,y,z]);
cube[2][0][1] = newPiece(['red',y,z]);
y = null;
cube[0][1][1] = newPiece(['orange',y,z]);
cube[2][1][1] = newPiece(['red',y,z]);
y = 'blue';
cube[0][2][1] = newPiece(['orange',y,z]);
cube[1][2][1] = newPiece([null,y,z]);
cube[2][2][1] = newPiece(['red',y,z]);

// top stage
z = 'white';
y = 'green';
cube[0][0][2] = newPiece(['orange',y,z]);
cube[1][0][2] = newPiece([null,y,z]);
cube[2][0][2] = newPiece(['red',y,z]);
y = null;
cube[0][1][2] = newPiece(['orange',y,z]);
cube[1][1][2] = newPiece([null,y,z]);
cube[2][1][2] = newPiece(['red',y,z]);
y = 'blue';
cube[0][2][2] = newPiece(['orange',y,z]);
cube[1][2][2] = newPiece([null,y,z]);
cube[2][2][2] = newPiece(['red',y,z]);

return cube;
}


8 changes: 8 additions & 0 deletions js/scripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Created by Simon on 23/02/2016.
* scripts test
*/

var mycube = newCube();

document.getElementById('cube').innerText = mycube;
14 changes: 14 additions & 0 deletions rubik.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Rukib's Cube</title>
</head>
<body>

<div id="cube"></div>

<script src="js/rubik.js"></script>
<script src="js/scripts.js"></script>
</body>
</html>

0 comments on commit 3329765

Please sign in to comment.