Skip to content

Commit

Permalink
init,add the grid elements, add the matrix of Cell
Browse files Browse the repository at this point in the history
  • Loading branch information
modouaicha023 committed Nov 15, 2023
0 parents commit a94d445
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 0 deletions.
22 changes: 22 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Game Of Life</title>
<link rel="stylesheet" href="style.css">
</head>

<body>
<h1>Game of Life</h1>
<div class="grid"></div>

<div class="">
<button id="play"><img src="https://cdn-icons-png.flaticon.com/512/0/375.png" alt="play button"></button>
</div>

<script src="script.js"></script>
</body>

</html>
28 changes: 28 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const rows = 100;
const cols = 100;

let cellsMatrix = createEmptyMatrix();


createCellsElements();


function createEmptyMatrix() {
return Array.from({ length: rows }, () => Array(cols).fill(false));
}

console.log(createEmptyMatrix())


function createCellsElements() {
const gridContainer = document.querySelector('.grid');

for (let row = 0; row < rows; row++) {
for (let col = 0; col < cols; col++) {
const cell = document.createElement('div');
cell.className = 'cell';
gridContainer.appendChild(cell);
}
}
}

67 changes: 67 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
@import url('https://fonts.googleapis.com/css2?family=Black+Ops+One&display=swap');

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
flex-direction: column;
gap: 20px;
background: -webkit-linear-gradient(#e2e79b, #948fbe);
background-clip: border-box;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}

h1 {
font-size: clamp(32px, 4vw, 48px);
font-family: 'Black Ops One', sans-serif;
background: -webkit-linear-gradient(#c96b6b, #5c4edb);
background-clip: border-box;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}

.grid {
padding: 5px;
display: grid;
grid-template-columns: repeat(100, 20px);
overflow: scroll;
width: 90%;
height: 50%;
background-color: white;
}

.cell {
width: 20px;
height: 20px;
border: 1px solid #ccc;
}

.alive {
background-color: yellow;
}

#play {
background-color: transparent;
color: transparent;
border: none;
}

#play img {
width: 64px;
height: 64px;
}


#play img:hover {
cursor: pointer;
opacity: 80%;
}

0 comments on commit a94d445

Please sign in to comment.