Skip to content

Commit

Permalink
Merge pull request #1098 from Nayanika1402/game
Browse files Browse the repository at this point in the history
New Game added
  • Loading branch information
Durgesh4993 authored Aug 9, 2024
2 parents 86ff516 + d775a4f commit 507cc3a
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ ________________________________________________________________________________
| 202 | [Doodling_Game](.SinglePlayer%20-%20Games/Doodling_Game) |
| 203 | [Duck_Hunt_Game](.SinglePlayer%20-%20Games/Duck_Hunt_Game) |
| 204 | [Breakout_Game](.SinglePlayer%20-%20Games/BreakOut_Game) |
| 205 | [Breakout_Game](.SinglePlayer%20-%20Games/Maze_Game) |

| 208 | [Pixel Painter](.SinglePlayer%20-%20Games/Pixel%20Painter) |
| 206 | [Breakout_Game](.SinglePlayer%20-%20Games/Bomber_Game) |

| 205 | [Maze_Game](.SinglePlayer%20-%20Games/Maze_Game) |
| 206 | [Bomber_Game](.SinglePlayer%20-%20Games/Bomber_Game) |
| 207 | [Tug of War ](.SinglePlayer%20-%20Games/Tug_of_war) |
Expand All @@ -275,6 +280,7 @@ ________________________________________________________________________________
| 217 | [Brick_Breaker_Game](.SinglePlayer%20-%20Games/Brick_Breaker_Game) |
| 218 | [Bash_Mole_Game](.SinglePlayer%20-%20Games/Bash_Mole_Game) |


</div>

<div>
Expand Down
Binary file added SinglePlayer - Games/Pixel Painter/Images/ss1.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 SinglePlayer - Games/Pixel Painter/Images/ss2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions SinglePlayer - Games/Pixel Painter/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pixel Painter</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id="toolbar">
<input type="color" id="colorPicker" value="#000000">
<button id="clearButton">Clear</button>
<button id="undoButton">Undo</button>
</div>
<div id="canvasContainer" style="position: relative;">
<canvas id="pixelCanvas" width="600" height="600"></canvas>
<div id="grid"></div>
</div>
<script src="script.js"></script>
</body>
</html>
53 changes: 53 additions & 0 deletions SinglePlayer - Games/Pixel Painter/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// script.js
document.addEventListener('DOMContentLoaded', () => {
const canvas = document.getElementById('pixelCanvas');
const ctx = canvas.getContext('2d');
const colorPicker = document.getElementById('colorPicker');
const clearButton = document.getElementById('clearButton');
const undoButton = document.getElementById('undoButton');
let drawing = false;
let color = colorPicker.value;
let undoStack = [];

// Initialize canvas
ctx.fillStyle = '#fff';
ctx.fillRect(0, 0, canvas.width, canvas.height);

canvas.addEventListener('mousedown', () => drawing = true);
canvas.addEventListener('mouseup', () => drawing = false);
canvas.addEventListener('mousemove', draw);
colorPicker.addEventListener('input', (e) => {
color = e.target.value;
colorPicker.style.borderColor = color;
});
clearButton.addEventListener('click', clearCanvas);
undoButton.addEventListener('click', undo);

canvas.addEventListener('mousedown', saveState);

function draw(event) {
if (!drawing) return;
const rect = canvas.getBoundingClientRect();
const x = event.clientX - rect.left;
const y = event.clientY - rect.top;
ctx.fillStyle = color;
ctx.fillRect(Math.floor(x / 10) * 10, Math.floor(y / 10) * 10, 10, 10);
}

function clearCanvas() {
ctx.fillStyle = '#fff';
ctx.fillRect(0, 0, canvas.width, canvas.height);
}

function saveState() {
undoStack.push(ctx.getImageData(0, 0, canvas.width, canvas.height));
if (undoStack.length > 10) undoStack.shift(); // Limit stack size
}

function undo() {
if (undoStack.length > 0) {
const imgData = undoStack.pop();
ctx.putImageData(imgData, 0, 0);
}
}
});
52 changes: 52 additions & 0 deletions SinglePlayer - Games/Pixel Painter/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* styles.css */
body {
display: flex;
flex-direction: column;
align-items: center;
background-color: #f0f0f0;
font-family: Arial, sans-serif;
}

