Real MATH

This commit is contained in:
Noah Moroze 2014-05-17 11:03:11 -04:00
parent 66e0c1c2b6
commit 32907eef36
3 changed files with 13 additions and 2 deletions

View file

@ -7,9 +7,19 @@ var colors = [
];
var Clock = function(sides) {
this.position = 0;
this.sides = sides;
this.blocks = [];
for(var i=0; i<sides; i++) {
this.blocks.push([]);
}
this.addBlock = function(block) {
this.blocks[this.position].push(block);
}
this.rotate = function(steps) {
this.position += steps;
this.position = Math.abs(((this.position%sides)+this.position) % sides);
}
}

View file

@ -7,8 +7,9 @@
<center>
<canvas id="canvas"></canvas>
</center>
<script src="entities.js"></script>
<script src="main.js"></script>
<script src="math.js"></script>
</body>
</html>

View file

@ -1,5 +1,5 @@
function rotatePoint(x, y, theta) {
var thetaRad = theta * 0.0174532925;
var thetaRad = theta * (Math.PI / 180);
var rotX = Math.cos(thetaRad) * x - Math.sin(thetaRad) * y;
var rotY = Math.sin(thetaRad) * x + Math.cos(thetaRad) * y;