@@ -4,20 +4,19 @@ import TwoGameScreen from "./component/twoplayer/TwoGameScreen.jsx";
4
4
import OnOff from "./img/on-off-button.png" ;
5
5
import StarRain from "./component/effect/StarRain.jsx" ;
6
6
import { useNavigate } from "react-router-dom" ;
7
+ import Loading from "./component/loading/Loading" ;
7
8
8
9
import * as constants from "../utils/Constants" ;
9
10
10
11
import { useLocation } from "react-router-dom" ;
11
- import { createBrowserHistory } from "history" ;
12
+ import axios from 'axios' ;
12
13
13
14
14
15
function TwoDecorativeGame ( ) {
15
16
16
17
const anotherVideoRef = useRef ( null ) ;
17
18
const otherDrawingRef = useRef ( null ) ;
18
- const otherContextRef = useRef ( null ) ;
19
19
const otherEmojiRef = useRef ( null ) ;
20
- const otherEmojiContextRef = useRef ( null ) ;
21
20
22
21
23
22
/// 파라미터로 방 코드 받음
@@ -31,17 +30,14 @@ function TwoDecorativeGame() {
31
30
32
31
const handleResize = ( ) => {
33
32
let height = window . innerHeight * constants . TWO_DECORATIVE_GAME_HEIGHT_RATIO ;
34
- console . log ( height )
35
-
36
33
setWindowHeight ( height ) ;
37
34
}
38
35
39
- // 모달창 (타이머)
40
- const [ isOpen , setIsOpen ] = useState ( false ) ;
36
+ const [ isLoading , setIsLoading ] = useState ( true ) ;
41
37
42
- const onClickButton = ( ) => {
43
- setIsOpen ( true ) ;
44
- } ;
38
+ const getVideo = ( isLoading ) => {
39
+ console . log ( isLoading ) ;
40
+ }
45
41
46
42
// 자식 함수 데려오기
47
43
const gameScreenRef = useRef ( ) ;
@@ -54,15 +50,21 @@ function TwoDecorativeGame() {
54
50
const [ word , setWord ] = useState ( "Your Word Here!" ) ;
55
51
// 뒤로가기 버튼 클릭
56
52
const [ isBackButton , setIsBackButton ] = useState ( false ) ;
53
+
57
54
// 상대 이모지 개수 불러오기
58
55
const [ otherNumber , setOtherNumber ] = useState ( 0 ) ;
59
56
60
57
const getOtherData = ( otherNumber ) => {
61
58
console . log ( otherNumber ) ;
62
59
}
63
60
61
+ const onClickedBack = ( ) => {
62
+ deleteRoom ( code ) ;
63
+ setIsBackButton ( ! isBackButton )
64
+ }
64
65
65
-
66
+ const otherShapes = useRef ( [ ] ) ;
67
+
66
68
useEffect ( ( ) => {
67
69
68
70
window . addEventListener ( 'resize' , handleResize ) ;
@@ -72,6 +74,24 @@ function TwoDecorativeGame() {
72
74
73
75
} , [ ] )
74
76
77
+ // 방 나가기 -> 방 삭제
78
+ const deleteRoom = ( code ) => {
79
+ axios . post ( constants . GAMEROOM_URL + "/delete" ,
80
+ {
81
+ code : code ,
82
+ } )
83
+ . then ( ( res ) => {
84
+
85
+ if ( res . data . result == "FAIL" ) {
86
+ console . log ( "방 삭제 실패" ) ;
87
+ }
88
+ else {
89
+ console . log ( "방 삭제 성공" )
90
+ }
91
+ } )
92
+ . catch ( ( Error ) => { console . log ( "에러" , Error ) } )
93
+ }
94
+
75
95
return (
76
96
< div className = "main-container-decoration-game-two" >
77
97
< StarRain />
@@ -80,7 +100,7 @@ function TwoDecorativeGame() {
80
100
< div className = "best-top-left-decoration-game-two" >
81
101
</ div >
82
102
< div className = "best-top-right-decoration-game-two" >
83
- < div className = "on-off-button-two-decorative" onClick = { ( ) => { setIsBackButton ( ! isBackButton ) } } >
103
+ < div className = "on-off-button-two-decorative" onClick = { onClickedBack } >
84
104
< img className = "on-off-image-two-decorative" src = { OnOff } alt = "END" > </ img >
85
105
</ div >
86
106
</ div >
@@ -115,9 +135,9 @@ function TwoDecorativeGame() {
115
135
sender = { Math . random ( ) . toString ( 36 ) . substring ( 2 , 11 ) }
116
136
anotherVideoRef = { anotherVideoRef }
117
137
otherDrawingRef = { otherDrawingRef }
118
- otherContextRef = { otherContextRef }
119
138
otherEmojiRef = { otherEmojiRef }
120
139
isBackButton = { isBackButton } />
140
+
121
141
</ div >
122
142
</ div >
123
143
</ div >
@@ -130,6 +150,7 @@ function TwoDecorativeGame() {
130
150
131
151
< div className = "right-body-container-decoration-game-two" >
132
152
< div className = "body-container-of-right-decoration-game-two" >
153
+ < Loading loading = { isLoading } />
133
154
< div style = { {
134
155
position : "relative" ,
135
156
height : "100%"
@@ -143,8 +164,15 @@ function TwoDecorativeGame() {
143
164
position : "absolute" ,
144
165
width : ( window . innerHeight * constants . TWO_DECORATIVE_GAME_HEIGHT_RATIO * ( 4.0 / 3.0 ) ) ,
145
166
height : windowHeight ,
146
- margin : "auto" ,
167
+ marginLeft : "auto" ,
168
+ marginRight : "auto" ,
169
+ top : "0" ,
170
+ left : "0" ,
171
+ right : "0" ,
172
+ textAlign : "center" ,
147
173
zIndex : 1 ,
174
+ width : "100%" ,
175
+ height : "100%" ,
148
176
transform : "scaleX(-1)"
149
177
} }
150
178
/>
@@ -155,16 +183,16 @@ function TwoDecorativeGame() {
155
183
// tabIndex={0}s
156
184
//onKeyDown={f1Down}
157
185
style = { {
158
- // background:"red",
186
+ // background: "red",
159
187
position : "absolute" ,
160
188
marginLeft : "auto" ,
161
189
marginRight : "auto" ,
162
190
left : "0" ,
163
191
right : "0" ,
164
192
textAlign : "center" ,
165
193
zIndex : 9 ,
166
- width : "100%" ,
167
- height : "100%" ,
194
+ width : ( window . innerHeight * constants . TWO_DECORATIVE_GAME_HEIGHT_RATIO * ( 4.0 / 3.0 ) ) ,
195
+ height : windowHeight ,
168
196
} } >
169
197
</ canvas >
170
198
< canvas
@@ -180,8 +208,8 @@ function TwoDecorativeGame() {
180
208
right : "0" ,
181
209
textAlign : "center" ,
182
210
zIndex : 11 ,
183
- width : "100%" ,
184
- height : "100%" ,
211
+ width : ( window . innerHeight * constants . TWO_DECORATIVE_GAME_HEIGHT_RATIO * ( 4.0 / 3.0 ) ) ,
212
+ height : windowHeight ,
185
213
} } >
186
214
</ canvas >
187
215
</ div >
0 commit comments