-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdraw-test.js
More file actions
64 lines (52 loc) · 1.45 KB
/
draw-test.js
File metadata and controls
64 lines (52 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// var rectangle = {
// x: 20,
// y: 10,
// width: 40,
// height: 40,
// }
// var triangle = {
// x: 20,
// y: 100,
// width: 40,
// height: 40,
// }
// var circle = {
// x: 20,
// y: 190,
// width: 40,
// height: 40,
// }
// window.requestAnimFrame = (function(callback) {
// return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame ||
// function(callback) {
// window.setTimeout(callback, 1000 / 60);
// };
// })();
// function animate(myTriangle, canvas, context, startTime) {
// // update
// var time = (new Date()).getTime() - startTime;
// var linearSpeed = 100;
// // pixels / second
// var newX = linearSpeed * time / 1000;
// if(newX < canvas.width - myTriangle.width) {
// myTriangle.x = newX;
// }
// // clear
// context.clearRect(0, 0, canvas.width, canvas.height);
// drawTriangle(triangle, context);
// // request new frame
// requestAnimFrame(function() {
// animate(myTriangle, canvas, context, startTime);
// });
// }
// drawTriangle(triangle, ctx);
// // ctx.save();
// drawCircle(circle, ctx);
// drawRectangle(rectangle, ctx);
// setTimeout(function() {
// var startTime = (new Date()).getTime();
// animate(triangle, board, ctx, startTime);
// }, 1000);
function moveByDirection(actor, x, y) {
actor.move(actor.get_x() + x * 10, actor.get_y() + y * 10);
}