-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstick.js
More file actions
40 lines (34 loc) · 683 Bytes
/
stick.js
File metadata and controls
40 lines (34 loc) · 683 Bytes
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
//stick
function Stick ()
{
this.image = new Image();
this.image.src = "images/stick1.png";
this.width = 32;
this.height = 32;
this.x = 0;
this.y = 0;
}
Stick.prototype = new Elemento();
Stick.prototype.constructor = Stick;
Stick.prototype.setImg = function(img)
{
this.image.src = img;
}
Stick.prototype.randomPos = function ()
{
var y = Math.floor((Math.random()* (documentHeight - this.height) )+1);
var x = Math.floor((Math.random()* (documentWidth - this.width) )+1);
this.x = x;
this.y = y;
}
Stick.prototype.intervalChangePosition = function(obj, interval)
{
setInterval
(
function()
{
obj.randomPos();
},
interval
);
}