Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contributing under GSSOC'24. Adding a simple game #5109

Merged
merged 4 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Games/Prime-No-Finder-Game/bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Prime-No-Finder-Game/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions Games/Prime-No-Finder-Game/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Prime Number Finder</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
<style>
.background-image {
background-image: url('bg.jpg');
background-size: cover;
background-position: center;
}
</style>
</head>
<body class="background-image text-white flex items-center justify-center h-screen">
<div class="bg-gray-800 bg-opacity-75 p-10 rounded-lg shadow-lg">
<h1 class="text-4xl mb-4 text-center">Prime Number Finder</h1>
<p class="text-lg mb-6 text-center">Enter a number to check if it's a prime number.</p>
<div class="mb-4">
<input id="numberInput" type="number" placeholder="Enter number" class="w-full p-2 rounded-lg text-black">
</div>
<div class="mb-4 text-center">
<button onclick="checkPrime()" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Check</button>
</div>
<div id="result" class="text-center text-2xl"></div>
<img id="resultImage" class="mt-4 mx-auto w-32 h-32 hidden">
</div>
<script src="script.js"></script>
</body>
</html>
34 changes: 34 additions & 0 deletions Games/Prime-No-Finder-Game/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function checkPrime() {
const number = document.getElementById('numberInput').value;
const resultDiv = document.getElementById('result');
const resultImage = document.getElementById('resultImage');

if (number === '') {
resultDiv.innerHTML = 'Please enter a number!';
resultImage.classList.add('hidden');
return;
}

const num = parseInt(number);
if (isPrime(num)) {
resultDiv.innerHTML = `${num} is a prime number!`;
resultImage.src = 'star.jpg';
resultImage.classList.remove('hidden');
} else {
resultDiv.innerHTML = `${num} is not a prime number.`;
resultImage.src = 'skull.jpg';
resultImage.classList.remove('hidden');
}
}

function isPrime(num) {
if (num <= 1) return false;
if (num <= 3) return true;

if (num % 2 === 0 || num % 3 === 0) return false;

for (let i = 5; i * i <= num; i += 6) {
if (num % i === 0 || num % (i + 2) === 0) return false;
}
return true;
}
Binary file added Games/Prime-No-Finder-Game/skull.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Prime-No-Finder-Game/star.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ This repository also provides one such platforms where contributers come over an

|[Idle_miner](https://github.com/kunjgit/GameZone/tree/main/Games/Idle_miner)| [Five_Nights_at_Freddys](https://github.com/kunjgit/GameZone/tree/main/Games/Five_Nights_at_Freddys) | [Penalty_Shootout_Game] (https://github.com/kunjgit/GameZone/tree/main/Games/Penalty_Shootout_Game)| |[Snake_Gun_Water](https://github.com/kunjgit/GameZone/tree/main/Games/Snake_Gun_Water)|
| [Drum_kit] (https://github.com/kunjgit/GameZone/tree/main/Games/Drum_kit)|

| [Prime-No-Finder-Game] (https://github.com/kunjgit/GameZone/tree/main/Games/Prime-No-Finder-Game)|
</center>
<br>
<p align="right"><a href="#top">Back to top</a></p>
Expand Down
Binary file added assets/images/Prime-No-Finder Game.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading