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 Catch Him #4800

Merged
merged 2 commits into from
Jul 14, 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
18 changes: 18 additions & 0 deletions Games/Catch Him/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Catch him
"Catch Him" is a fun and engaging game that involves quick reflexes and strategic thinking. The main objective of the game is to catch a character named Ralph, who moves swiftly across the screen. Players must click or tap on Ralph as he appears in different locations, often disappearing and reappearing quickly to increase the challenge. The game typically includes various levels of difficulty, with Ralph moving faster and more unpredictably as players advance. It's a great game for testing hand-eye coordination and speed, providing an entertaining and competitive experience for players of all ages.

## How to play ?:

1. **Objective**: Your goal is to catch Ralph by clicking or tapping on him whenever he appears on the screen.

2. **Gameplay**:
- Ralph will move around the screen and may disappear and reappear in different locations.
- Use your mouse (if on a computer) tap to catch Ralph.
- Each time you successfully catch Ralph, you earn points.

3. **Time Limit**: The game may have a time limit . Try to catch Ralph as many times as possible before time runs out.

4. **Score**: Your score is based on how many times you catch Ralph. Aim for a high score and challenge yourself to improve with each playthrough.

## Screenshot
<img src="images/Catch_him.png">
Binary file added Games/Catch Him/audios/hit.m4a
Binary file not shown.
Binary file added Games/Catch Him/images/Catch_him.png
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/Catch Him/images/favicon.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/Catch Him/images/player.png
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/Catch Him/images/ralph.png
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/Catch Him/images/wall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions Games/Catch Him/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!DOCTYPE html>
<html lang="pt-br">

<head>

<!-- settings -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ctch Ralph</title>

<!-- fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Press+Start+2P&display=swap" rel="stylesheet">

<!-- styles -->
<link rel="stylesheet" href="./styles/reset.css">
<link rel="stylesheet" href="./styles/main.css">
</head>

<body>

<div class="container">
<div class="menu">
<div class="menu-time">
<h2 style="color: red;">Time Left</h2>
<h2 id="time-left">0</h2>
</div>
<div class="menu-score">
<h2 style="color: red;">Your Score</h2>
<h2 id="score">0</h2>
</div>
<div class="menu-lives">
<img src="./images/player.png" alt="img" height="60px" />
<h2>x3</h2>
</div>
</div>

<div class="panel">
<div class="panel-row">
<div class="square " id="1"></div>
<div class="square" id="2"></div>
<div class="square" id="3"></div>
</div>

<div class="panel-row">
<div class="square enemy" id="4"></div>
<div class="square" id="5"></div>
<div class="square" id="6"></div>
</div>

<div class="panel-row">
<div class="square" id="7"></div>
<div class="square" id="8"></div>
<div class="square" id="9"></div>
</div>
</div>
</div>

<script defer src="scripts/engine.js"></script>
</body>

</html>
65 changes: 65 additions & 0 deletions Games/Catch Him/scripts/engine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const state = {
view: {
squares: document.querySelectorAll(".square"),
enemy: document.querySelector(".enemy"),
timeLeft: document.querySelector("#time-left"),
score: document.querySelector("#score"),
},
values: {
gameVelocity: 1000,
hitPosition: 0,
result: 0,
curretTime: 60,
},
actions: {
timerId: setInterval(randomSquare, 1000),
countDownTimerId: setInterval(countDown, 1000),
},
};

function countDown() {
state.values.curretTime--;
state.view.timeLeft.textContent = state.values.curretTime;

if (state.values.curretTime <= 0) {
clearInterval(state.actions.countDownTimerId);
clearInterval(state.actions.timerId);
alert("Game Over! O seu resultado foi: " + state.values.result);
}
}

function playSound(audioName) {
let audio = new Audio(`./src/audios/${audioName}.m4a`);
audio.volume = 0.2;
audio.play();
}

function randomSquare() {
state.view.squares.forEach((square) => {
square.classList.remove("enemy");
});

let randomNumber = Math.floor(Math.random() * 9);
let randomSquare = state.view.squares[randomNumber];
randomSquare.classList.add("enemy");
state.values.hitPosition = randomSquare.id;
}

function addListenerHitBox() {
state.view.squares.forEach((square) => {
square.addEventListener("mousedown", () => {
if (square.id === state.values.hitPosition) {
state.values.result++;
state.view.score.textContent = state.values.result;
state.values.hitPosition = null;
playSound("hit");
}
});
});
}

function initialize() {
addListenerHitBox();
}

initialize();
48 changes: 48 additions & 0 deletions Games/Catch Him/styles/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.container {
display: flex;
flex-direction: column;
height: 100vh;
background-image: url("../images/wall.png");
}

.menu {
display: flex;
justify-content: space-evenly;
align-items: center;

height: 90px;
width: 100%;
background-color: #000000;
color: #ffffff;
border-bottom: 5px solid #ffd700;
}

.panel {
margin-top: 1rem;
display: flex;
align-items: center;
justify-content: center;
}

.square {
height: 150px;
width: 150px;
border: 1px solid #000000;
background-color: #1aeaa5;
}

.enemy {
background-image: url("../images/ralph.png");
background-size: cover;
}

.menu-lives {
display: flex;
align-items: center;
justify-content: center;
}

.menu-time h2:nth-child(2),
.menu-score h2:nth-child(2) {
margin-top: 1rem;
}
7 changes: 7 additions & 0 deletions Games/Catch Him/styles/reset.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
/* font-family: "Bebas Neue", sans-serif; */
font-family: "Press Start 2P", cursive;
}
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,9 @@ This repository also provides one such platforms where contributers come over an
| [IKnowYou-Mind-Reading-Game](https://github.com/kunjgit/GameZone/tree/main/Games/IKnowYou-Mind-Reading-Game) |
|[Rock_Paper_Scissors_Neon](https://github.com/kunjgit/GameZone/tree/main/Games/Rock_Paper_Scissors_Neon)|
|[Beat_a_mole](https://github.com/kunjgit/GameZone/tree/main/Games/Beat_a_mole)|
|[Catch Him](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_him) |
|[Hexsweep_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Hexsweep-Game)|



</center>

<br>
Expand Down
Binary file added assets/images/Catch_him.png
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 assets/images/Catch_him.webp
Binary file not shown.
Loading