Real MATH
This commit is contained in:
parent
66e0c1c2b6
commit
32907eef36
3 changed files with 13 additions and 2 deletions
10
entities.js
10
entities.js
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
2
math.js
2
math.js
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue