= Shooty Ships * Roger and I created this game over 4 or 5 classes. It was an evolution of the bouncy balls demo series, itself which took 4 or 5 classes to cover. * This took place before we began learning python but after we had studied PHP. == fi.html Fight IO
by Appledog


== mygames.js You will also need this, which is a small library of functions we came up with as we learned javascript. The original idea of this was to help Roger understand how to make a library of functions in javascript. function rotate(ox, oy, x, y, r) { var xDiff = x - ox; var yDiff = y - oy; var rot = Math.atan2(xDiff, yDiff); var newRot = rot + (r * 3.141592653 / 180); var dx = Math.cos(newRot); var dy = Math.sin(newRot); var dist = Math.sqrt((xDiff*xDiff)+(yDiff*yDiff)); return { x: ox + (dx * dist), y: oy + (dy * dist) } } function getMousePos(canvas, event) { var rect = canvas.getBoundingClientRect(); return { x: event.clientX - rect.left, y: event.clientY - rect.top }; } function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } function getRandomColor() { var color = ''; while (color.length != 7) { color = "#" + Math.random().toString(16).slice(2, 8); } return color; } function colorScreen(c) { ctx.fillStyle = c; ctx.fillRect(0, 0, MAX_W, MAX_H); } function clearScreen() { colorScreen("#FFFFFF"); } == theme.css .title { font-size: 20px; } .mytd { border: 1px solid black; height: 50px; width: 50px; }