forked from ec-idds/hackathon-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibrary.js
More file actions
79 lines (68 loc) · 1.38 KB
/
Library.js
File metadata and controls
79 lines (68 loc) · 1.38 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
function Library() {
let player = {
x: 180,
y: 40,
size: 40,
draw: function() {
fill('red');
ellipse(this.x, this.y, this.size, this.size);
}
};
let miniMap = {
x: 50,
y: 50,
size: 400,
draw: function() {
fill('orange');
rect(this.x, this.y, this.size, this.size);
}
};
let QuadZone = {
x: 100,
y: 20,
size: 40,
draw: function() {
fill('red');
rect(this.x, this.y, this.size, this.size);
}
};
this.setup = function () {
// canvas
createCanvas(500, 500);
}
this.draw = function () {
background('pink')
player.draw();
QuadZone.draw();
if(keyIsPressed){
if(keyCode == LEFT_ARROW){
player.x = player.x - 3;
} else if (keyCode == RIGHT_ARROW){
player.x = player.x + 3;
}
if (keyCode == UP_ARROW){
player.y = player.y - 3;
} else if (keyCode == DOWN_ARROW){
player.y = player.y + 3;
}
}
let mapOn = false;
if(keyIsPressed){
if(keyCode == BACKSPACE){
mapOn = true;
} else {
mapOn = false;
}
}
if(mapOn == true){
miniMap.draw();
}
let QuadDist = dist(player.x, player.y, QuadZone.x + QuadZone.size / 2, QuadZone.y + QuadZone.size / 2);
if(QuadDist < 30) {
this.sceneManager.showScene( Quad );
player.x = 180;
player.y = 40;
QuadZone.y = 20;
}
}
}