Compare commits
16 Commits
v0.2.1
..
f1346a628c
| Author | SHA1 | Date | |
|---|---|---|---|
| f1346a628c | |||
| 343af77bd1 | |||
| 47fd5c7458 | |||
| a754319374 | |||
| 4aeed537d7 | |||
| f725b4e922 | |||
| 8252f38bb7 | |||
| e4d9afdd68 | |||
| 90c868d9e9 | |||
| 452c35c1b0 | |||
| 9dea6014fe | |||
| e37d737d3a | |||
| 65c7b930e3 | |||
| 082176d75e | |||
| 18673c95c4 | |||
| cb52bd1561 |
+4
-2
@@ -1,6 +1,6 @@
|
||||
FROM nginx:latest
|
||||
|
||||
RUN apt-get update && apt-get install -y nodejs npm
|
||||
RUN apt-get update && apt-get install -y nodejs npm netcat-openbsd
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -14,10 +14,12 @@ RUN npm run build
|
||||
|
||||
WORKDIR /usr/share/nginx/html
|
||||
COPY index.html .
|
||||
COPY default.css .
|
||||
|
||||
RUN mkdir -p /usr/share/nginx/html/public
|
||||
COPY src/*.css ./public
|
||||
|
||||
RUN cp /app/build/* ./public
|
||||
|
||||
HEALTHCHECK CMD nc -z 127.0.0.1 80
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
@@ -22,6 +22,7 @@ body {
|
||||
padding: 8px;
|
||||
line-height: 21px;
|
||||
display: inline-block;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#top {
|
||||
@@ -34,9 +35,19 @@ body {
|
||||
}
|
||||
|
||||
#main {
|
||||
margin: 0px 120px;
|
||||
display: flex;
|
||||
/*background: #1e2030;*/
|
||||
}
|
||||
|
||||
.canvas {
|
||||
width: 780px;
|
||||
height: 600px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.cardStats {
|
||||
font-size: 18px;
|
||||
}
|
||||
@@ -121,9 +132,7 @@ a.button {
|
||||
.card {
|
||||
background: #363a4f;
|
||||
text-align: center;
|
||||
border-radius: 6px;
|
||||
border-top-left-radius: 18px;
|
||||
border-top-right-radius: 18px;
|
||||
border-radius: 18px;
|
||||
animation: card 3s linear infinite;
|
||||
width: 800px;
|
||||
height: 800px;
|
||||
+21
-11
@@ -3,24 +3,26 @@
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Trianta</title>
|
||||
<link rel="stylesheet" href="public/home.css" />
|
||||
<link rel="stylesheet" href="default.css" />
|
||||
</head>
|
||||
<body>
|
||||
<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://lab.trianta.dev/Trianta">Projects</a>
|
||||
<p class="navItem" style="text-align: right; flex-grow: 1;">Trianta</p>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div class="card">
|
||||
<h2 class="cardTop">Pong</h2>
|
||||
<canvas width="750" height="585" id="pong"></canvas>
|
||||
<script src="public/pong.js"></script>
|
||||
<div id="gameover" hidden="true">
|
||||
<h1>Game Over</h1>
|
||||
</div>
|
||||
<div id="restart" hidden="true">
|
||||
<button class="button" type="button" onclick = "restartGame()">Restart Game</a>
|
||||
<div class="canvas">
|
||||
<canvas width="750" height="585" id="pong"></canvas>
|
||||
<script src="public/pong.js"></script>
|
||||
<div id="gameover" hidden="true">
|
||||
<h1>Game Over</h1>
|
||||
</div>
|
||||
<div id="restart" hidden="true">
|
||||
<button class="button" type="button" onclick = "restartGame()">Restart Game</a>
|
||||
</div>
|
||||
</div>
|
||||
<p class="cardStats">Left Paddle Height: <span id="leftPaddle"></span></p>
|
||||
<p class="cardStats">Right Paddle Height: <span id="rightPaddle"></span></p>
|
||||
@@ -28,8 +30,16 @@
|
||||
</div>
|
||||
<div class="card">
|
||||
<h2 class="cardTop">Snake</h2>
|
||||
<canvas width="625" height="375" id="snake"></canvas>
|
||||
<script src="public/snake.js"></script>
|
||||
<div class="canvas">
|
||||
<canvas width="625" height="375" id="snake"></canvas>
|
||||
<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">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>
|
||||
|
||||
Generated
+5
-5
@@ -1,21 +1,21 @@
|
||||
{
|
||||
"name": "trianta.dev",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "trianta.dev",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"typescript": "^5.5.4"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.5.4",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz",
|
||||
"integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==",
|
||||
"version": "5.6.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz",
|
||||
"integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==",
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "trianta.dev",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.2",
|
||||
"description": "My personal website",
|
||||
"main": "index.html",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
html, body {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
background: black;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.button {
|
||||
background: blue;
|
||||
color: white;
|
||||
padding: 15px 20px;
|
||||
font-size: 32px;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
text-transform: uppercase;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
+17
-11
@@ -60,11 +60,10 @@ class SnakeCore {
|
||||
foodAte: boolean;
|
||||
|
||||
constructor() {
|
||||
// TODO: Add CSS stuff for page
|
||||
this.canvas = document.getElementById('snake') as HTMLCanvasElement;
|
||||
this.context = this.canvas.getContext('2d') as CanvasRenderingContext2D;
|
||||
this.grid = 25; // size of grid squares
|
||||
this.timeout = 20; // speed in ms
|
||||
this.timeout = 32; // speed in ms
|
||||
this.width = 25;
|
||||
this.height = 15;
|
||||
this.board = [];
|
||||
@@ -170,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("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 {
|
||||
@@ -213,7 +227,6 @@ class Bot {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Fix trim function
|
||||
trim() {
|
||||
let reachedSnake = false;
|
||||
this.path.push(this.pathUntrimmed.pop() as Point); // Push food location
|
||||
@@ -240,13 +253,6 @@ class Bot {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
values:
|
||||
0 = left
|
||||
1 = up
|
||||
2 = right
|
||||
4 = down
|
||||
*/
|
||||
nextMove() {
|
||||
// Get new path to food
|
||||
if (this.path.length === 0)
|
||||
@@ -279,7 +285,7 @@ const g_snakebot: Bot = new Bot();
|
||||
// game loop
|
||||
function snakeloop() {
|
||||
// Reset of needed
|
||||
if (g_snake.gameover)
|
||||
if (g_snake.gameover || g_snake.getPageNumbers())
|
||||
g_snake.reset();
|
||||
|
||||
// Simulate movement of snake
|
||||
|
||||
Reference in New Issue
Block a user