previous

page 6

next
scramble.js
function scramble() {
var arr=[];
for (var i=0;i<4;i++) arr[i]=i;
Shuffle(arr);
var i=0;
for (var r=1;r<3;r++) {
for (var c=1;c<3;c++) {
var id=arr[i]; i++;
var el=document.getElementById(id);
el.style.gridRowStart=r;
el.style.gridColumnStart=c;
}
}
}
index.html
<html>
<head>
<title>Jigsaw</title>
<link rel='stylesheet' href='styles.css'>
<script src='library.js'></script>
<script src='pieces.js'></script>
<script src='scramble.js'></script>
</head>
<body>
<div>
<img src='images/squares.png'>
</div>
<br>
<div id='grid'>
<script>pieces(); scramble();</script>
</div>
</body>
</html>
previous
next