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

Fruit Slicer #4473

Merged
merged 6 commits into from
Jun 15, 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
26 changes: 26 additions & 0 deletions Games/Fruit_Slicer_Game/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# **Fruit Slicer**

---

<br>

## **Description 📃**
Fruit Slider is a fun and engaging puzzle game where players slide fruit pieces on a grid to align them in a specific order or pattern. The objective is to complete the puzzle in the fewest moves possible.

## **functionalities 🎮**
Random fruits are generated and tossed onto the screen from different angles and at varying speeds. This randomness keeps the game challenging and unpredictable.
Each successful slice adds points to the player’s score. Some fruits may offer bonus points or special effects when sliced, adding an extra layer of strategy.

<br>

## **How to play? 🕹️**
Fruits will randomly appear.
The player will attempt to slice the fruits.
The game will keep track of the score based on successfully sliced fruits.

<br>

## **Screenshots 📸**

<br>
![alt text](image.png)
Binary file not shown.
Binary file added Games/Fruit_Slicer_Game/assets/bg3 - Copy.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/Fruit_Slicer_Game/assets/image.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/Fruit_Slicer_Game/assets/slicefruit.ogg
Binary file not shown.
Binary file added Games/Fruit_Slicer_Game/assets/slicefruit.wav
Binary file not shown.
Binary file added Games/Fruit_Slicer_Game/assets/splash.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/Fruit_Slicer_Game/assets/wood-bg2.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/Fruit_Slicer_Game/assets/wrong.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions Games/Fruit_Slicer_Game/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Fruit Slicer Game</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
</head>
<body>
<div id="container">
<div id="instructions">
Slice Fruits
</div>
<div id="fruitcontainer">
<div id="score">
<div class="scoreDisplay">
<span id="scoreValue">0</span></div>
</div>
<div id="trialsleft"></div>
<div id="front">
Are you ready for the ultimate slice action ? <br/>
<img src="./assets/splash.png" alt="Fruit logo">
</div>
<img id="fruit1" class="fruit">
</div>
<div id="startReset">
Start Game
</div>
<!--for game over block-->
<div id="gameOver"></div>
</div>
<!--for audio files-->
<audio id="slicesound">
<source src="./assets/slicefruit.mp3"></source>
<source src="./assets/slicefruit.ogg"></source>
<source src="./assets/slicefruit.wav"></source>
</audio>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script src="script.js"></script>
</body>
</html>
134 changes: 134 additions & 0 deletions Games/Fruit_Slicer_Game/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
var playing = false;
var score;
var trialsleft;
var step;//for random steps
var action;//for settime interval
var fruits = ['1','2','3','4','5','6','7','8','9','10'];//for fruits

$(function(){
//click on start or reset button
$('#front').show();
$("#startReset").click(function () {
if(playing == true){
//if we are playing
location.reload();//reload page
}else{
//if we are not playing from before
$('#front').hide();
$('#score').show();
playing = true;
//set score to 0
score = 0;
$("#scoreValue").html(score);

//show trials left box

$('#trialsleft').show();
trialsleft=3;
addhearts();

//hide game over box
$('#gameOver').hide();

//change button to reset game
$('#startReset').html('Reset Game')


//start action
startAction();
}
});
//slice a fruit
$("#fruit1").mouseover(function () {
score++;// increase score
$("#scoreValue").html(score);

//play sound
$("#slicesound")[0].play();

//stop fruit
clearInterval(action);

//hide fruit
$('#fruit1').hide("explode",500);//slice fruit

//send new fruit
setTimeout(startAction,500);
});


//functions

//addhearts
function addhearts() {
$('#trialsleft').empty();
for(i = 0 ; i < trialsleft ; i++){
$('#trialsleft').append('<img src="./assets/wrong.png" , class="life">');
}
}

//start action
function startAction(){
//generate random fruit
$('#fruit1').show();

//choose random fruit
chooseRandom();
//random position
$('#fruit1').css({
'left': Math.round(550 * Math.random()),
'top': -50
});
//generate random step
step=1 + Math.round(5 * Math.random());//change steps
//descend fruits down by 10ms
action = setInterval(function(){
//move fruit by one step
$('#fruit1').css('top', $('#fruit1').position().top + step);

//check if the fruit is too low
if($('#fruit1').position().top > $('#fruitcontainer').height()-50){
//yes it is low
// check trails left
if(trialsleft > 1){
//generate a fruit
$("#fruit1").show();
//choose random fruit
chooseRandom();
//random position
$('#fruit1').css({
'left': Math.round(550 * Math.random()),
'top': -50
});
//generate random step
step= 1 + Math.round(5 * Math.random());//change steps

//reduce trials by one
trialsleft--;
//populate trails left box by one
addhearts();

}else{
//game over
playing=false;//we are ot playing any more
$("#score").hide();
$('#startreset').html('Start Game');
$('#gameOver').show();
$('#gameOver').html('<p>Game Over!</p><p>Your score is '+ score + '</p>');
$('#trialsleft').hide();
stopAction();//stops Action
}
}
},10);
}

//choose random fruits
function chooseRandom(){
$('#fruit1').attr('src','https://raw.githubusercontent.com/Saumya-07/Fruit-Slicer/master/images/' + fruits[Math.round(9*Math.random())]+'.png');
}
// Stop Action
function stopAction(){
clearInterval(action);
$('#fruit1').hide();
}
});
128 changes: 128 additions & 0 deletions Games/Fruit_Slicer_Game/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
html {
height: 100%;
background: radial-gradient(circle, #fff, rgb(189, 182, 182));
background-image: url(./assets/bg3\ -\ Copy.jpg);
background-size: cover;
font-family: cursive, sans-serif;
}
#container {
width: 750px;
height: 600px;
margin: 10px auto;
padding: 20px;
border-radius: 10px;
position: relative;
}

