-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
168 lines (141 loc) · 4 KB
/
main.js
File metadata and controls
168 lines (141 loc) · 4 KB
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
import $ from 'jquery'
import {IROHATEXT1,SELECTTEX,GOODENDING,NORMALENDING} from "./irohatext"
//선택지
let choicecheck; //선택지 골랐는지 확인
let choiceevent; //어떤 선택지사항인지
let choicenow=0; //어떤 선택지고름?
let choicesuccess //선택지 성공여부
let Conversationtext // 현재 나온 타이핑
let currentCharIndex // 현재 타이핑 위치
let typingSpeed = 60; // 타이핑 속도 (밀리초)
let skiptext=false
let i = 0; //대화
let j = 0; //선택지
let point = 100; //호감도
let k = 0;
const $conversation = $(".conversation");
function typeCharacter() {
if (currentCharIndex < Conversationtext.length) {
$conversation.text($conversation.text() + Conversationtext.charAt(currentCharIndex));
currentCharIndex++;
setTimeout(typeCharacter, typingSpeed);
}
else {
$conversation.text(Conversationtext); // 타이핑이 끝나면 전체 텍스트 표시
}
}
//텍스트 출력 초기화시키는곳
function PrintText(text){
$conversation.text('');
currentCharIndex=0;
Conversationtext=text
typeCharacter();
}
//베이스 사운드 함수
export function playSound(name,vol,loop = false) {
const audio = new Audio('./'+name);
audio.volume = vol;
audio.loop = loop;
audio.play();
return audio;
}
const PS = playSound("backsound.mp3",0.5);
const PS2 = playSound("inclass.mp3",0.5);
const datesound = playSound("date.mp3",0.5);
const dinersound = playSound("diner.mp3",0.5);
const gamesound = playSound("gamecenter.mp3",0.5);
const moviesound = playSound("cinema.mp3",0.5);
PS2.pause();
datesound.pause();
dinersound.pause();
gamesound.pause();
moviesound.pause();
const onsound = new Audio('./clicksound.mp3');
function on(){
onsound.play();
$('.gamebox').show();
$('.middle').hide();
PS.pause();
PS2.play();
PrintText(IROHATEXT1[i]["TEXT1"]);
}
$(".gamebox").on('click', function() {
if (IROHATEXT1[i]["end"] == "0") {
i++;
PrintText(IROHATEXT1[i]["TEXT1"]);
if (IROHATEXT1[i]["select"] == true){
$('.wall').show();
$('.selectbox1').show();
$('.selectbox1').text(SELECTTEX[j]["select1"]);
$('.selectbox2').show();
$('.selectbox2').text(SELECTTEX[j]["select2"]);
j++;
}
}
if (IROHATEXT1[i]["end"] == "1")
{
if (point <= 150) {
PrintText(NORMALENDING[k]["normaltext"]);
k++;
}
else if (point > 150) {
PrintText(GOODENDING[k]["goodtext"]);
k++;
}
}
});
$('.selectbox1').on('click', function() {
onsound.play();
point = point + 10;
$('.like').text(point);
const laughsound = new Audio('./laugh.mp3');
laughsound.play();
$('.selectbox1').hide();
$('.selectbox2').hide();
$('.wall').hide();
});
$('.selectbox2').on('click', function() {
onsound.play();
point = point - 10;
$('.like').text(point);
$('.selectbox1').hide();
$('.selectbox2').hide();
$('.wall').hide();
});
$('.gamebox').on('click',function() {
if (IROHATEXT1[i]["chacter"] == "1") {
PS2.pause();
datesound.play();
$('.gamebox').css('background-image',"url('./datesite.png')")
$('.ch').attr('src','./ch2.png');
}
if (IROHATEXT1[i]["chacter"] == "2") {
datesound.pause();
dinersound.play();
$('.gamebox').css('background-image',"url('./dinersite.png')")
}
if (IROHATEXT1[i]["chacter"] == "3") {
dinersound.pause();
gamesound.play();
$('.gamebox').css('background-image',"url('./gamesite.png')")
}
if (IROHATEXT1[i]["chacter"] == "4") {
gamesound.pause();
moviesound.play();
$('.gamebox').css('background-image',"url('./moviesite.png')")
}
if (IROHATEXT1[i]["chacter"] == "5") {
moviesound.pause();
PS2.play();
$('.gamebox').css('background-image',"url('./classroom.jpg')")
$('.ch').attr('src','./ch1.png');
}
});
$('.gamebox').hide();
$('.btn').on('click', function() {on()});
$('.ch').attr('src','./ch1.png');
$('.like').text(point);
$('.selectbox1').hide();
$('.selectbox2').hide();
$('.wall').hide();
// 이미지 변경 및 배경 사진 변경