forked from paulorpdl/codigoTaller2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcirculo.js
50 lines (47 loc) · 1.14 KB
/
circulo.js
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
function Circulo(juego, x, y ) {
this.juego = juego;
this.x = x;
this.y = y;
this.remover = false;
this.rev = false;
this.revy = false;
}
Circulo.prototype.actualizar = function() {
if (this.x < this.juego.ctx.canvas.width-50 && this.rev == false) {
this.x += 10;
}
else if (this.x == this.juego.ctx.canvas.width-50 && this.rev == false) {
this.rev = true;
this.x -= 10;
}
else if (this.x > 50 && this.rev == true) {
this.x -= 10;
}
else if (this.x == 50 && this.rev == true) {
this.rev = false;
this.x += 10;
}
/*if (this.y > this.juego.ctx.canvas.height+50 && this.revy == false) {
this.y -= 10;
}
else if (this.y == this.juego.ctx.canvas.height+50 && this.revy == false) {
this.revy = true;
this.y += 10;
}
else if (this.y > 50 && this.revy == true) {
this.y += 10;
}
else if (this.y == 50 && this.revy == true) {
this.revy = false;
this.y -= 10;
}*/
};
Circulo.prototype.dibujar = function(ctx) {
ctx.beginPath();
ctx.strokeStyle = "blue";
ctx.fillStyle = "black";
ctx.arc(this.x, this.y, 50, 0, Math.PI*2, false);
ctx.stroke();
ctx.fill();
ctx.closePath();
};