Skip to content

Commit

Permalink
Doodling_Game is added
Browse files Browse the repository at this point in the history
  • Loading branch information
pallasivasai committed Jul 9, 2024
1 parent 0ceb11b commit bf4c447
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ ________________________________________________________________________________
| 198 | [Ball_Fall_Game](.SinglePlayer%20-%20Games/Ball_Fall_Game) |
| 199 | [City_Builder_Game](.SinglePlayer%20-%20Games/City_Builder_Game) |
| 202 | [Cooking_Challenge Game](.SinglePlayer%20-%20Games/Cooking_Challenge Game) |
| 203 | [Doodling_Game](.SinglePlayer%20-%20Games/Doodling_Game) |



Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions SinglePlayer - Games/Doodling_Game/READme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Doodling Game

A simple doodling game where users can draw on a canvas, change colors, and adjust the brush size. This game supports both mouse and touch inputs, making it suitable for both desktop and mobile devices.

## Features

- Draw on the canvas using mouse or touch inputs.
- Change the color of the brush using a color picker.
- Adjust the brush size using a range slider.
- Clear the canvas with a single click.

## Demo

![Doodling Game Demo](demo.gif)

## How to Run

1. Clone the repository or download the files.
2. Open the `index.html` file in your preferred web browser.

## Files

- `index.html`: The main HTML file containing the structure of the doodling game.
- `styles.css`: The CSS file for styling the doodling game.
- `script.js`: The JavaScript file containing the logic for the doodling game.

18 changes: 18 additions & 0 deletions SinglePlayer - Games/Doodling_Game/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Doodling Game</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="toolbar">
<button id="clear">Clear</button>
<input type="color" id="colorPicker">
<input type="range" id="sizePicker" min="1" max="10" value="5">
</div>
<canvas id="drawingCanvas"></canvas>
<script src="script.js"></script>
</body>
</html>
72 changes: 72 additions & 0 deletions SinglePlayer - Games/Doodling_Game/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const canvas = document.getElementById('drawingCanvas');
const ctx = canvas.getContext('2d');

canvas.width = window.innerWidth * 0.8;
canvas.height = window.innerHeight * 0.8;

let painting = false;
let color = '#000';
let lineWidth = 5;

function startPosition(e) {
painting = true;
draw(e);
}

function endPosition() {
painting = false;
ctx.beginPath();
}

function draw(e) {
if (!painting) return;

ctx.lineWidth = lineWidth;
ctx.lineCap = 'round';
ctx.strokeStyle = color;

ctx.lineTo(e.clientX - canvas.offsetLeft, e.clientY - canvas.offsetTop);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(e.clientX - canvas.offsetLeft, e.clientY - canvas.offsetTop);
}

canvas.addEventListener('mousedown', startPosition);
canvas.addEventListener('mouseup', endPosition);
canvas.addEventListener('mousemove', draw);

// Touch support for mobile devices
canvas.addEventListener('touchstart', (e) => {
const touch = e.touches[0];
const mouseEvent = new MouseEvent('mousedown', {
clientX: touch.clientX,
clientY: touch.clientY
});
canvas.dispatchEvent(mouseEvent);
});

canvas.addEventListener('touchend', () => {
const mouseEvent = new MouseEvent('mouseup', {});
canvas.dispatchEvent(mouseEvent);
});

canvas.addEventListener('touchmove', (e) => {
const touch = e.touches[0];
const mouseEvent = new MouseEvent('mousemove', {
clientX: touch.clientX,
clientY: touch.clientY
});
canvas.dispatchEvent(mouseEvent);
});

document.getElementById('clear').addEventListener('click', () => {
ctx.clearRect(0, 0, canvas.width, canvas.height);
});

document.getElementById('colorPicker').addEventListener('change', (e) => {
color = e.target.value;
});

document.getElementById('sizePicker').addEventListener('change', (e) => {
lineWidth = e.target.value;
});
16 changes: 16 additions & 0 deletions SinglePlayer - Games/Doodling_Game/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
body {
margin: 0;
display: flex;
flex-direction: column;
align-items: center;
background-color: #f0f0f0;
}

.toolbar {
margin: 20px;
}

#drawingCanvas {
border: 1px solid #000;
background-color: #fff;
}
53 changes: 53 additions & 0 deletions additionalpage/game.html
Original file line number Diff line number Diff line change
Expand Up @@ -7344,6 +7344,59 @@ <h4 class = "text-white uppercase game-card-title">Cooking_Challenge Game</h4>



<!--Card start-->
<div class = "game-card">
<div class = "game-card-top img-fit-cover">
<video src="https://drive.google.com/file/d/196cu13TDdMGKB0tdX57ynDBGmb1sf894/view?usp=drive_link" link " type="video/mp4" muted loop class="clip" ></video>
<img src = "../SinglePlayer - Games/Banner - images/Doodling_Game.png" alt = "">
<div class = "ratings-count">
45
<img src = "../SinglePlayer - Games/Banner - images/Doodling_Game.png" 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/Doodling_Game/index.html" />
<!--If there are spaces in your naming of folder, put %20 in between, ex:
link%20to%20the%html%file%20for%your&game-->

<!--The share link will be active only when it is deployed over website-->
</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">Doodling_Game</h4>
<p class = "para-text">Doodling_Game</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>20.06.2023</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/Doodling_Game/index.html" class = "btn-primary uppercase">Play Now</a>
</div>
</div>
</div>
</div>
<!--Card end-->




Expand Down

0 comments on commit bf4c447

Please sign in to comment.