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 new game Eco Warrior #4299

Closed
wants to merge 14 commits into from
50 changes: 50 additions & 0 deletions Games/Eco_Warrior/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Eco Warrior

## Overview

Eco Warrior is an educational and engaging game designed to raise awareness about environmental conservation. Players take on the role of an eco-warrior whose mission is to clean up litter, plant trees, and restore ecosystems. The game is designed to be both fun and educational, teaching players the importance of keeping the environment clean and green.

## How to Play

- **Objective**: Clean up all the litter within the given time to advance to the next level. Additionally, plant trees to increase your impact score and improve the environment.
- **Energy**: Start with 100 energy points. Cleaning litter and planting trees consume energy. Energy regenerates over time.
- **Score**: Earn points by cleaning litter and planting trees. Higher scores unlock upgrades and allow you to progress to higher levels.
- **Timer**: Each level has a countdown timer. Clean up all the litter before the time runs out to complete the level. The time available increases with each subsequent level.

## Game Elements

- **Litter**: Click on litter items scattered around the game area to clean them up. Each piece of litter cleaned increases your score.
- **Trees**: Plant trees to improve your score and the environment. Planting a tree costs 10 energy points.
- **Upgrades**: Accumulate 50 points to purchase an upgrade that increases your energy regeneration rate.

## Levels

The game consists of multiple levels, each progressively more challenging:
- **Level 1**: Start with 10 pieces of litter and 60 seconds to clean them up.
- **Subsequent Levels**: Each new level adds 5 more pieces of litter and increases the timer by 10 seconds. The challenge increases as you progress, requiring more strategic use of energy and time.

## Game Over

If you fail to clean up all the litter within the given time, the game will display a "Game Over" message and reset. Try again to beat your previous scores and advance further.

## Screenshots

![Treasure Hunt](../../assets/images/Eco_Warrior.png)

## Try It Out

You can try out the game by opening the `index.html` file in your web browser.

## Educational Impact

Eco Warrior aims to educate players about the importance of environmental conservation. By simulating the cleanup process and tree planting, players learn the value of these actions in a fun and interactive way. The game encourages players to think about real-world environmental issues and how they can contribute to a cleaner, greener planet.

## Gameplay Tips

- **Manage Energy**: Keep an eye on your energy levels. Avoid running out of energy by allowing time for regeneration.
- **Strategize**: Plan your moves to efficiently clean up litter and plant trees without wasting energy.
- **Upgrade Wisely**: Use your score to purchase upgrades that will help you in higher levels by increasing your energy regeneration rate.

## Credits

Eco Warrior was created to raise awareness about environmental conservation. Thank you for playing and contributing to a cleaner, greener planet.
Binary file added Games/Eco_Warrior/assets/litter.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/Eco_Warrior/assets/tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
118 changes: 118 additions & 0 deletions Games/Eco_Warrior/game.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
let energy = 100;
let score = 0;
let level = 1;
let litterCount = 10;
let energyRegenRate = 1;
let timer;
let timeLeft = 60;

const energyElement = document.getElementById('energy');
const scoreElement = document.getElementById('score');
const levelElement = document.getElementById('level');
const timerElement = document.getElementById('timer');
const plantTreeButton = document.getElementById('plant-tree');
const upgradeButton = document.getElementById('upgrade');
const litterContainer = document.getElementById('litter');
const treesContainer = document.getElementById('trees');

function updateStats() {
energyElement.textContent = energy;
scoreElement.textContent = score;
levelElement.textContent = level;
timerElement.textContent = timeLeft;
plantTreeButton.disabled = energy < 10;
upgradeButton.disabled = score < 50;
}

function createLitter() {
for (let i = 0; i < litterCount; i++) {
const litter = document.createElement('div');
litter.classList.add('litter');
litter.style.top = `${Math.random() * 350}px`;
litter.style.left = `${Math.random() * 750}px`;

litter.addEventListener('click', () => {
litter.remove();
score += 10;
updateStats();
checkLevelCompletion();
});

litterContainer.appendChild(litter);
}
}

function checkLevelCompletion() {
if (litterContainer.children.length === 0) {
clearInterval(timer);
alert('Level Completed! Starting next level.');
level++;
litterCount += 5;
timeLeft = 60 + (level - 1) * 10;
createLitter();
startTimer();
updateStats();
}
}

