Skip to content

Commit

Permalink
Plant simulation(New Project) (#645)
Browse files Browse the repository at this point in the history


https://github.com/user-attachments/assets/48ff50c6-890a-4b91-9d9f-fc67ff5f0aee

Project Description:
This is an interactive web-based simulation designed to visually
demonstrate the growth stages of a plant as it receives water and
sunlight. Users can interact with the plant by adding water and
sunlight, observing its transformation from a seed to a fully grown
tree. It aims to educate users about plant growth and care through a
simple, engaging interface.

Features:
Interactive Plant Growth Simulation: The plant's growth is triggered by
the user clicking on water and sunlight buttons.
Dynamic Image Updates: The plant’s image updates in stages as water and
sunlight are added, showing the plant’s progress from seed to sapling,
young plant, flowering plant, and tree.
Growth Stages: The plant transitions through four stages:
Seed
Sapling
Young Plant (Veretation)
Flowering Plant
Tree
Visual and Textual Feedback: The plant’s image and corresponding text
description are updated to reflect the current growth stage.
Disclaimer for Proper Usage: A message warns users to add water and
sunlight only once per stage to avoid issues in the simulation.
User-Friendly Interface: Simple and intuitive buttons to simulate water
and sunlight additions, with clear visual feedback on progress.
Educational Purpose: Helps users understand how water and sunlight
contribute to plant growth.
  • Loading branch information
dhairyagothi authored Jan 24, 2025
2 parents d6c8029 + 8965e42 commit 6caf81d
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 0 deletions.
Binary file added public/Plant/images/R.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 public/Plant/images/back.webp
Binary file not shown.
Binary file added public/Plant/images/flowering.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 public/Plant/images/sap3.webp
Binary file not shown.
Binary file added public/Plant/images/sapling2.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 public/Plant/images/seeds.webp
Binary file not shown.
Binary file added public/Plant/images/stage-2-veretation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions public/Plant/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>
Plant Growth stimulation
</h1>


<div class="container">
<div class="content">
<button class="water" onclick="waterclicked()">Add more Water</button>
<img id="image" src="images\seeds.webp" height="200px" title="Seeds">
<button class="sunlight" onclick="sunlightclicked()">Add more Sunlight</button>
<br>
</div>
<p id="data" style="color: white;font-weight: bold;font-size: 40px;">Seeds</p>
<p style="color:white;" id="dis">Disclaimer:Please add water and sunlight only once per step to progress to the next stage. Repeatedly adding them may cause unexpected issues.</p>
</div>
<script src="script.js"></script>
</body>
</html>
36 changes: 36 additions & 0 deletions public/Plant/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
let water=0;
let sunlight=0;

function waterclicked(){
water++;
changesimage();
}

function sunlightclicked(){
sunlight++;
changesimage();
}

function changesimage(){
if(water==1 && sunlight==1){
document.getElementById("image").src = "images/sap3.webp";
document.getElementById("image").title= "Sapling";
document.getElementById("data").innerHTML= "Sapling";

}
if(water==2 && sunlight==2){
document.getElementById("image").src = "images/stage-2-veretation.png";
document.getElementById("image").title= "Young Plant(Vereation)";
document.getElementById("data").innerHTML= "Young plant";
}
if(water==3 && sunlight==3){
document.getElementById("image").src = "images/flowering.png";
document.getElementById("image").title= "Flowering Plant";
document.getElementById("data").innerHTML= "Flowering Plant";
}
if(water==4 && sunlight==4){
document.getElementById("image").src = "images/R.png";
document.getElementById("image").title= "Tree";
document.getElementById("data").innerHTML= "Tree";
}
}
77 changes: 77 additions & 0 deletions public/Plant/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

body{
background: url("images/back.webp");
background-color: black;
width: 100%;
height: 100vh;
background-repeat: no-repeat;
background-position: center center;
flex-direction: column;
display: flex;

justify-content: center;
align-items: center;
margin: 0;

}
body h1{
background-color: black;
padding: 8px;
border: solid white 10px;
border-radius: 10px;
color:rgb(239, 242, 239);
text-align: center;
margin-top: 70px;
font-size: 50px;
}
.image{
margin: 40px 40px;
padding: 30px;
}
button{
cursor: pointer;
padding: 0 20px;
}
.container{
background-color: black;
width: 60%;
height: 70%;
padding: 20px;
border-radius: 10px;
display: flex;
justify-content: space-around;
align-items: center;
border:solid white 10px;
flex-direction: column;

}
.content{
background-color: black;



display: flex;
justify-content: space-around;
align-items: center;

}


.water{
background-color: blue;
color: white;
font-weight: bold;
padding: 6px;
border-radius: 10px;
border: solid white 2px;
}
.sunlight{
background-color: yellow;
color: black;
font-weight: bold;
padding: 6px;
border-radius: 10px;
border: solid white 2px;
text-align: right;
margin-right: 10px;
}

0 comments on commit 6caf81d

Please sign in to comment.