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

Added Morse_Code_Generator #4270

Merged
merged 8 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
33 changes: 33 additions & 0 deletions Games/Morse_Code_Generator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Game_Name

## Description 📃

[Game_Name] is a simple yet engaging Morse Code generator. It allows users to convert regular text input into Morse Code, a method of encoding text characters using sequences of dots and dashes.

## Functionalities 🎮

- Translate regular text input into Morse Code representations.
- Display the translated Morse Code output alongside the input text.
- Handle whitespace characters (spaces) between words in the input text.
- Provide real-time conversion, updating the Morse Code output as the user types or modifies the input text.
- Ensure case insensitivity, allowing both uppercase and lowercase characters in the input text.
- Handle errors gracefully, such as invalid characters that cannot be translated into Morse Code.

## How to play? 🕹️

1. Input the desired text into the provided text field.
2. The Morse Code equivalent of the input text will be displayed in real-time.
3. Copy the Morse Code output if needed for further use or communication.

## Screenshots 📸
![image](https://github.com/Saipradyumnagoud/GameZone/assets/143107589/d1418c4e-6db9-4cb8-86e0-e8ab971de658)



## Working video 📹



https://github.com/Saipradyumnagoud/GameZone/assets/143107589/799ff7d0-18ac-4068-9026-8b0980b706b7


21 changes: 21 additions & 0 deletions Games/Morse_Code_Generator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Morse Code Generator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Morse Code Generator</h1>
<textarea id="input-text" placeholder="Enter text to convert"></textarea>
<br>
<button id="convert-btn">Convert to Morse Code</button>

<textarea id="output-morse" placeholder="Morse Code will appear here"></textarea>
</div>
<script src="script.js"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions Games/Morse_Code_Generator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
document.getElementById('convert-btn').addEventListener('click', function() {
const inputText = document.getElementById('input-text').value.trim().toLowerCase();
const morseCode = convertToMorse(inputText);
document.getElementById('output-morse').value = morseCode;
});

function convertToMorse(text) {
const morseCodeMap = {
'a': '.-', 'b': '-...', 'c': '-.-.', 'd': '-..', 'e': '.', 'f': '..-.', 'g': '--.', 'h': '....',
'i': '..', 'j': '.---', 'k': '-.-', 'l': '.-..', 'm': '--', 'n': '-.', 'o': '---', 'p': '.--.',
'q': '--.-', 'r': '.-.', 's': '...', 't': '-', 'u': '..-', 'v': '...-', 'w': '.--', 'x': '-..-',
'y': '-.--', 'z': '--..',
'0': '-----', '1': '.----', '2': '..---', '3': '...--', '4': '....-', '5': '.....', '6': '-....',
'7': '--...', '8': '---..', '9': '----.'
};

return text.split('').map(char => {
if (char === ' ') {
return '/';
} else if (morseCodeMap[char]) {
return morseCodeMap[char];
} else {
return '';
}
}).join(' ');
}
31 changes: 31 additions & 0 deletions Games/Morse_Code_Generator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
body {
font-family: Arial, sans-serif;
}

.container {
max-width: 600px;
margin: 0 auto;
text-align: center;
padding: 20px;
}

textarea {
width: 100%;
margin-bottom: 10px;
padding: 10px;
resize: none;
}

button {
padding: 10px 20px;
background-color: #007bff;
color: #fff;
border: none;
cursor: pointer;
transition: background-color 0.3s;
}

button:hover {
background-color: #0056b3;
}

15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,13 @@ This repository also provides one such platforms where contributers come over an
|[AquaSort_Game](https://github.com/kunjgit/GameZone/tree/main/Games/AquaSort_Game) |
|[Turn_on_the_light](https://github.com/kunjgit/GameZone/tree/main/Games/Turn_on_the_light) |
| [Tic-Tac-Toe Game](https://github.com/kunjgit/GameZone/tree/main/Games/Tic-Tac-Toe) |
| [Rapid_click_frenzy](https://github.com/kunjgit/GameZone/tree/main/Games/Rapid_click_frenzy) |
|[Dsa_quiz_game](https://github.com/kunjgit/GameZone/tree/main/Games/Dsa_quiz_game) |
| [Rapid_click_frenzy](https://github.com/kunjgit/GameZone/tree/main/Games/Rapid_click_frenzy) |
| [Gravity_Simulation_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Gravity_Simulation_Game) |
| [Rapid_click_frenzy](https://github.com/kunjgit/GameZone/tree/main/Games/Rapid_click_frenzy) |
| [Dsa_quiz_game](https://github.com/kunjgit/GameZone/tree/main/Games/Dsa_quiz_game) |
| [Gravity_Simulation_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Gravity_Simulation_Game) |
| [Anagarm-Word-Game](https://github.com/kunjgit/GameZone/tree/main/Games/Anagarm-Word-Game) |
| [Brick Buster Game](https://github.com/kunjgit/GameZone/tree/main/Games/Brick Buster) |
| [Rapid_click_frenzy](https://github.com/kunjgit/GameZone/tree/main/Games/Rapid_click_frenzy)
|[Penguins Can't Fly](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Penguins_Can't_Fly)|
| [Taash_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Taash_Game)|

| [Brick Buster Game](https://github.com/kunjgit/GameZone/tree/main/Games/Brick%20Buster) |
| [Penguins Can't Fly](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Penguins_Can't_Fly) |
| [Taash_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Taash_Game) |

</center>

Expand Down
Binary file added assets/images/Morse_Code_Generator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading