studyup 1.0.1 โ†’ 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ # 2048 Game ๐Ÿง ๐ŸŽฎ
2
+
3
+ A fun, interactive puzzle game inspired by the original 2048! This project was built using **HTML**, **CSS**, and **JavaScript**, with dynamic tile merging, score tracking, and keyboard controls.
4
+
5
+ ## ๐ŸŽฏ Features
6
+
7
+ - Fully playable 2048 game (merge tiles with arrow keys)
8
+ - Dynamic board updates and animations
9
+ - Score tracker
10
+ - Game-over detection
11
+ - Responsive layout
12
+
13
+ ## ๐Ÿงช Tech Stack
14
+
15
+ - HTML5
16
+ - CSS3 (Flexbox/Grid)
17
+ - Vanilla JavaScript (Event handling, DOM manipulation)
18
+
19
+ ## ๐Ÿ“ธ Screenshots
20
+
21
+ ### ๐Ÿ’ป View
22
+ ![Screenshot](assets/Screenshots-2048-Game.jpg)
23
+
24
+
25
+ ## ๐Ÿ› ๏ธ Installation
26
+
27
+ 1. Clone the repository:
28
+ ```bash
29
+ git clone https://github.com/rotariu-alexandra/2048-game.git
@@ -0,0 +1,69 @@
1
+ body {
2
+ background-color: #faf8ef;
3
+ display: flex;
4
+ justify-content: center;
5
+ font-family:"Clear Sans", Helvetica, serif;
6
+ }
7
+
8
+ h1 {
9
+ font-size: 5rem;
10
+ line-height: 0.7;
11
+ color: #776e65;
12
+ margin: 0;
13
+ }
14
+
15
+ p, h2 {
16
+ margin: 0;
17
+ }
18
+
19
+ .container {
20
+ width: 465px;
21
+ margin-top: 2rem;
22
+ }
23
+
24
+ .info {
25
+ display: flex;
26
+ justify-content: space-between;
27
+ margin-bottom: 1.3rem;
28
+ }
29
+
30
+ .grid {
31
+ display: flex;
32
+ flex-wrap: wrap;
33
+ width: 456px;
34
+ height: 456px;
35
+ background-color: #bbada0;
36
+ border: 7px solid #bbada0;
37
+ border-radius: 6px;
38
+ margin-top: 1.3rem;
39
+ }
40
+
41
+ .grid div {
42
+ width: 100px;
43
+ height: 100px;
44
+ margin: 7px;
45
+ border-radius: 3px;
46
+ background-color: #eee4da;
47
+ color: #afa192;
48
+ font-weight: bold;
49
+ text-align: center;
50
+ font-size: 3.8rem;
51
+ line-height: 1.6;
52
+ }
53
+
54
+ .score-container {
55
+ text-align: center;
56
+ border-radius: 3px;
57
+ background-color: #8f7a66;
58
+ color: #fff;
59
+ width: 70px;
60
+ height: 60px;
61
+ }
62
+
63
+ #score {
64
+ font-size: 1.8rem;
65
+ }
66
+
67
+ .score-title {
68
+ font-size: 1rem;
69
+ }
@@ -0,0 +1,23 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>2048</title>
7
+ <link rel="stylesheet" href="css/style.css">
8
+ </head>
9
+ <body>
10
+ <div class="container">
11
+ <div class="info">
12
+ <h1>2048</h1>
13
+ <div class="score-container">
14
+ <p class="score-title">Score</p>
15
+ <h2 id="score">0</h2>
16
+ </div>
17
+ </div>
18
+ <p id="result">Join the numbers and get to the <b>2048</b> title!</p>
19
+ <div class="grid"></div>
20
+ </div>
21
+ <script src="src/script.js"></script>
22
+ </body>
23
+ </html>
@@ -0,0 +1,270 @@
1
+ document.addEventListener('DOMContentLoaded', () => {
2
+ const gridDisplay = document.querySelector('.grid');
3
+ const scoreDisplay = document.querySelector('#score');
4
+ const resultDisplay = document.querySelector('#result');
5
+ const width = 4;
6
+ let squares = [];
7
+ let score = 0;
8
+
9
+ function createBoard() {
10
+ for(let i = 0; i < width * width; i++) {
11
+ const square = document.createElement('div');
12
+ square.innerHTML = 0;
13
+ gridDisplay.appendChild(square);
14
+ squares.push(square);
15
+ }
16
+ generate();
17
+ generate();
18
+ }
19
+ createBoard();
20
+
21
+
22
+ function generate() {
23
+ const randomNumber = Math.floor(Math.random() * squares.length);
24
+ if(squares[randomNumber].innerHTML == 0){
25
+ squares[randomNumber].innerHTML = 2;
26
+ checkForGameOver();
27
+ } else {
28
+ generate();
29
+ }
30
+ }
31
+
32
+ function moveRight() {
33
+ for (let i = 0; i < 16; i++) {
34
+ if (i % 4 === 0) {
35
+ let totalOne = squares[i].innerHTML;
36
+ let totalTwo = squares[i+1].innerHTML;
37
+ let totalThree = squares[i+2].innerHTML;
38
+ let totalFour = squares[i+3].innerHTML;
39
+
40
+ let row = [
41
+ parseInt(totalOne),
42
+ parseInt(totalTwo),
43
+ parseInt(totalThree),
44
+ parseInt(totalFour)
45
+ ];
46
+ let filteredRow = row.filter(num => num);
47
+ let missing = 4 - filteredRow.length;
48
+ let zeros = Array(missing).fill(0);
49
+ let newRow = zeros.concat(filteredRow);
50
+ console.log(newRow);
51
+ squares[i].innerHTML = newRow[0];
52
+ squares[i+1].innerHTML = newRow[1];
53
+ squares[i+2].innerHTML = newRow[2];
54
+ squares[i+3].innerHTML = newRow[3];
55
+ }
56
+ }
57
+ }
58
+
59
+ function moveLeft(){
60
+ for (let i = 0; i < 16; i++) {
61
+ if (i % 4 === 0) {
62
+ let totalOne = squares[i].innerHTML;
63
+ let totalTwo = squares[i+1].innerHTML;
64
+ let totalThree = squares[i+2].innerHTML;
65
+ let totalFour = squares[i+3].innerHTML;
66
+
67
+ let row = [
68
+ parseInt(totalOne),
69
+ parseInt(totalTwo),
70
+ parseInt(totalThree),
71
+ parseInt(totalFour)
72
+ ];
73
+ let filteredRow = row.filter(num => num);
74
+ let missing = 4 - filteredRow.length;
75
+ let zeros = Array(missing).fill(0);
76
+ let newRow = filteredRow.concat(zeros);
77
+ console.log(newRow);
78
+ squares[i].innerHTML = newRow[0];
79
+ squares[i+1].innerHTML = newRow[1];
80
+ squares[i+2].innerHTML = newRow[2];
81
+ squares[i+3].innerHTML = newRow[3];
82
+ }
83
+ }
84
+ }
85
+
86
+ function moveUp(){
87
+ for(let i =0; i < 4; i++){
88
+ let totalOne = squares[i].innerHTML;
89
+ let totalTwo = squares[i+width].innerHTML;
90
+ let totalThree = squares[i+width*2].innerHTML;
91
+ let totalFour = squares[i+width*3].innerHTML;
92
+
93
+ let column = [
94
+ parseInt(totalOne),
95
+ parseInt(totalTwo),
96
+ parseInt(totalThree),
97
+ parseInt(totalFour)
98
+ ];
99
+ let filteredColumn = column.filter(num => num);
100
+ let missing = 4 - filteredColumn.length;
101
+ let zeros = Array(missing).fill(0);
102
+ let newColumn = filteredColumn.concat(zeros);
103
+ console.log(newColumn);
104
+ squares[i].innerHTML = newColumn[0];
105
+ squares[i+width].innerHTML = newColumn[1];
106
+ squares[i+width*2].innerHTML = newColumn[2];
107
+ squares[i+width*3].innerHTML = newColumn[3];
108
+ }
109
+ }
110
+
111
+
112
+ function moveDown(){
113
+ for(let i =0; i < 4; i++){
114
+ let totalOne = squares[i].innerHTML;
115
+ let totalTwo = squares[i+width].innerHTML;
116
+ let totalThree = squares[i+width*2].innerHTML;
117
+ let totalFour = squares[i+width*3].innerHTML;
118
+
119
+ let column = [
120
+ parseInt(totalOne),
121
+ parseInt(totalTwo),
122
+ parseInt(totalThree),
123
+ parseInt(totalFour)
124
+ ];
125
+ let filteredColumn = column.filter(num => num);
126
+ let missing = 4 - filteredColumn.length;
127
+ let zeros = Array(missing).fill(0);
128
+ let newColumn = zeros.concat(filteredColumn);
129
+
130
+ squares[i].innerHTML = newColumn[0];
131
+ squares[i+width].innerHTML = newColumn[1];
132
+ squares[i+width*2].innerHTML = newColumn[2];
133
+ squares[i+width*3].innerHTML = newColumn[3];
134
+ }
135
+ }
136
+
137
+
138
+ function combineRow(){
139
+ for(let i=0; i < 15; i++){
140
+ if(squares[i].innerHTML === squares[i+1].innerHTML){
141
+ let combineTotal = parseInt(squares[i].innerHTML) + parseInt(squares[i+1].innerHTML);
142
+ squares[i].innerHTML = combineTotal;
143
+ squares[i+1].innerHTML = 0;
144
+ score += combineTotal;
145
+ scoreDisplay.innerHTML = score;
146
+ }
147
+ }
148
+ }
149
+
150
+ function combineColumn(){
151
+ for(let i=0; i < 11; i++){
152
+ if(squares[i].innerHTML === squares[i+width].innerHTML){
153
+ let combineTotal = parseInt(squares[i].innerHTML) + parseInt(squares[i+width].innerHTML);
154
+ squares[i].innerHTML = combineTotal;
155
+ squares[i+width].innerHTML = 0;
156
+ score += combineTotal;
157
+ scoreDisplay.innerHTML = score;
158
+ }
159
+ }
160
+ checkForWin();
161
+ }
162
+
163
+ //async function
164
+ function control(e){
165
+ if (e.key === 'ArrowLeft'){
166
+ keyLeft();
167
+ } else if(e.key === 'ArrowRight'){
168
+ keyRight();
169
+ } else if(e.key === 'ArrowUp'){
170
+ keyUp();
171
+ }else if(e.key === 'ArrowDown'){
172
+ keyDown();
173
+ }
174
+ }
175
+ document.addEventListener('keydown', control);
176
+
177
+ function keyLeft(){
178
+ moveLeft();
179
+ combineRow();
180
+ moveLeft();
181
+ generate();
182
+ }
183
+
184
+ function keyRight(){
185
+ moveRight();
186
+ combineRow();
187
+ moveRight();
188
+ generate();
189
+ }
190
+
191
+ function keyUp(){
192
+ moveUp();
193
+ combineColumn();
194
+ moveUp();
195
+ generate();
196
+ }
197
+
198
+ function keyDown(){
199
+ moveDown();
200
+ combineColumn();
201
+ moveDown();
202
+ generate();
203
+ }
204
+
205
+ //check number for to win
206
+
207
+ function checkForWin(){
208
+ for(let i = 0; i < squares.length ;i++){
209
+ if(squares[i].innerHTML == 2048) {
210
+ resultDisplay.innerHTML = "You win";
211
+ document.removeEventListener('keydown', control);
212
+ }
213
+ }
214
+ }
215
+
216
+ //check lose
217
+ function checkForGameOver(){
218
+ let zeros = 0;
219
+ for(let i=0; i < squares.length; i++){
220
+ if(squares[i].innerHTML == 0){
221
+ zeros++;
222
+ }
223
+ }
224
+
225
+ if(zeros === 0){
226
+ resultDisplay.innerHTML = "You lose";
227
+ document.removeEventListener('keydown', control);
228
+ }
229
+ }
230
+
231
+ function clear(){
232
+ resultDisplay.innerHTML = "You lose";
233
+ document.removeEventListener('keydown', control);
234
+ setTimeout(clear, 3000);
235
+ }
236
+ //add colors
237
+ function addColors(){
238
+ for(let i=0; i < squares.length; i++){
239
+ if(squares[i].innerHTML == 0){
240
+ squares[i].style.backgroundColor = '#afa192';
241
+ } else if(squares[i].innerHTML == 2){
242
+ squares[i].style.backgroundColor = '#eee4da';
243
+ } else if(squares[i].innerHTML == 4){
244
+ squares[i].style.backgroundColor = '#ede0c8';
245
+ } else if(squares[i].innerHTML == 8){
246
+ squares[i].style.backgroundColor = '#f2b179';
247
+ } else if(squares[i].innerHTML == 16){
248
+ squares[i].style.backgroundColor = '#ffcea4';
249
+ } else if(squares[i].innerHTML == 32){
250
+ squares[i].style.backgroundColor = '#e8c064';
251
+ } else if(squares[i].innerHTML == 64){
252
+ squares[i].style.backgroundColor = '#ffab6e';
253
+ } else if(squares[i].innerHTML == 128){
254
+ squares[i].style.backgroundColor = '#fd9982';
255
+ } else if(squares[i].innerHTML == 256){
256
+ squares[i].style.backgroundColor = '#ead79c';
257
+ } else if(squares[i].innerHTML == 512){
258
+ squares[i].style.backgroundColor = '#76daff';
259
+ } else if(squares[i].innerHTML == 1024){
260
+ squares[i].style.backgroundColor = '#beeaa5';
261
+ } else if(squares[i].innerHTML == 2048){
262
+ squares[i].style.backgroundColor = '#d7d4f0';
263
+ }
264
+ }
265
+ }
266
+
267
+ addColors();
268
+ let myTimer = setInterval(addColors, 50);
269
+
270
+ });
@@ -0,0 +1,5 @@
1
+ # ClassiCube-HTML
2
+ Offline HTML Version Of ClassiCube.
3
+ Official ClassiCube Repo: https://github.com/ClassiCube/ClassiCube
4
+ Preview: [HERE!](https://al3x77777.github.io/ClassiCube-HTML)
5
+ ![IMG](https://github.com/Al3x77777/ClassiCube-HTML/assets/112645002/91ef029b-66bf-46a7-b616-fa0eccf819a6)
@@ -0,0 +1,7 @@
1
+ body
2
+ {
3
+ padding: 0;
4
+ margin: 0;
5
+ overflow: hidden;
6
+
7
+ }
@@ -0,0 +1,72 @@
1
+ <html><head>
2
+ <title>ClassiCube</title>
3
+ <meta name="viewport" content="width=device-width">
4
+ <link href="css/style.css" rel="stylesheet">
5
+ <script src="js/jquery.js"></script>
6
+ </head>
7
+ <body>
8
+ <div id="body">
9
+ <div class="sec">
10
+ <div class="row">
11
+ <canvas id="canvas" style="display:block; box-sizing:border-box; border-width:0px; padding:0; margin:0 auto; background-color: black; width:100%; height:auto;" oncontextmenu="event.preventDefault()" tabindex="-1" width="1000" height="562"></canvas>
12
+ <span id="logmsg" style="font-size:18px;color:#F67;"></span>
13
+ </div>
14
+ </div>
15
+ <script type="text/javascript">
16
+ function resizeGameCanvas() {
17
+ var cc_canv = $('canvas#canvas');
18
+
19
+ cc_canv[0].width = window.innerWidth;
20
+ cc_canv[0].height = window.innerHeight;
21
+
22
+ cc_canv.focus();
23
+ }
24
+
25
+ function setFocusOnClick() {
26
+ // Set focus on the canvas when the iframe is clicked
27
+ var cc_canv = $('canvas#canvas');
28
+ cc_canv.focus();
29
+ }
30
+ document.getElementById('canvas').addEventListener('click', setFocusOnClick);
31
+
32
+ window.addEventListener('load', function() {
33
+ document.getElementById('canvas').focus();
34
+ });
35
+
36
+
37
+ var Module = {
38
+ preRun: [ resizeGameCanvas ],
39
+ postRun: [],
40
+ arguments: ['Singleplayer'],
41
+ print: function(text) {
42
+ if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
43
+ console.log(text);
44
+ },
45
+ printErr: function(text) {
46
+ if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
47
+ console.error(text);
48
+ },
49
+ canvas: (function() { return document.getElementById('canvas'); })(),
50
+ setStatus: function(text) {
51
+ console.log(text);
52
+ document.getElementById('logmsg').innerHTML = text;
53
+ },
54
+ totalDependencies: 0,
55
+ monitorRunDependencies: function(left) {
56
+ this.totalDependencies = Math.max(this.totalDependencies, left);
57
+ Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
58
+ }
59
+ };
60
+ Module.setStatus('Downloading...');
61
+ window.onerror = function(msg) {
62
+ // TODO: do not warn on ok events like simulating an infinite loop or exitStatus
63
+ Module.setStatus('Exception thrown, see JavaScript console (' + msg + ')');
64
+ Module.setStatus = function(text) {
65
+ if (text) Module.printErr('[post-exception status] ' + text);
66
+ };
67
+ };
68
+ </script>
69
+ <script async="" type="text/javascript" src="js/ClassiCube.js"></script>
70
+ </div>
71
+
72
+ </body></html>