
previous

page 7
next
The best way to check our work is to use the a values to draw the pieces.
This won't happen in the finished game so I created a test() function and added it to my functions.js.
function test() {
for (id=0;id<100;id++) {
var el=document.getElementById(id);
var a=el.getAttribute('a');
el.src='images/right/'+a+'.png';
}
}
for (id=0;id<100;id++) {
var el=document.getElementById(id);
var a=el.getAttribute('a');
el.src='images/right/'+a+'.png';
}
}
And this is what my index.html looks like right now:
<html>
<head>
<title>Ships</title>
<link rel='stylesheet' href='styles.css'>
<script src='library.js'></script>
<script src='functions.js'></script>
<script src='squares.js'></script>
<script src='seed.js'></script>
</head>
<body>
<script>squares(); seed(); test();</script>
</body>
<html>
<head>
<title>Ships</title>
<link rel='stylesheet' href='styles.css'>
<script src='library.js'></script>
<script src='functions.js'></script>
<script src='squares.js'></script>
<script src='seed.js'></script>
</head>
<body>
<script>squares(); seed(); test();</script>
</body>
<html>
add this to functions.js for later
function get_a(r,c) {
var id=rc2id(r,c);
var el=document.getElementById(id);
return el.getAttribute('a');
}
var id=rc2id(r,c);
var el=document.getElementById(id);
return el.getAttribute('a');
}
previous
next