#toolbar {
margin: 20px;
}

button {
transition: background-color 0.3s, transform 0.3s;
}

button:hover {
background-color: #ddd;
transform: scale(1.1);
}

#colorPicker {
transition: box-shadow 0.3s;
}

#colorPicker:focus {
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

#canvasContainer {
position: relative;
}

#pixelCanvas {
border: 1px solid #000;
background-color: #fff;
cursor: crosshair;
position: relative;
}

#grid {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
background: linear-gradient(90deg, rgba(0,0,0,0.1) 1px, transparent 1px),
linear-gradient(rgba(0,0,0,0.1) 1px, transparent 1px);
background-size: 10px 10px;
}
27 changes: 27 additions & 0 deletions additionalpage/game.html
Original file line number Diff line number Diff line change
Expand Up @@ -4003,6 +4003,14 @@ <h4 class="text-white uppercase game-card-title">Ping Pong</h4>
</div>
<!--card end-->

<!--Card start-->

<!-- ---------- -->
<!-- Pixel Painter -->
<!-- ---------- -->
<div class="game-card">
<div class="game-card-top img-fit-cover">
<img src="https://github.com/avi-tech-test/git-branching-prac/assets/ss1.png"

<!--Card start-->

Expand All @@ -4022,6 +4030,14 @@ <h4 class="text-white uppercase game-card-title">Ping Pong</h4>
<div class="share-icon text-2xl" onclick="copyLink(this)">
<i class="fas fa-share-alt"></i>
<input type="hidden"
value="https://github.com/Nayanika1402/GameSphere/tree/game/SinglePlayer%20-%20Games/Pixel%20Painter" />
</div>
<div class="flex flex-col sm:flex-row justify-between items-start flex-wrap">
<div class="py-1">
<h4 class="text-white uppercase game-card-title">Pixel Painter</h4>
<p class="para-text">Pixel Painter is an interactive web-based drawing application that allows users to create pixel art.
It features a canvas for drawing, a color picker, an undo functionality,and a clear button.
The interface includes smooth animations and an intuitive user experience.</p>
value="https://gamesphere-multiplayer.github.io/GameSphere/SinglePlayer%20-%20Games/Plankman/index.html" />
</div>
<div class="flex flex-col sm:flex-row justify-between items-start flex-wrap">
Expand All @@ -4043,14 +4059,19 @@ <h4 class="text-white uppercase game-card-title">Ping Pong</h4>
<div class="details-group">
<div class="flex items-center">
<p class="font-semibold">Release Date: &nbsp;</p>
<p>29.07.2024</p>
<p>31.07.2024</p>

</div>
<div class="flex items-center">
<p class="font-semibold">Updated: &nbsp;</p>
<p>Action | Desktop</p>
</div>
</div>
<div class="flex flex-col items-end justify-between">

<a target="_blank" href="../SinglePlayer - Games/Pixel Painter/index.html"
class="btn-primary uppercase">play now</a>
<a target="_blank" href="../SinglePlayer - Games/Plankman/index.html"
class="btn-primary uppercase">Play now</a>
</div>
Expand Down Expand Up @@ -5314,14 +5335,20 @@ <h4 class="text-white uppercase game-card-title">Tetris</h4>
241
<img src="../assets/icons/star-black.svg" alt="" class="ms-2">



<!-- Snake_ ladder_ MATRICES... -->
<div class = "game-card">
<div class = "game-card-top img-fit-cover">
<img src = "../assets/images/snake-ladder.jpg" alt = "">
<div class = "ratings-count">


<img src = "../assets/icons/star-black.svg" alt = "" class = "ms-2">


<img src = "../assets/icons/star-black.svg" alt = "" class = "ms-2"

</div>
</div>
<div class = "game-card-bottom">
Expand Down
Binary file added assets/images/ss1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 507cc3a

Please sign in to comment.