-
Notifications
You must be signed in to change notification settings - Fork 2
/
lvlSelect.js
117 lines (83 loc) · 2.67 KB
/
lvlSelect.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
(function(){
//Definition
function lvlSelect(io){
//CANVAS VARS
this.io = io;
this._io = io;
this.cHeight = io.canvas.height;
this.cWidth = io.canvas.width;
this.imgPath = 'img/';
this.loadResources = 0;
this.totalResources = 5;
this.btnSpaceX = 40;
this.btnMargin = 80;
this.btnSpaceY = 40;
this.cols = 4;
this.btnSize = 65;
if(GAMEHEIGHT != 568){
this.btnSpaceX = 52;
this.btnMargin = 70;
this.btnSpaceY = 20;
this.btnSize = 60;
}
//Levels
this.lvlButtons = new Array();
}; iio.lvlSelect = lvlSelect;
lvlSelect.prototype.setup = function(){
this.io.addToGroup('BACKGROUND',new iio.Rect(pxConv(this.cWidth/2),pxConv(this.cHeight/2),pxConv(this.cWidth),pxConv(this.cHeight)).addImage(this.imgPath+'mountain.png'),-30);
this.backBtn = this.io.addToGroup('MENU',new iio.Rect(pxConv(35),pxConv(30), pxConv(35), pxConv(35)).addImage('img/backBtn.png'),20)
this.lvlButtons.push(null);
var j = 0;
var k = 0;
var colorNum = 0;
var color = getColor(colorNum);
for(var i = 0; i < MAX_LEVELS ; i++){
if(i % this.cols === 0){
colorNum++;
j++;
color = getColor(colorNum);
k = 0;
}
this.lvlButtons.push(this.io.addToGroup('LEVELBTNS',new iio.Rect(pxConv(this.btnSpaceX + this.btnMargin *k ),pxConv(this.btnSpaceY + (this.btnMargin *j)), pxConv(this.btnSize), pxConv(this.btnSize)).setStrokeStyle(color[1],pxConv(3))
.setFillStyle(color[0])
));
k++;
}
//Paint all
for(var i = 1 ; i < this.lvlButtons.length ; i++){
if(localStorage["level." + i] == "true"){
var btnText = new iio.Text(i)
.setFont(pxConv(40)+'px KGWhattheTeacherWants')
.setTextAlign('center')
.setFillStyle(this.lvlButtons[i].styles.strokeStyle)
.setStrokeStyle('rgba(0,0,0,0.3)',pxConv(2))
this.lvlButtons[i].addObj(btnText);
var btnPos = new iio.Vec(this.lvlButtons[i].pos);
btnPos.y += pxConv(10);
this.lvlButtons[i].objs[0].pos = btnPos;
}else{
this.lvlButtons[i].addObj(new iio.Rect().addImage('img/lock.png')
.setImgSize(pxConv(32),pxConv(37))
.setAlpha(0.7));
//this.lvlButtons[i].setStrokeStyle(colors['black'][1][0]).setAlpha(0.7);
}
}
muteBtn = this.io.addToGroup('MENU',new iio.Rect(this.io.canvas.width - pxConv(30), pxConv(30), pxConv(30), pxConv(30))
.setRoundingRadius(pxConv(2))
.setFillStyle(colors['orange'][0])
.setStrokeStyle(colors['orange'][1],pxConv(2)),20);
muteBtn.addObj(new iio.Rect().addImage('img/sound.png')
.setImgSize(pxConv(20),pxConv(20)));
if(muted){
muteBtn.objs[0].setAlpha(0.3);
}else{
muteBtn.objs[0].setAlpha(1);
}
}
lvlSelect.prototype.step = function(){
}
iio.AppManager.prototype.activateLevelSelect = function(io){
this.level = new iio.lvlSelect(io);
return this.level;
}
})();