Skip to content

Commit

Permalink
New Game added
Browse files Browse the repository at this point in the history
  • Loading branch information
Nayanika1402 committed Jul 28, 2024
1 parent 1fe308f commit 21ac8d0
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 0 deletions.
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;
}
55 changes: 55 additions & 0 deletions additionalpage/game.html
Original file line number Diff line number Diff line change
Expand Up @@ -4003,6 +4003,61 @@ <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"
alt="">
<div class="ratings-count">
241
<img src="../assets/icons/star-black.svg" alt="" class="ms-2">
</div>
</div>
<div class="game-card-bottom">
<div class="share-icon text-2xl" onclick="copyLink(this)">
<i class="fas fa-share-alt"></i>
<input type="hidden"
value="https://gamesphere-multiplayer.github.io/GameSphere/SinglePlayer%20-%20Games/Pixel%20Painter/index.html" />
</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>
</div>
<div class="star-rating mt-2 sm:mt-0 py-1">
<img src="../assets/icons/star-green.svg">
<img src="../assets/icons/star-green.svg">
<img src="../assets/icons/star-green.svg">
<img src="../assets/icons/star-green.svg">
<img src="../assets/icons/star-green-half.svg">
</div>
</div>
<div class="block-wrap flex justify-between items-end">
<div class="details-group">
<div class="flex items-center">
<p class="font-semibold">Release Date: &nbsp;</p>
<p>29.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>
</div>
</div>
</div>
</div>
<!--card end-->



<!--Card start-->
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 21ac8d0

Please sign in to comment.