File tree Expand file tree Collapse file tree 2 files changed +16
-16
lines changed Expand file tree Collapse file tree 2 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -130,20 +130,16 @@ document.addEventListener('keydown', (e) => {
130
130
// Add touch event listeners for mobile support
131
131
let touchStartX = 0 ;
132
132
let touchStartY = 0 ;
133
- let touchEndX = 0 ;
134
- let touchEndY = 0 ;
135
133
136
134
function handleTouchStart ( e ) {
137
135
touchStartX = e . touches [ 0 ] . clientX ;
138
136
touchStartY = e . touches [ 0 ] . clientY ;
139
137
}
140
138
141
- function handleTouchMove ( e ) {
142
- touchEndX = e . touches [ 0 ] . clientX ;
143
- touchEndY = e . touches [ 0 ] . clientY ;
144
- }
139
+ function handleTouchEnd ( e ) {
140
+ const touchEndX = e . changedTouches [ 0 ] . clientX ;
141
+ const touchEndY = e . changedTouches [ 0 ] . clientY ;
145
142
146
- function handleTouchEnd ( ) {
147
143
const dx = touchEndX - touchStartX ;
148
144
const dy = touchEndY - touchStartY ;
149
145
const absDx = Math . abs ( dx ) ;
@@ -167,7 +163,6 @@ function handleTouchEnd() {
167
163
}
168
164
169
165
document . addEventListener ( 'touchstart' , handleTouchStart , false ) ;
170
- document . addEventListener ( 'touchmove' , handleTouchMove , false ) ;
171
166
document . addEventListener ( 'touchend' , handleTouchEnd , false ) ;
172
167
173
168
function initGame ( ) {
Original file line number Diff line number Diff line change 13
13
padding : 30px ;
14
14
border-radius : 15px ;
15
15
text-align : center;
16
-
16
+ width : 100% ;
17
+ max-width : 500px ;
17
18
}
18
19
19
20
.game-container {
@@ -26,24 +27,28 @@ body {
26
27
27
28
# grid-container {
28
29
display : grid;
29
- grid-template-columns : repeat (4 , 100 px );
30
- grid-template-rows : repeat (4 , 100 px );
30
+ grid-template-columns : repeat (4 , 1 fr );
31
+ grid-template-rows : repeat (4 , 1 fr );
31
32
gap : 10px ;
33
+ width : 100% ;
34
+ max-width : 400px ;
32
35
}
33
36
37
+ /* Ensure grid cells maintain a square aspect ratio */
34
38
.grid-cell {
35
- width : 100 px ;
36
- height : 100 px ;
39
+ width : 100 % ;
40
+ padding-bottom : 100 % ; /* Creates a square aspect ratio */
37
41
background-color : # cdc1b4 ;
38
42
border-radius : 6px ;
39
43
display : flex;
40
44
justify-content : center;
41
45
align-items : center;
42
- font-size : 30 px ;
46
+ font-size : 1.5 rem ; /* Adjust font size for better visibility */
43
47
font-weight : bold;
44
48
color : # 776e65 ;
45
49
}
46
50
51
+ /* Color specific rules for different cell values */
47
52
.grid-cell [data-value = "2" ] { background-color : # eee4da ; color : # 776e65 ; }
48
53
.grid-cell [data-value = "4" ] { background-color : # ede0c8 ; color : # 776e65 ; }
49
54
.grid-cell [data-value = "8" ] { background-color : # f2b179 ; color : # f9f6f2 ; }
58
63
59
64
.score-container {
60
65
margin-top : 20px ;
61
- font-size : 24 px ;
66
+ font-size : 1.5 rem ; /* Adjusted for better readability on mobile */
62
67
font-weight : bold;
63
- }
68
+ }
You can’t perform that action at this time.
0 commit comments