/
credits_state.js
59 lines (44 loc) · 1.15 KB
/
credits_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
var credits_state = function(p, prev_state) {
// object to return
var obj = game_state(p);
obj.set_previous_state(prev_state);
// --- private variables ---
var credits_back = image_manager.get_image("creditsscreen.png");
// Buttons
var back_button = button(p, {
state : function() { return prev_state; },
rect : {
pos : new p.PVector(p.width * (3/4), 500),
width: 120,
height: 50,
image: "back.png",
}
});
//Not ordered
var all_buttons = [ back_button ];
// --- public methods ---
obj.get_type = function() {
return "credits";
};
obj.update = function() {
//do nothing
};
obj.render = function() {
// fill the background
p.noStroke();
p.fill(g.background_color);
p.rectMode(p.CORNER);
p.rect(0, 0, p.width, p.height);
p.imageMode(p.CENTER);
p.image(credits_back, p.width/2, p.height/2);
};
obj.key_pressed = function(k) {
if (p.keyCode === 13 || p.keyCode === 27) { // enter, esc
obj.exit_state();
}
};
obj.get_all_buttons = function() {
return all_buttons;
};
return obj;
};