shooty_ships
                Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| shooty_ships [2023/11/06 00:59] – created appledog | shooty_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 | ||
| < | < | ||
| < | < | ||
| Line 446: | Line 447: | ||
| </ | </ | ||
| </ | </ | ||
| + | </ | ||
| + | |||
| + | == 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, | ||
| + | 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, | ||
| + | var rect = canvas.getBoundingClientRect(); | ||
| + | return { | ||
| + | x: event.clientX - rect.left, | ||
| + | y: event.clientY - rect.top | ||
| + | }; | ||
| + | } | ||
| + | |||
| + | function getRandomInt(min, | ||
| + | return Math.floor(Math.random() * (max - min + 1)) + min; | ||
| + | } | ||
| + | |||
| + | function getRandomColor() { | ||
| + | var color = ''; | ||
| + | while (color.length != 7) { | ||
| + | color = "#" | ||
| + | } | ||
| + | return color; | ||
| + | } | ||
| + | |||
| + | function colorScreen(c) { | ||
| + | ctx.fillStyle = c; | ||
| + | ctx.fillRect(0, | ||
| + | } | ||
| + | |||
| + | function clearScreen() { | ||
| + | colorScreen("# | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | == theme.css | ||
| + | < | ||
| + | .title { | ||
| + | font-size: 20px; | ||
| + | } | ||
| + | |||
| + | .mytd { | ||
| + | border: 1px solid black; | ||
| + | height: 50px; | ||
| + | width: 50px; | ||
| + | } | ||
| + | |||
| </ | </ | ||
shooty_ships.1699232361.txt.gz · Last modified: 2023/11/06 00:59 by appledog
                
                