#front {
font-size: 40px;
color: #d3901d;
width: 650px;
height: 450px;
padding: 10px;
margin: 30px auto 20px auto;
z-index: 2;
display: none;
}
#front img {
width: 280px;
}
#instructions {
width: 450px;
height: 50px;
margin: 10px auto;
font-size: 30px;

background-color: #d3901d;
color: #2e1d11;
text-align: center;
line-height: 50px;
border-radius: 20px;
box-shadow: 0px 4px 0px 0px #775012;
}
#fruitcontainer {
background: url(./assets/wood-bg2.jpg);
background-size: cover;
width: 650px;
height: 450px;
padding: 10px;
margin: 30px auto 20px auto;
background-color: white;
color: black;
text-align: center;
font-family: cursive, sans-serif;
overflow: hidden;
border-radius: 20px;
box-shadow: 0px 4px 0px 0px #4b4b4e;
position: relative;
}

.fruit {
display: none;
position: absolute;
}
#score {
display: none;
}
.scoreDisplay {
z-index: 1;
display: flex;
background-color: transparent;
color: #888e61;
position: absolute;
font-size: 30px;
justify-items: center;
}

#score img {
width: 40px;
align-items: center;
padding-right: 5px;
}
#trialsleft {
margin-top: 7px;
display: flex;
position: absolute;
left: 550px;
background-color: transparent;
z-index: 1;
}
.life {
width: 30px;
padding-right: 5px;
}

#startReset {
position: relative;
width: 90px;
padding: 10px;
margin: 0 auto;

cursor: pointer;
text-align: center;
background-color: #8d8315;
box-shadow: 0px 4px 0px 0px #5c5619;
border-radius: 5px;
transition: all 0.2s;
}
#startReset:active {
background-color: #69620c;
box-shadow: 0px 0px #5c5619;
top: 4px;
color: white;
}

#gameOver {
box-sizing: border-box;
width: 500px;
height: 300px;
background: transparent;
color: #d3901d;
text-transform: upperCase;
text-align: center;
font-size: 3em;
position: absolute;
top: 170px;
left: 150px;
z-index: 2;
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,15 @@ This repository also provides one such platforms where contributers come over an
| [Intellect Quest](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Intellect_Quest) |
| [Taash_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Taash_Game) |
| [Number_Guessing_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Number_Guessing_Game) |
| [Fruit_Slicer_Game] (https://github.com/narayani9120/GameZone_B/tree/main/Games/Fruit_Slicer_Game) |
| [Tower_Block_Game](https://github.com/Saipradyumnagoud/GameZone/tree/main/Games/Tower_Block_Game) |
| [Modulo_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Modulo_Game) |
| [Block_Ninja] (https://github.com/kunjgit/GameZone/tree/main/Games/Block_Ninja) |
| [Disney_Trivia](https://github.com/manmita/GameZone/tree/Disney_Trivia/Games/Disney_Trivia)|
|[Harmony_Mixer](https://github.com/kunjgit/GameZone/tree/main/Games/Harmony_Mixer)|



</center>

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