-
Notifications
You must be signed in to change notification settings - Fork 0
/
setting_game.js
179 lines (141 loc) · 5.6 KB
/
setting_game.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
$(document).ready(function(){
var queryParams = new URLSearchParams(window.location.search);
var hatParameter = false;
var clothesParameter = false;
var hatImg = $('.wearing_hat');
var clothesImg = $('.wearing_clothes');
var difficulty_stage = $('.difficulty_stage');
var difficulty = 0; //초기 난이도
console.log("setting_game 진입\n"+queryParams.toString());
if (queryParams.has("difficulty")) {
difficulty = parseInt(queryParams.get("difficulty")); //difficulty : 난이도
console.log("난이도: " + difficulty);
console.log("난이도");
difficulty_stage.attr("src","backgrounds_img/evening_background3.png");
} else {
// "difficulty" 파라미터가 없는 경우의 처리
console.log("난이도 파라미터가 없습니다.");
}
if(queryParams.has("resetHat")){
hatParameter = true;
var resetHat = JSON.parse(queryParams.get("resetHat")); //resetHat : 모자 미사용여부
console.log("모자 미사용여부: "+ resetHat);
//모자를 입고있는 경우우
if(!resetHat){
var hatColor = queryParams.get("hatColor"); //hatColor : 모자 색
hatImg.attr("src", "clothes_img/" + hatColor + "_hat1.png");
console.log("모자 색: "+ hatColor);
}else{
hatImg.hide();
}
} else {
console.log("모자 미사용여부 파라미터가 없습니다.");
hatImg.hide();
}
if(queryParams.has("resetClothes")){
clothesParameter = true;
var resetClothes = JSON.parse(queryParams.get("resetClothes")); //resetClothes : 옷 미사용여부
console.log("옷 미사용여부: "+ resetClothes);
//옷을 입고있는 경우
if(!resetClothes){
var clothesColor = queryParams.get("clothesColor"); //clothesColor : 옷 색
clothesImg.attr("src", "clothes_img/" + clothesColor + "_clothes1.png");
console.log("옷 색: "+ clothesColor);
}
else{
clothesImg.hide();
}
} else {
console.log("옷 미사용여부 파라미터가 없습니다.");
clothesImg.hide();
}
setButtonImages(difficulty);
//난이도 조절 버튼 함수
function setButtonImages(difficulty) {
switch (difficulty) {
case 0:
$('#difficulty img').attr("src", "buttons_img/easy_btn.png");
difficulty_stage.attr("src","backgrounds_img/evening_background3.png");
break;
case 1:
$('#difficulty img').attr("src", "buttons_img/normal_btn.png");
difficulty_stage.attr("src","backgrounds_img/bridge_background1.png");
break;
case 2:
$('#difficulty img').attr("src", "buttons_img/hard_btn.png");
difficulty_stage.attr("src","backgrounds_img/sunset_background.png");
break;
default:
break;
}
}
$('#start img').hover(function(){
$(this).attr("src", "buttons_img/start_btn2.png");
$(this).css('width','22vw');
}, function() {
$(this).attr("src", "buttons_img/start_btn1.png");
});
$('#start').click(()=>{
queryParams.set("difficulty", difficulty);
var url = "game.html?" + queryParams.toString();
location.href=url;
});
$('#lower_arrow img').hover(function(){
$(this).attr("src", "buttons_img/left_arrow_btn2.png");
$(this).css('width','5vw');
}, function() {
$(this).attr("src", "buttons_img/left_arrow_btn1.png");
});
$('#lower_arrow').click(()=>{
if (difficulty > 0) {
difficulty -= 1;
}
console.log("Current Difficulty: " + difficulty);
setButtonImages(difficulty);
});
$('#raise_arrow img').hover(function(){
$(this).attr("src", "buttons_img/right_arrow_btn2.png");
$(this).css('width','5vw');
}, function() {
$(this).attr("src", "buttons_img/right_arrow_btn1.png");
});
$('#raise_arrow').click(()=>{
if (difficulty < 2) {
difficulty += 1;
}
console.log("Current Difficulty: " + difficulty);
setButtonImages(difficulty);
});
//뒤로가기 함수
$('#back img').hover(function(){
$(this).attr("src", "buttons_img/back_btn1.png");
$(this).css('width','7vw');
}, function() {
$(this).attr("src", "buttons_img/back_btn2.png");
});
$('#back').click(()=>{
queryParams.set("difficulty",0);
var url = "index.html?"+queryParams.toString();
location.href=url;
});
$('#tutorial img').hover(function(){
$(this).attr("src", "buttons_img/tutorial_btn2.png");
$(this).css('width','22vw');
}, function() {
$(this).attr("src", "buttons_img/tutorial_btn1.png");
});
$('#tutorial').click(()=>{
var url = "tutorial.html?"+queryParams.toString();
location.href=url;
});
$('#characters img').hover(function(){
$(this).attr("src", "buttons_img/characters_btn4.png");
$(this).css('width','22vw');
}, function() {
$(this).attr("src", "buttons_img/characters_btn3.png");
});
$('#characters').click(()=>{
var url = "characters.html?" + queryParams.toString();
location.href=url;
});
});