Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f1346a628c | |||
| 343af77bd1 | |||
| 47fd5c7458 |
+12
-3
@@ -22,6 +22,7 @@ body {
|
|||||||
padding: 8px;
|
padding: 8px;
|
||||||
line-height: 21px;
|
line-height: 21px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
#top {
|
#top {
|
||||||
@@ -34,9 +35,19 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#main {
|
#main {
|
||||||
|
margin: 0px 120px;
|
||||||
|
display: flex;
|
||||||
/*background: #1e2030;*/
|
/*background: #1e2030;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.canvas {
|
||||||
|
width: 780px;
|
||||||
|
height: 600px;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
.cardStats {
|
.cardStats {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
@@ -121,9 +132,7 @@ a.button {
|
|||||||
.card {
|
.card {
|
||||||
background: #363a4f;
|
background: #363a4f;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border-radius: 6px;
|
border-radius: 18px;
|
||||||
border-top-left-radius: 18px;
|
|
||||||
border-top-right-radius: 18px;
|
|
||||||
animation: card 3s linear infinite;
|
animation: card 3s linear infinite;
|
||||||
width: 800px;
|
width: 800px;
|
||||||
height: 800px;
|
height: 800px;
|
||||||
|
|||||||
+11
-1
@@ -7,13 +7,14 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
|
<p class="navItem" style="text-align: left; flex-grow: 1;">Trianta</p>
|
||||||
<a class="navItem" href="https://www.github.com/trimutex">GitHub</a>
|
<a class="navItem" href="https://www.github.com/trimutex">GitHub</a>
|
||||||
<a class="navItem" href="https://lab.trianta.dev/Trianta">Projects</a>
|
<a class="navItem" href="https://lab.trianta.dev/Trianta">Projects</a>
|
||||||
<p class="navItem" style="text-align: right; flex-grow: 1;">Trianta</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h2 class="cardTop">Pong</h2>
|
<h2 class="cardTop">Pong</h2>
|
||||||
|
<div class="canvas">
|
||||||
<canvas width="750" height="585" id="pong"></canvas>
|
<canvas width="750" height="585" id="pong"></canvas>
|
||||||
<script src="public/pong.js"></script>
|
<script src="public/pong.js"></script>
|
||||||
<div id="gameover" hidden="true">
|
<div id="gameover" hidden="true">
|
||||||
@@ -22,14 +23,23 @@
|
|||||||
<div id="restart" hidden="true">
|
<div id="restart" hidden="true">
|
||||||
<button class="button" type="button" onclick = "restartGame()">Restart Game</a>
|
<button class="button" type="button" onclick = "restartGame()">Restart Game</a>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<p class="cardStats">Left Paddle Height: <span id="leftPaddle"></span></p>
|
<p class="cardStats">Left Paddle Height: <span id="leftPaddle"></span></p>
|
||||||
<p class="cardStats">Right Paddle Height: <span id="rightPaddle"></span></p>
|
<p class="cardStats">Right Paddle Height: <span id="rightPaddle"></span></p>
|
||||||
<a class="navItem" href="https://lab.trianta.dev/Trianta/trianta.dev/src/branch/main/src/pong.js">View Code</a>
|
<a class="navItem" href="https://lab.trianta.dev/Trianta/trianta.dev/src/branch/main/src/pong.js">View Code</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h2 class="cardTop">Snake</h2>
|
<h2 class="cardTop">Snake</h2>
|
||||||
|
<div class="canvas">
|
||||||
<canvas width="625" height="375" id="snake"></canvas>
|
<canvas width="625" height="375" id="snake"></canvas>
|
||||||
<script src="public/snake.js"></script>
|
<script src="public/snake.js"></script>
|
||||||
|
</div>
|
||||||
|
<p class="cardStats">
|
||||||
|
Adjust game size -- Width:
|
||||||
|
<input class="cardStats" id="snakeWidth" type="number" min="2" max="31" value="25">
|
||||||
|
Height:
|
||||||
|
<input class="cardStats" id="snakeHeight" type="number" min="2" max="24" value="15">
|
||||||
|
</p>
|
||||||
<p class="cardStats">Snake Head Location: <span id="snakeHead"></span></p>
|
<p class="cardStats">Snake Head Location: <span id="snakeHead"></span></p>
|
||||||
<p class="cardStats">Food Location: <span id="snakeFood"></span></p>
|
<p class="cardStats">Food Location: <span id="snakeFood"></span></p>
|
||||||
<a class="navItem" href="https://lab.trianta.dev/Trianta/trianta.dev/src/branch/main/src/snake.ts">View Code</a>
|
<a class="navItem" href="https://lab.trianta.dev/Trianta/trianta.dev/src/branch/main/src/snake.ts">View Code</a>
|
||||||
|
|||||||
+16
-1
@@ -169,6 +169,21 @@ class SnakeCore {
|
|||||||
document.getElementById("snakeHead").innerHTML = "x: " + this.body[this.body.length - 1].x + " y: " + this.body[this.body.length - 1].y;
|
document.getElementById("snakeHead").innerHTML = "x: " + this.body[this.body.length - 1].x + " y: " + this.body[this.body.length - 1].y;
|
||||||
document.getElementById("snakeFood").innerHTML = "x: " + this.food.x + " y: " + this.food.y ;
|
document.getElementById("snakeFood").innerHTML = "x: " + this.food.x + " y: " + this.food.y ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update width and height from page to match game
|
||||||
|
getPageNumbers() {
|
||||||
|
let specifiedWidth = parseInt((document.getElementById("snakeWidth") as HTMLInputElement).value);
|
||||||
|
let specifiedHeight = parseInt((document.getElementById("snakeHeight") as HTMLInputElement).value);
|
||||||
|
if (this.width == specifiedWidth && this.height == specifiedHeight)
|
||||||
|
return false;
|
||||||
|
this.width = specifiedWidth;
|
||||||
|
this.height = specifiedHeight;
|
||||||
|
while (this.height > this.board.length)
|
||||||
|
this.board.push(new Array(this.width));
|
||||||
|
this.canvas.setAttribute("width", String(specifiedWidth * this.grid));
|
||||||
|
this.canvas.setAttribute("height", String(specifiedHeight * this.grid));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Bot {
|
class Bot {
|
||||||
@@ -270,7 +285,7 @@ const g_snakebot: Bot = new Bot();
|
|||||||
// game loop
|
// game loop
|
||||||
function snakeloop() {
|
function snakeloop() {
|
||||||
// Reset of needed
|
// Reset of needed
|
||||||
if (g_snake.gameover)
|
if (g_snake.gameover || g_snake.getPageNumbers())
|
||||||
g_snake.reset();
|
g_snake.reset();
|
||||||
|
|
||||||
// Simulate movement of snake
|
// Simulate movement of snake
|
||||||
|
|||||||
Reference in New Issue
Block a user