-
Notifications
You must be signed in to change notification settings - Fork 0
/
controlsAndInput.js
72 lines (63 loc) · 1.69 KB
/
controlsAndInput.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
69
70
71
72
//Constructor function to handle the onscreen menu, keyboard and mouse
//controls
function ControlsAndInput() {
//playback button displayed in the top left of the screen
this.playbackButton = new PlaybackButton();
//make the window fullscreen or revert to windowed
this.mousePressed = function() {
//???
//check if the playback button has been clicked
//if not make the visualisation fullscreen
if (this.playbackButton.hitCheck()) {
this.menuDisplayed = true;
this.playing = true;
}
else {
if (fullscreen()) {
fullscreen(false);
}
else {
fullscreen(true);
}
}
};
//responds to keyboard presses
//@param keycode the ascii code of the keypressed
this.keyPressed = function(keycode) {
console.log(keycode);
if (keycode == 32) {
this.menuDisplayed = !this.menuDisplayed;
}
else {
this.menuDisplayed = false;
}
if (keycode > 48 && keycode < 58) {
var visNumber = keycode - 49;
vis.selectVisual(vis.visuals[visNumber].name);
}
};
//draws the playback button and potentially the menu
this.draw = function() {
push();
fill("white");
stroke("black");
strokeWeight(2);
textSize(34);
//playback button
this.playbackButton.draw();
//only draw the menu if menu displayed is set to true.
if (this.menuDisplayed) {
text("Select a visualisation:", 100, 30);
this.menu();
}
pop();
};
this.menu = function() {
//draw out menu items for each visualisation
//???
//
for (var i = 0; i < vis.visuals.length; i++) {
text(" " + (i + 1) + ": " + vis.visuals[i].name, 50, 70 + i * 30);
}
};
}