-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWall.js
68 lines (66 loc) · 1.54 KB
/
Wall.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function coordonates()
{
this.x;
this.y;
}
function Wall()
{
// solid object
// the player cannot pass this layer
// the gravity must be stoped when an object wall touches a player
// after some time, the wall must disspear
// this object is formed from a lot of circles on the screen
this.numberOfDots = 0;
this.coordonatesOfDots = [];
this.circleRadius = 2;
this.maximumDots = 13;
this.firstTimer;
this.secondTimer;
this.create = function(x, y)
{
if(this.numberOfDots < this.maximumDots)
{
this.coordonatesOfDots[++this.numberOfDots] = new coordonates();
this.coordonatesOfDots[this.numberOfDots].x = x;
this.coordonatesOfDots[this.numberOfDots].y = y;
}
}
this.update = function()
{
if(Keys.click == true)
{
this.create(mousseX, mousseY);
}
}
this.timerStart = function()
{
this.firstTimer = new Date().getTime();
}
this.timerStop = function()
{
this.secondTimer = new Date().getTime();
}
this.checkForRemoval = function()
{
if(this.firstTimer && this.secondTimer)
{
//they both exist
if(this.secondTimer - this.firstTimer >= 5000)
{
return true;
}
else
{
return false;
}
}
}
this.show = function()
{
for(let i=1;i<this.numberOfDots;i++)
{
stroke(255,0,255);
line(this.coordonatesOfDots[i].x,this.coordonatesOfDots[i].y, this.coordonatesOfDots[i+1].x, this.coordonatesOfDots[i+1].y);
}
}
}