diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..14d30483 Binary files /dev/null and b/.DS_Store differ diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..bbcbbe7d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/name_ASCII_Banner/README.md b/.github/ISSUE_TEMPLATE/name_ASCII_Banner/README.md new file mode 100644 index 00000000..196645a6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/name_ASCII_Banner/README.md @@ -0,0 +1,8 @@ +# ASCII Banner 🌸 + +This is my fun Hacktoberfest contribution — a script that prints my name **“Gopika 🚀”** in beautiful ASCII art using random fonts each time you run it! + +## 🚀 How to Run +1. Install requirements: + ```bash + pip install pyfiglet diff --git a/.github/ISSUE_TEMPLATE/name_ASCII_Banner/banner.py b/.github/ISSUE_TEMPLATE/name_ASCII_Banner/banner.py new file mode 100644 index 00000000..47b7d5fb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/name_ASCII_Banner/banner.py @@ -0,0 +1,13 @@ +import pyfiglet +import random + +# Some cool fonts you can experiment with +fonts = ["slant", "block", "digital", "bubble", "starwars", "doom", "big"] + +print("\n✨ Welcome to Gopika's Hacktoberfest Contribution ✨\n") + +# Generate ASCII art with random font +banner = pyfiglet.figlet_format("Gopika 🚀", font=random.choice(fonts)) + +print(banner) +print("💜 Made with love by Gopika 💜") diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 00000000..f9128470 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "windows-gcc-x86", + "includePath": [ + "${workspaceFolder}/**" + ], + "compilerPath": "C:/MinGW/bin/gcc.exe", + "cStandard": "${default}", + "cppStandard": "${default}", + "intelliSenseMode": "windows-gcc-x86", + "compilerArgs": [ + "" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..2f014ea6 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "C/C++ Runner: Debug Session", + "type": "cppdbg", + "request": "launch", + "args": [], + "stopAtEntry": false, + "externalConsole": true, + "cwd": ".", + "program": "build/Debug/outDebug", + "MIMode": "gdb", + "miDebuggerPath": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..2b67dc19 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,60 @@ +{ + "liveServer.settings.port": 5501, + "C_Cpp_Runner.cCompilerPath": "gcc", + "C_Cpp_Runner.cppCompilerPath": "g++", + "C_Cpp_Runner.debuggerPath": "gdb", + "C_Cpp_Runner.cStandard": "", + "C_Cpp_Runner.cppStandard": "", + "C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wformat=2", + "-Wcast-align", + "-Wconversion", + "-Wsign-conversion", + "-Wnull-dereference" + ], + "C_Cpp_Runner.msvcWarnings": [ + "/W4", + "/permissive-", + "/w14242", + "/w14287", + "/w14296", + "/w14311", + "/w14826", + "/w44062", + "/w44242", + "/w14905", + "/w14906", + "/w14263", + "/w44265", + "/w14928" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [], + "C_Cpp_Runner.includePaths": [], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ], + "C_Cpp_Runner.useAddressSanitizer": false, + "C_Cpp_Runner.useUndefinedSanitizer": false, + "C_Cpp_Runner.useLeakSanitizer": false, + "C_Cpp_Runner.showCompilationTime": false, + "C_Cpp_Runner.useLinkTimeOptimization": false, + "C_Cpp_Runner.msvcSecureNoWarnings": false +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..4632a0eb --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,29 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: gcc.exe build active file", + "command": "C:/MinGW/bin/gcc.exe", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}\\${fileBasenameNoExtension}.exe", + "" + ], + "options": { + "cwd": "C:/MinGW/bin" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/2048/app.js b/2048/app.js new file mode 100644 index 00000000..94a724be --- /dev/null +++ b/2048/app.js @@ -0,0 +1,191 @@ +```javascript +let arr = []; +let hasCombine = []; +let hasMove = true; +let score = 0; + +function initializeGrid() { + arr = Array(4).fill(null).map(() => Array(4).fill(0)); + hasCombine = Array(4).fill(null).map(() => Array(4).fill(false)); + let x = Math.floor(Math.random() * 4); + let y = Math.floor(Math.random() * 4); + arr[x][y] = 2; +} + +initializeGrid(); +fill(); + +document.addEventListener("keydown", keyPush); + +document.addEventListener("click", (event) => { + const validButtons = ['up','down','left','right']; + if(validButtons.includes(event.target.name)) { + let keyCode; + switch(event.target.name) { + case 'up': keyCode = 38; break; + case 'down': keyCode = 40; break; + case 'left': keyCode = 37; break; + case 'right': keyCode = 39; break; + } + + document.dispatchEvent(new KeyboardEvent("keydown", { keyCode })); + } +}); + + +function keyPush(evt) { + hasMove = false; + switch (evt.keyCode) { + case 37: // Left + moveTiles(0, 1, (i, j, c) => arr[i][j - c - 1] == 0, (i, j, c) => arr[i][j - c - 1] == arr[i][j - c], (i, j, c) => swap(i, j - c, i, j - c - 1), (i, j, c) => combine(i, j - c, i, j - c - 1)); + break; + case 38: // Up + moveTiles(1, 0, (i, j, c) => arr[i - c - 1][j] == 0, (i, j, c) => arr[i - c - 1][j] == arr[i - c][j], (i, j, c) => swap(i - c, j, i - c - 1, j), (i, j, c) => combine(i - c, j, i - c - 1, j)); + break; + case 39: // Right + moveTiles(0, -1, (i, j, c) => arr[i][j + c + 1] == 0, (i, j, c) => arr[i][j + c + 1] == arr[i][j + c], (i, j, c) => swap(i, j + c, i, j + c + 1), (i, j, c) => combine(i, j + c, i, j + c + 1)); + break; + case 40: // Down + moveTiles(-1, 0, (i, j, c) => arr[i + c + 1][j] == 0, (i, j, c) => arr[i + c + 1][j] == arr[i + c][j], (i, j, c) => swap(i + c, j, i + c + 1, j), (i, j, c) => combine(i + c, j, i + c + 1, j)); + break; + } + fill(); +} + +function moveTiles(iDirection, jDirection, isEmpty, canCombine, doSwap, doCombine) { + const startI = iDirection === -1 ? 3 : 0; + const startJ = jDirection === -1 ? 3 : 0; + const iIncrement = iDirection === 0 ? 1 : -1; + const jIncrement = jDirection === 0 ? 1 : -1; + + for (let i = startI; i >= 0 && i < 4; i += iIncrement) { + for (let j = startJ; j >= 0 && j < 4; j += jIncrement) { + let c = 0; + while ((iDirection === 0 && j + c >= 0 && j + c < 3) || (jDirection === 0 && i + c >= 0 && i + c < 3)) { + if (isEmpty(i, j, c)) { + doSwap(i, j + c * jDirection, i, j + (c + 1) * jDirection || i + c * iDirection, i + (c + 1) * iDirection); + } else if (canCombine(i, j, c)) { + doCombine(i, j + c * jDirection, i, j + (c + 1) * jDirection || i + c * iDirection, i + (c + 1) * iDirection); + } + c++; + } + } + } +} + +function fill() { + if (!isFull()) { + if (hasMove) { + randomXY(); + } + } else if (isGameOver()) { + document.getElementById("gameOver").style.display = "block"; + } + + for (let i = 0; i < 4; i++) { + for (let j = 0; j < 4; j++) { + const temp = document.getElementById(i + "" + j); + temp.innerHTML = arr[i][j] !== 0 ? arr[i][j] : ''; + } + } + resetHasCombine(); +} + +function randomXY() { + let x, y; + do { + x = Math.floor(Math.random() * 4); + y = Math.floor(Math.random() * 4); + } while (arr[x][y] !== 0); + + const z = Math.ceil(Math.random() * 10); + arr[x][y] = z >= 7 ? 4 : 2; +} + +function swap(a, b, x, y) { + if (arr[a][b] !== 0 || arr[x][y] !== 0) { + [arr[a][b], arr[x][y]] = [arr[x][y], arr[a][b]]; + hasMove = true; + } +} + +function combine(a, b, x, y) { + if (!hasCombine[x][y] && !hasCombine[a][b]) { + arr[x][y] *= 2; + arr[a][b] = 0; + hasCombine[x][y] = true; + hasMove = true; + score += arr[x][y]; + document.getElementById('num-score').innerHTML = score; + } +} + +function resetHasCombine() { + for (let i = 0; i < 4; i++) { + for (let j = 0; j < 4; j++) { + hasCombine[i][j] = false; + } + } +} + +function isFull() { + return !arr.some(row => row.includes(0)); +} + +function isGameOver() { + for (let i = 0; i < 4; i++) { + for (let j = 0; j < 4; j++) { + if (i > 0 && arr[i - 1][j] === arr[i][j]) return false; + if (j > 0 && arr[i][j - 1] === arr[i][j]) return false; + if (i < 3 && arr[i + 1][j] === arr[i][j]) return false; + if (j < 3 && arr[i][j + 1] === arr[i][j]) return false; + } + } + return true; +} + +function restart() { + initializeGrid(); + document.getElementById('gameOver').style.display = 'none'; + document.getElementById('num-score').innerHTML = score = 0; + fill(); +} + +// btn-translate +let btnTranslate = document.getElementsByClassName("btn-translate")[0]; + +btnTranslate.onclick = () => { + let body = document.getElementsByTagName("body")[0]; + + if(body.className != "id"){ + // ID + body.classList.add("id"); + + // .how -> span + document.querySelector('.how span').textContent = "Bagaimana cara Bermain?"; + // .how -> p + document.querySelector('.how p').innerHTML = "Gunakan tombol panah Anda untuk memindahkan ubin. Ubin dengan nomor yang sama bergabung menjadi satu ketika mereka menyentuh. Tambahkan hingga mencapai 2048!"; + // #text-score + document.querySelector('#text-score').textContent = "Skor : "; + // #gameOver -> span + document.querySelector('#gameOver span').textContent = "Permainan Selesai !!"; + // #gameOver -> #reset + document.querySelector('#gameOver #reset').textContent = "Coba Lagi"; + + } else { + // EN + body.classList.remove("id"); + + // how -> span + document.querySelector('.how span').textContent = "How to Play?" + // how -> p + document.querySelector('.how p').innerHTML = "Use your arrow keys to move the tiles. Tiles with the same number merge into one when they touch. Add them up to reach 2048!" + // #text-score + document.querySelector('#text-score').textContent = "Score : "; + // #gameOver -> span + document.querySelector('#gameOver span').textContent = "Game Over !!"; + // #gameOver -> #reset + document.querySelector('#gameOver #reset').textContent = "Try Again"; + } +} +``` diff --git a/2048/arrow.png b/2048/arrow.png new file mode 100644 index 00000000..ebcc46b8 Binary files /dev/null and b/2048/arrow.png differ diff --git a/2048/index.html b/2048/index.html new file mode 100644 index 00000000..719d1994 --- /dev/null +++ b/2048/index.html @@ -0,0 +1,96 @@ + + + +
| + | + | + | + |
| + | + | + | + |
| + | + | + | + |
| + | + | + | + |