Skip to content

Commit

Permalink
Added layout rules for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
ExtF8 committed Jul 22, 2023
1 parent d0af3d3 commit 3a946cc
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
9 changes: 6 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ <h1>Conway's Game of Life</h1>
Any dead cell with exactly three live neighbors becomes a
live cell (reproduction)
</li>
<br>
<br />
<li>
Click on the canvas to select initial live cells, then press 'Start' to watch the patterns evolve according to the rules.
Click on the canvas to select initial live cells, then press
'Start' to watch the patterns evolve according to the rules.
</li>
</ul>
</div>
<canvas id="gameCanvas" width="800" height="500"></canvas>
<div class="container">
<canvas id="gameCanvas"></canvas>
</div>
<div class="controls">
<button id="startBtn">Start</button>
<button id="stopBtn">Stop</button>
Expand Down
5 changes: 3 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
const canvas = document.getElementById('gameCanvas');
canvas.addEventListener('click', handleCanvasClick);
const ctx = canvas.getContext('2d');
canvas.width = 800;
canvas.height = 600;
const cellSize = 10;
const rows = canvas.height / cellSize;
const cols = canvas.width / cellSize;
Expand Down Expand Up @@ -39,13 +41,12 @@ document.getElementById('startBtn').addEventListener('click', () => {

function animate() {
setTimeout(() => {

updateGame();
drawGrid();
if (isAnimating) {
animationId = requestAnimationFrame(animate);
}
}, 100)
}, 100);
}
animate();
console.log('start');
Expand Down
41 changes: 40 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
@@ -1,19 +1,57 @@
html {
box-sizing: border-box;
}

* {
margin: 0;
padding: 0;
box-sizing: inherit;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-weight: normal;
}

body {
font-family: Arial, Helvetica, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
margin-top: 50px;
margin-top: 10px;
padding: 20px;
}

h1 {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
text-align: center;
font-weight: bolder;
text-transform: capitalize;
}

.container {
display: flex;
justify-content: center;
align-items: flex-start;
position: relative;
}

canvas {
border: 1px solid black;
margin: 10px;
}

@media (max-width: 768px) {
#gameCanvas {
width: 400px;
max-width: 98%;
height: auto;
}
}

@media (max-width: 768px) {
button {
padding: 15px 25px;
font-size: 18px;
margin-bottom: 15px;
}
}

.controls {
Expand All @@ -35,6 +73,7 @@ button {
list-style-type: none;
line-height: 1.2;
}

#howTo {
margin-bottom: 20;
}

0 comments on commit 3a946cc

Please sign in to comment.