function plantTree() {
if (energy < 10) return;

const tree = document.createElement('div');
tree.classList.add('tree');
tree.style.top = `${Math.random() * 350}px`;
tree.style.left = `${Math.random() * 750}px`;

treesContainer.appendChild(tree);
energy -= 10;
score += 20;
updateStats();
}

function upgrade() {
if (score < 50) return;
score -= 50;
energyRegenRate += 0.5;
updateStats();
}

function startTimer() {
timer = setInterval(() => {
if (timeLeft > 0) {
timeLeft--;
updateStats();
} else {
clearInterval(timer);
alert('Game Over! You ran out of time.');
resetGame();
}
}, 1000);
}

function resetGame() {
energy = 100;
score = 0;
level = 1;
litterCount = 10;
energyRegenRate = 1;
timeLeft = 60;
litterContainer.innerHTML = '';
treesContainer.innerHTML = '';
createLitter();
startTimer();
updateStats();
}

plantTreeButton.addEventListener('click', plantTree);
upgradeButton.addEventListener('click', upgrade);

setInterval(() => {
if (energy < 100) {
energy = Math.min(100, energy + energyRegenRate);
updateStats();
}
}, 1000);

createLitter();
startTimer();
updateStats();
34 changes: 34 additions & 0 deletions Games/Eco_Warrior/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Eco Warrior</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="game-container">
<header>
<h1>Eco Warrior</h1>
<div id="stats">
<p>Energy: <span id="energy">100</span></p>
<p>Score: <span id="score">0</span></p>
<p>Level: <span id="level">1</span></p>
<p>Time Left: <span id="timer">60</span>s</p>
</div>
</header>
<div id="game-area">
<div id="instructions">
<p>Clean up the litter by clicking on it. Plant trees to increase your impact score. Energy regenerates over time.</p>
</div>
<div id="litter"></div>
<div id="trees"></div>
</div>
<footer>
<button id="plant-tree">Plant Tree (-10 Energy)</button>
<button id="upgrade" disabled>Upgrade: Energy Booster (-50 Score)</button>
</footer>
</div>
<script src="game.js"></script>
</body>
</html>
93 changes: 93 additions & 0 deletions Games/Eco_Warrior/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
body {
font-family: 'Arial', sans-serif;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #e0f7fa;
}

#game-container {
width: 800px;
max-width: 100%;
border: 2px solid #00897b;
border-radius: 10px;
background-color: #ffffff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
overflow: hidden;
}

header {
background-color: #004d40;
color: white;
padding: 20px;
text-align: center;
}

#stats {
display: flex;
justify-content: space-around;
background-color: #00796b;
padding: 10px;
border-radius: 10px;
margin-top: 10px;
}

#game-area {
position: relative;
padding: 20px;
height: 400px;
background-color: #c8e6c9;
border-radius: 10px;
}

#instructions {
margin-bottom: 20px;
background-color: #80cbc4;
padding: 10px;
border-radius: 5px;
text-align: center;
color: white;
font-weight: bold;
}

footer {
background-color: #004d40;
color: white;
text-align: center;
padding: 10px;
}

button {
background-color: #00796b;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
margin: 5px;
}

button:disabled {
background-color: #004d40;
cursor: not-allowed;
}

.litter, .tree {
position: absolute;
width: 40px;
height: 40px;
cursor: pointer;
background-size: cover;
background-repeat: no-repeat;
}

.litter {
background-image: url('assets/litter.png');
}

