-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
929cbd3
commit 11917cc
Showing
8 changed files
with
156 additions
and
11 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
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
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
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
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,54 @@ | ||
html { | ||
width: 100vw; | ||
height: 100vh; | ||
} | ||
|
||
body { | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
row-gap: 2rem; | ||
align-items: center; | ||
justify-content: center; | ||
margin: 0; | ||
} | ||
|
||
#canvas { | ||
width: 320px; | ||
height: 320px; | ||
border: 5px solid black; | ||
/* display: flex; | ||
flex-wrap: wrap; */ | ||
display: grid; | ||
grid-template-columns: repeat(10, 1fr); | ||
grid-template-rows: repeat(10, 1fr); | ||
} | ||
|
||
.canvas-cubes { | ||
border: 1px solid blue; | ||
/* width: calc(100% / 10); */ | ||
/* height: calc(100% / 10); */ | ||
box-sizing: border-box; | ||
} | ||
|
||
#controls-column { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
row-gap: 0.5rem; | ||
/* border: 3px solid black; */ | ||
} | ||
|
||
#controls-column #up, | ||
#down, | ||
#controls-row #left, | ||
#right { | ||
width: 2rem; | ||
aspect-ratio: 1/1; | ||
} | ||
|
||
#controls-row { | ||
display: flex; | ||
column-gap: 3rem; | ||
} |
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,26 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="icon" href="../static/jsSnake_favicon.svg" /> | ||
<link rel="stylesheet" href="./snake.css" /> | ||
<title>Snake</title> | ||
</head> | ||
<body> | ||
<h2 id="score-heading">Score</h2> | ||
<span id="score-result">0</span> | ||
<div id="canvas"></div> | ||
<div id="controls"> | ||
<div id="controls-column"> | ||
<button id="up">↑</button> | ||
<div id="controls-row"> | ||
<button id="left">←</button> | ||
<button id="right">→</button> | ||
</div> | ||
<button id="down">↓</button> | ||
</div> | ||
</div> | ||
<script src="./snake.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,11 @@ | ||
let canvas = document.getElementById('canvas'); | ||
|
||
for (let i = 0; i < 100; i++) { | ||
let canvasCube = document.createElement('div'); | ||
canvasCube.classList.add('canvas-cubes'); | ||
canvasCube.setAttribute('id', i); | ||
canvasCube.textContent = i; | ||
canvas.appendChild(canvasCube); | ||
} | ||
|
||
/* Now I am thinking to add a sprite class, which has a draw(),undraw(),add() methods */ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.