-
Notifications
You must be signed in to change notification settings - Fork 839
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
Closed
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ac7b8b0
Add files via upload
Antiquely3059 75fb237
Create README.md
Antiquely3059 0a7e610
Add files via upload
Antiquely3059 7d57b4e
Update README.md
Antiquely3059 00897ed
Update README.md
Antiquely3059 712d0d9
Merge branch 'kunjgit:main' into main
Antiquely3059 aa57be1
Delete Games/Eco Warrior directory
Antiquely3059 c940572
Add files via upload
Antiquely3059 cbdba3e
Update README.md
Antiquely3059 a9c8046
Merge branch 'main' into main
Antiquely3059 31aa780
Merge branch 'main' into main
Antiquely3059 27e42cf
Merge branch 'main' into main
Antiquely3059 482979b
Merge branch 'main' into main
Antiquely3059 00e4a90
Merge branch 'main' into main
Antiquely3059 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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