.tree {
background-image: url('assets/tree.png');
}
12 changes: 1 addition & 11 deletions README.md
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure you added your game entry in this file and also that merge conflicts are resolved

Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ This repository also provides one such platforms where contributers come over an
| Game | Game | Game | Game | Game |
| ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------- |
| [Master Typing](https://github.com/kunjgit/GameZone/tree/main/Games/Master_Typing) | [Treasure Hunt](https://github.com/Antiquely3059/GameZone/tree/main/Games/Treasure%20Hunt) | [Virtual Pet](https://github.com/Antiquely3059/GameZone/tree/main/Games/Virtual_Pet) | [MazeRunner](https://github.com/kunjgit/GameZone/tree/main/Games/MazeRunner) | [Ping_Pong_Singleplayer](https://github.com/kunjgit/GameZone/tree/main/Games/Ping_Pong_Singleplayer) | |
| [Tilting Maze](https://github.com/kunjgit/GameZone/tree/main/Games/Tilting_Maze) | [Simon Game Challenge](https://github.com/kunjgit/GameZone/tree/main/Games/Simon_Game_Challenge) | [Snake Game](https://github.com/kunjgit/GameZone/tree/main/Games/Snake_Game) | [Dino Runner Game](https://github.com/kunjgit/GameZone/tree/main/Games/Dino_Runner_Game) |
| [Eco Warrior](https://github.com/kunjgit/GameZone/tree/main/Games/Eco_Warrior) | [Tilting Maze](https://github.com/kunjgit/GameZone/tree/main/Games/Tilting_Maze) | [Simon Game Challenge](https://github.com/kunjgit/GameZone/tree/main/Games/Simon_Game_Challenge) | [Snake Game](https://github.com/kunjgit/GameZone/tree/main/Games/Snake_Game) | [Dino Runner Game](https://github.com/kunjgit/GameZone/tree/main/Games/Dino_Runner_Game) |
| [Whack a Mole](https://github.com/kunjgit/GameZone/tree/main/Games/Whack_a_Mole) | [Doraemon Jump](https://github.com/kunjgit/GameZone/tree/main/Games/Doraemon_Jump) | [Black Jack](https://github.com/kunjgit/GameZone/tree/main/Games/Black_Jack) | [Memory Game](https://github.com/kunjgit/GameZone/tree/main/Games/Memory_Game) | [Word Guessing Game](https://github.com/kunjgit/GameZone/tree/main/Games/Word_Guessing_Game) |
| [Ludo Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ludo_Game) | [Piano Game](https://github.com/kunjgit/GameZone/tree/main/Games/Piano) | [Atari Breakout](https://github.com/kunjgit/GameZone/tree/main/Games/Atari_Breakout) | [Dinosaur Game](https://github.com/kunjgit/GameZone/tree/main/Games/Chrome_Dinosaur_Game) | [Guess The Colour by RGB Game](https://github.com/kunjgit/GameZone/tree/main/Games/Colour_Guessing_Game) |
| [Guess The Number](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Number) | [Race car game](https://github.com/kunjgit/GameZone/tree/main/Games/race_car) | [Aim Training](https://github.com/DP-NOTHING/GameZone/tree/contri/Games/Aim_Training) | [Alien Shooter](https://github.com/kunjgit/GameZone/tree/main/Games/Alien_Shooters) | [Fruit Ninja](https://github.com/kunjgit/GameZone/tree/main/Games/Fruit_Ninja) |
Expand Down Expand Up @@ -785,16 +785,7 @@ This repository also provides one such platforms where contributers come over an
| [Bunny is Lost](https://github.com/kunjgit/GameZone/tree/main/Games/Bunny_is_Lost)|
|[Steam_Punk](https://github.com/kunjgit/GameZone/tree/main/Games/Steam_Punk)|
|[Tower Defence Game](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Tower_Defence_Game)|
<<<<<<< HEAD

=======
|[Ghost Busting Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ghost_busting_game)|
Antiquely3059 marked this conversation as resolved.
Show resolved Hide resolved
|[Wheel_of_fortune](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Wheel_of_fortune)|
|[Dot_Box_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Dot_Box_Game)|
| [Cosmic_Blast](https://github.com/kunjgit/GameZone/tree/main/Games/Cosmic_Blast) |
|[Mole](https://github.com/taneeshaa15/GameZone/tree/main/Games/Mole)|
|[Pottery-Game](https://github.com/kunjgit/GameZone/tree/main/Games/Pottery-Game)|
>>>>>>> c24ab932e1702441882a65b80d713ea232e18c46


|[Wheel_of_Fortunes](https://github.com/Saipradyumnagoud/GameZone/tree/main/Games/Wheel_of_Fortunes)|
Expand Down Expand Up @@ -860,4 +851,3 @@ Terms and conditions for use, reproduction and distribution are under the [Apach
</center>
<br>

<p align="right"><a href="#top">Back to top</a></p>
Binary file added assets/images/Eco_Warrior.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.