-
Notifications
You must be signed in to change notification settings - Fork 3
/
pause_state.js
86 lines (71 loc) · 1.73 KB
/
pause_state.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
var pause_state = function (p, prev_state) {
// object to return
var obj = game_state(p);
obj.set_previous_state(prev_state);
// --- private variables ---
// Buttons
// Have a rectangle representing their position and
// a state to go to when pressed
var button_x = p.width / 2;
var button_top = 200;
var button_sep = 50;
var continue_button = button(p, {
state : function() { return prev_state; },
rect : {
pos : new p.PVector(button_x, button_top),
width : 60,
height : 20,
text: "Continue"
}
});
var options_button = button(p, {
state : function() { return options_state(p, obj); },
rect : {
pos : new p.PVector(button_x, button_top+button_sep),
width : 60,
height : 20,
text: "Options"
}
});
var help_button = button(p, {
state : function() { return help_state(p, obj); },
rect : {
pos : new p.PVector(button_x, button_top+2*button_sep),
width : 60,
height : 20,
text: "Help"
}
});
var quit_button = button(p, {
state : function() { return splash_state(p); },
rect : {
pos : new p.PVector(button_x, button_top+3*button_sep),
width : 60,
height : 20,
text: "Quit"
}
});
//Not ordered
var all_buttons = [ continue_button, options_button, help_button, quit_button ];
// --- public methods ---
obj.get_type = function() {
return "pause";
};
obj.update = function() {
//do nothing
};
obj.render = function() {
p.noStroke();
p.fill(0, 150);
p.rect(0, 0, p.width, p.height);
};
obj.key_pressed = function(k) {
if (k === 112 || p.keyCode == 13) { //p, enter
obj.exit_state();;
}
};
obj.get_all_buttons = function() {
return all_buttons;
};
return obj;
};