User Tools

Site Tools


shooty_ships

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
shooty_ships [2023/11/06 00:59] – created appledogshooty_ships [2023/11/06 01:02] (current) appledog
Line 3: Line 3:
 * This took place before we began learning python but after we had studied PHP. * This took place before we began learning python but after we had studied PHP.
  
 +== fi.html
 <Code:Javascript|fi.html> <Code:Javascript|fi.html>
 <!DOCTYPE HTML> <!DOCTYPE HTML>
Line 446: Line 447:
 </body> </body>
 </html> </html>
 +</Code>
 +
 +== 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.
 +
 +<Code:Javascript|mygames.js>
 +
 +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");
 +}
 +
 +</Code>
 +
 +== theme.css
 +<Code:CSS>
 +.title {
 +  font-size: 20px;
 +}
 +
 +.mytd {
 +    border: 1px solid black;
 +    height: 50px;
 +    width: 50px;
 +}
 +
 </Code> </Code>
shooty_ships.1699232361.txt.gz · Last modified: 2023/11/06 00:59 by appledog

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki