15 Commits

Author SHA1 Message Date
Trianta
225e5e8422 pong: reset counter on idle and increase idle length 2024-12-30 17:15:41 -06:00
Trianta
3aaa6740f4 pong: let bot idle last longer 2024-12-30 17:14:00 -06:00
Trianta
51ec729979 pong: fix which bot should idle 2024-12-30 17:11:37 -06:00
Trianta
be4eb906c5 pong: make other bot idle when not busy 2024-12-30 17:10:46 -06:00
Trianta
16242e95ca pong: increase speed of game 2024-12-30 17:03:50 -06:00
Trianta
d1d9631ae8 pong: fix left paddle location 2024-12-30 17:03:22 -06:00
Trianta
e2f111dd36 pong: fix undefined function 2024-12-30 17:00:50 -06:00
Trianta
43f652f695 pong: there's no way this works 2024-12-30 16:54:01 -06:00
Trianta
347c419d59 pong: fix wack definition order 2024-12-30 16:43:27 -06:00
Trianta
efcc58d0cd Merge branch 'main' into pong 2024-12-30 16:30:53 -06:00
5edb887eec Merge pull request 'core: new split layout for page' (#12) from redesign into main
Reviewed-on: Trianta/trianta.dev#12
2024-12-30 00:03:44 -06:00
Trianta
dea09e2f50 core: match other pages to format 2024-12-29 22:23:00 -06:00
Trianta
785266d0e4 core: decrease trianta and move content text left 2024-12-29 22:18:56 -06:00
Trianta
4d01c794c0 core: make main area flex and add changes to contact 2024-12-29 22:09:20 -06:00
Trianta
262246e8f0 core: make nav bar actually a nav bar and side by side with content 2024-12-29 21:47:33 -06:00
7 changed files with 263 additions and 173 deletions
+31 -4
View File
@@ -6,6 +6,7 @@
body {
font-family: Arial, sans-serif;
font-weight: 800;
color: #06CDFF;
background: #03001C;
line-height: 1.5;
@@ -14,20 +15,46 @@ body {
}
.inside {
max-width: 80rem;
max-width: 60rem;
margin: 0 auto;
padding: 2rem 1.5rem;
}
#navigation {
nav {
padding: 1rem;
text-align: center;
width: 6rem;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
}
.gap {
width: 4rem;
}
.content {
width: 48rem;
text-align: left;
}
@media screen and (max-width: 600px) {
.column {
width: 100%;
}
.gap {
visibility: hidden;
}
}
.trianta {
font-size: 3.5rem !important;
color: #06CDFF !important;
border: none !important;
color: #06CDFF !important;
font-size: 2.5rem !important;
min-width: 12rem;
margin: -1rem;
}
+13 -7
View File
@@ -11,13 +11,19 @@
<a href="/" class="trianta">TRIANTA</a>
<p>Function over form by design</p>
</div>
<div id="navigation">
<a href="https://www.github.com/trimutex">GitHub</a>
<a href="https://lab.trianta.dev/Trianta">Projects</a>
<a href="/completed">Completed</a>
<a href="/current">Current</a>
<a href="/other">Other</a>
<a href="/contact">Contact</a>
<div style="display: flex;">
<nav class="column">
<ul>
<li><a href="https://www.github.com/trimutex">GitHub</a></li>
<li><a href="https://lab.trianta.dev/Trianta">Projects</a></li>
<li><a href="/completed">Completed</a></li>
<li><a href="/current">Current</a></li>
<li><a href="/other">Other</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
<div class="column gap"></div>
<div class="column content"></div>
</div>
</div>
</body>
+48 -41
View File
@@ -11,50 +11,57 @@
<a href="/" class="trianta">TRIANTA</a>
<p>Function over form by design</p>
</div>
<div id="navigation">
<a href="https://www.github.com/trimutex">GitHub</a>
<a href="https://lab.trianta.dev/Trianta">Projects</a>
<a href="/completed">Completed</a>
<a href="/current">Current</a>
<a href="/other">Other</a>
<a href="/contact">Contact</a>
</div>
<h2>Completed Projects</h2>
<div class="card reserve">
<div class="canvas">
<canvas width="750" height="585" id="pong"></canvas>
<script src="/public/pong.js"></script>
<div id="gameover" hidden="true">
<h3>Game Over</h3>
<div style="display: flex;">
<nav class="column">
<ul>
<li><a href="https://www.github.com/trimutex">GitHub</a></li>
<li><a href="https://lab.trianta.dev/Trianta">Projects</a></li>
<li><a href="/completed">Completed</a></li>
<li><a href="/current">Current</a></li>
<li><a href="/other">Other</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
<div class="column gap"></div>
<div class="column content">
<h2>Completed Projects</h2>
<div class="card reserve">
<div class="canvas">
<canvas width="750" height="585" id="pong"></canvas>
<script src="/public/pong.js"></script>
<div id="gameover" hidden="true">
<h3>Game Over</h3>
</div>
<div id="restart" hidden="true">
<button class="button" type="button" onclick = "restartGame()">Restart Game</a>
</div>
</div>
<div class="stats">
<p style="font-size: 22px;">Pong</p>
<p>Left Paddle Height: <span id="leftPaddle"></span></p>
<p>Right Paddle Height: <span id="rightPaddle"></span></p>
<a href="https://lab.trianta.dev/Trianta/trianta.dev/src/branch/main/src/pong.js">View Code</a>
</div>
</div>
<div id="restart" hidden="true">
<button class="button" type="button" onclick = "restartGame()">Restart Game</a>
<div class="card reserve">
<div class="canvas">
<canvas width="625" height="375" id="snake"></canvas>
<script src="/public/snake.js"></script>
</div>
<div class="stats">
<p style="font-size: 22px;">Snake</p>
<p>
Adjust game size -- Width:
<input id="snakeWidth" type="number" min="2" max="31" value="31">
Height:
<input id="snakeHeight" type="number" min="2" max="24" value="24">
</p>
<p>Snake Head Location: <span id="snakeHead"></span></p>
<p>Food Location: <span id="snakeFood"></span></p>
<a href="https://lab.trianta.dev/Trianta/trianta.dev/src/branch/main/src/snake.ts">View Code</a>
</div>
</div>
</div>
<div class="stats">
<p style="font-size: 22px;">Pong</p>
<p>Left Paddle Height: <span id="leftPaddle"></span></p>
<p>Right Paddle Height: <span id="rightPaddle"></span></p>
<a href="https://lab.trianta.dev/Trianta/trianta.dev/src/branch/main/src/pong.js">View Code</a>
</div>
</div>
<div class="card reserve">
<div class="canvas">
<canvas width="625" height="375" id="snake"></canvas>
<script src="/public/snake.js"></script>
</div>
<div class="stats">
<p style="font-size: 22px;">Snake</p>
<p>
Adjust game size -- Width:
<input id="snakeWidth" type="number" min="2" max="31" value="31">
Height:
<input id="snakeHeight" type="number" min="2" max="24" value="24">
</p>
<p>Snake Head Location: <span id="snakeHead"></span></p>
<p>Food Location: <span id="snakeFood"></span></p>
<a href="https://lab.trianta.dev/Trianta/trianta.dev/src/branch/main/src/snake.ts">View Code</a>
</div>
</div>
</div>
</body>
+17 -10
View File
@@ -11,17 +11,24 @@
<a href="/" class="trianta">TRIANTA</a>
<p>Function over form by design</p>
</div>
<div id="navigation">
<a href="https://www.github.com/trimutex">GitHub</a>
<a href="https://lab.trianta.dev/Trianta">Projects</a>
<a href="/completed">Completed</a>
<a href="/current">Current</a>
<a href="/other">Other</a>
<a href="/contact">Contact</a>
<div style="display: flex;">
<nav class="column">
<ul>
<li><a href="https://www.github.com/trimutex">GitHub</a></li>
<li><a href="https://lab.trianta.dev/Trianta">Projects</a></li>
<li><a href="/completed">Completed</a></li>
<li><a href="/current">Current</a></li>
<li><a href="/other">Other</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
<div class="column gap"></div>
<div class="column content">
<h2>Contact Methods</h2>
<p>E-mail: gregcraw2001@gmail.com</p>
<p>Discord: trianta</p>
</div>
</div>
<h2>Contact Methods</h2>
<p>E-mail: gregcraw2001@gmail.com</p>
<p>Discord: trianta</p>
</div>
</body>
</html>
+28 -21
View File
@@ -11,27 +11,34 @@
<a href="/" class="trianta">TRIANTA</a>
<p>Function over form by design</p>
</div>
<div id="navigation">
<a href="https://www.github.com/trimutex">GitHub</a>
<a href="https://lab.trianta.dev/Trianta">Projects</a>
<a href="/completed">Completed</a>
<a href="/current">Current</a>
<a href="/other">Other</a>
<a href="/contact">Contact</a>
</div>
<h2>Current Personal Projects</h2>
<div class="card">
<h3>Wrench</h3>
<p>Description: A simple application to handle all of your Linux configuration needs.</p>
<p>Language: C++26</p>
<p>Tools: CMake</p>
<p>Frameworks: Qt6</p>
<a href="https://github.com/Trimutex/wrench">View Repository</a>
</div>
<div class="card">
<h3>Synopsis</h3>
<p>Description: A markdown repository containing details and changes of servers I maintain.</p>
<a href="https://github.com/Trimutex/synopsis">View Repository</a>
<div style="display: flex;">
<nav class="column">
<ul>
<li><a href="https://www.github.com/trimutex">GitHub</a></li>
<li><a href="https://lab.trianta.dev/Trianta">Projects</a></li>
<li><a href="/completed">Completed</a></li>
<li><a href="/current">Current</a></li>
<li><a href="/other">Other</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
<div class="column gap"></div>
<div class="column content">
<h2>Current Personal Projects</h2>
<div class="card">
<h3>Wrench</h3>
<p>Description: A simple application to handle all of your Linux configuration needs.</p>
<p>Language: C++26</p>
<p>Tools: CMake</p>
<p>Frameworks: Qt6</p>
<a href="https://github.com/Trimutex/wrench">View Repository</a>
</div>
<div class="card">
<h3>Synopsis</h3>
<p>Description: A markdown repository containing details and changes of servers I maintain.</p>
<a href="https://github.com/Trimutex/synopsis">View Repository</a>
</div>
</div>
</div>
</div>
</body>
+58 -51
View File
@@ -11,57 +11,64 @@
<a href="/" class="trianta">TRIANTA</a>
<p>Function over form by design</p>
</div>
<div id="navigation">
<a href="https://www.github.com/trimutex">GitHub</a>
<a href="https://lab.trianta.dev/Trianta">Projects</a>
<a href="/completed">Completed</a>
<a href="/current">Current</a>
<a href="/other">Other</a>
<a href="/contact">Contact</a>
</div>
<h2>Other Projects</h2>
<div class="card">
<h3>Hyprland</h3>
<p>Description: An independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks. </p>
<a href="https://github.com/hyprwm/Hyprland">View Repository</a>
<p>Language: C++26</p>
<p>Tools: CMake</p>
<p>and various libraries.</p>
<p>Contributions (newest first)</p>
<a href="https://github.com/hyprwm/Hyprland/pull/8323">hyprwm/Hyprland#8323</a>
<a href="https://github.com/hyprwm/Hyprland/pull/8044">hyprwm/Hyprland#8044</a>
<a href="https://github.com/hyprwm/Hyprland/pull/7959">hyprwm/Hyprland#7959</a>
<br>
<a href="https://github.com/hyprwm/Hyprland/pull/7755">hyprwm/Hyprland#7755</a>
<a href="https://github.com/hyprwm/Hyprland/pull/7683">hyprwm/Hyprland#7683</a>
<a href="https://github.com/hyprwm/Hyprland/pull/7633">hyprwm/Hyprland#7633</a>
<br>
<a href="https://github.com/hyprwm/Hyprland/pull/7575">hyprwm/Hyprland#7575</a>
<a href="https://github.com/hyprwm/Hyprland/pull/7458">hyprwm/Hyprland#7458</a>
<a href="https://github.com/hyprwm/Hyprland/pull/6652">hyprwm/Hyprland#6652</a>
</div>
<div class="card">
<h3>Proxy</h3>
<p>Description: A program written in C++ to act as a proxy for another server.</p>
<a href="https://lab.trianta.dev/Trianta/proxy-network">View Repository</a>
<p>Language: C++11</p>
<p>Tools: CMake</p>
<p>Testing Frameworks: <a href="https://github.com/ThrowTheSwitch/Unity">Unity Test (ThrowTheSwitch)</a></p>
</div>
<div class="card">
<h3>Cloudcare</h3>
<p>Description: A sample repository that uses downloaded .bed files to train a model on DNA using PyTorch.</p>
<a href="https://github.com/Trimutex/cloudcare">View Repository</a>
<p>Languages: Python, Bash</p>
<p>Libraries: PyTorch</p>
<p>Tools: Conda</p>
</div>
<div class="card">
<h3>N-Queens</h3>
<p>Description: The N-Queens problem recreated in C++ which gets solved using a Genetic Algorithm.</p>
<a href="https://lab.trianta.dev/Trianta/n-queens">View Repository</a>
<p>Language: C++11</p>
<p>Tools: CMake</p>
<div style="display: flex;">
<nav class="column">
<ul>
<li><a href="https://www.github.com/trimutex">GitHub</a></li>
<li><a href="https://lab.trianta.dev/Trianta">Projects</a></li>
<li><a href="/completed">Completed</a></li>
<li><a href="/current">Current</a></li>
<li><a href="/other">Other</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
<div class="column gap"></div>
<div class="column content">
<h2>Other Projects</h2>
<div class="card">
<h3>Hyprland</h3>
<p>Description: An independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks. </p>
<a href="https://github.com/hyprwm/Hyprland">View Repository</a>
<p>Language: C++26</p>
<p>Tools: CMake</p>
<p>and various libraries.</p>
<p>Contributions (newest first)</p>
<a href="https://github.com/hyprwm/Hyprland/pull/8323">hyprwm/Hyprland#8323</a>
<a href="https://github.com/hyprwm/Hyprland/pull/8044">hyprwm/Hyprland#8044</a>
<a href="https://github.com/hyprwm/Hyprland/pull/7959">hyprwm/Hyprland#7959</a>
<br>
<a href="https://github.com/hyprwm/Hyprland/pull/7755">hyprwm/Hyprland#7755</a>
<a href="https://github.com/hyprwm/Hyprland/pull/7683">hyprwm/Hyprland#7683</a>
<a href="https://github.com/hyprwm/Hyprland/pull/7633">hyprwm/Hyprland#7633</a>
<br>
<a href="https://github.com/hyprwm/Hyprland/pull/7575">hyprwm/Hyprland#7575</a>
<a href="https://github.com/hyprwm/Hyprland/pull/7458">hyprwm/Hyprland#7458</a>
<a href="https://github.com/hyprwm/Hyprland/pull/6652">hyprwm/Hyprland#6652</a>
</div>
<div class="card">
<h3>Proxy</h3>
<p>Description: A program written in C++ to act as a proxy for another server.</p>
<a href="https://lab.trianta.dev/Trianta/proxy-network">View Repository</a>
<p>Language: C++11</p>
<p>Tools: CMake</p>
<p>Testing Frameworks: <a href="https://github.com/ThrowTheSwitch/Unity">Unity Test (ThrowTheSwitch)</a></p>
</div>
<div class="card">
<h3>Cloudcare</h3>
<p>Description: A sample repository that uses downloaded .bed files to train a model on DNA using PyTorch.</p>
<a href="https://github.com/Trimutex/cloudcare">View Repository</a>
<p>Languages: Python, Bash</p>
<p>Libraries: PyTorch</p>
<p>Tools: Conda</p>
</div>
<div class="card">
<h3>N-Queens</h3>
<p>Description: The N-Queens problem recreated in C++ which gets solved using a Genetic Algorithm.</p>
<a href="https://lab.trianta.dev/Trianta/n-queens">View Repository</a>
<p>Language: C++11</p>
<p>Tools: CMake</p>
</div>
</div>
</div>
</div>
</body>
+68 -39
View File
@@ -19,6 +19,25 @@ class Box {
}
}
class Ball {
geometry: Box;
speed: number;
dx: number;
dy: number;
resetting: boolean;
constructor(_geometry: Box) {
// start in the middle of the game
this.geometry = _geometry;
this.speed = 5;
// ball velocity (start going to the top-right corner)
this.dx = this.speed;
this.dy = -this.speed;
// keep track of when need to reset the ball position
this.resetting = false;
}
}
class Paddle {
geometry: Box;
speed: number;
@@ -26,6 +45,7 @@ class Paddle {
isLeft: boolean;
score: number;
dy: number;
idleCounter: number;
constructor(_geometry: Box, _isLeft: boolean) {
this.geometry = _geometry;
@@ -34,40 +54,12 @@ class Paddle {
this.isBot = true;
this.score = 0;
this.dy = 0;
this.idleCounter = 0;
}
scored() {
this.score++;
}
input() {
if (!this.isBot)
return;
let ballRegion = Math.floor(g_pong.ball.geometry.y / 15);
let paddleRegion = Math.floor(this.geometry.y / 15);
if (ballRegion < paddleRegion) this.dy = -this.speed;
if (ballRegion > paddleRegion) this.dy = this.speed;
if (ballRegion === paddleRegion) this.dy = 0;
}
}
class Ball {
geometry: Box;
speed: number;
dx: number;
dy: number;
resetting: boolean;
constructor() {
// start in the middle of the game
this.geometry = new Box(g_pong.width / 2, g_pong.height / 2, g_pong.grid, g_pong.grid);
this.speed = 5;
// ball velocity (start going to the top-right corner)
this.dx = this.speed;
this.dy = -this.speed;
// keep track of when need to reset the ball position
this.resetting = false;
}
}
class PongCore {
@@ -91,13 +83,13 @@ class PongCore {
this.grid = 15; // size of grid squares
this.paddleHeight = this.grid * 5;
this.paddleHeightMax = this.canvas.height - this.grid - this.paddleHeight;
this.timeout = 32; // speed in ms
this.timeout = 4; // speed in ms
this.width = this.canvas.width;
this.height = this.canvas.height;
this.gameover = false;
this.paddleSpeed = 6;
this.ball = new Ball();
this.left = new Paddle(new Box(this.width / 2, this.height / 2 - this.paddleHeight / 2, this.grid, this.paddleHeight), true);
this.ball = new Ball(new Box(this.width / 2, this.height / 2, this.grid, this.grid));
this.left = new Paddle(new Box(this.grid * 2, this.height / 2 - this.paddleHeight / 2, this.grid, this.paddleHeight), true);
this.right = new Paddle(new Box(this.width - this.grid * 3, this.height / 2 - this.paddleHeight / 2, this.grid, this.paddleHeight), false);
}
@@ -121,19 +113,24 @@ class PongCore {
// Game loop
loop() {
// Reset of needed
if (this.gameover)
this.reset();
if (g_pong.gameover)
g_pong.reset();
this.simulate();
g_pong.simulate();
this.draw();
this.updatePageText();
g_pong.draw();
g_pong.updatePageText();
}
// Simulate game logic
simulate() {
this.left.input();
this.right.input();
if (this.ball.dx < 0) {
this.botInput(this.left);
this.botIdle(this.right);
} else {
this.botInput(this.right);
this.botIdle(this.left);
}
// move paddles by their velocity
this.left.geometry.y += this.left.dy;
@@ -245,6 +242,38 @@ class PongCore {
document.getElementById("leftPaddle").innerHTML = this.left.geometry.y.toString();
document.getElementById("rightPaddle").innerHTML = this.right.geometry.y.toString();
}
// Function for bot to play as a paddle
botInput(player: Paddle) {
if (!player.isBot)
return;
let ballRegion = Math.floor(this.ball.geometry.y / 15);
let paddleRegion = Math.floor(player.geometry.y / 15);
if (ballRegion < paddleRegion) player.dy = -player.speed;
if (ballRegion > paddleRegion) player.dy = player.speed;
if (ballRegion === paddleRegion) player.dy = 0;
}
// Randomly move the bot paddle when ball not towards it
botIdle(player: Paddle) {
player.idleCounter++;
if (player.idleCounter < 20)
return;
else
player.idleCounter = 0;
let direction: number = Math.floor(Math.random() * 3);
switch (direction) {
case 0:
player.dy = 0;
break;
case 1:
player.dy = -player.speed;
break;
case 2:
player.dy = player.speed;
break;
}
}
}
// listen to keyboard events to move the paddles