-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init,add the grid elements, add the matrix of Cell
- Loading branch information
0 parents
commit a94d445
Showing
3 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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%; | ||
} |