I have slured my words several times today.
I don't know whether it is caused by my bad sleep schedule or another worse cause, but I am a bit freaked out. I think it happened once or twice yesterday.
"I am not asking for medical advice."
I don't know whether it is caused by my bad sleep schedule or another worse cause, but I am a bit freaked out. I think it happened once or twice yesterday.
"I am not asking for medical advice."
I made a DDA ray tester.
I can't make a replit because replit converted to AI-slopery.
<!DOCTYPE html>
<html>
<head>
<title>DDA RAYCAST</title>
<style>
* {
padding: 0px;
margin: 0px;
border-width: 0px;
}
canvas {
width: 100vw;
}
</style>
</head>
<body>
<canvas id="canvas" width="480" height="360"></canvas>
<script>
/* NOT WRITTEN BY AI, AND F*CK "VIBE CODING". */
/* Note: I knoe the period is supposed to go before the quotation mark, but who cares?*/
// INITALIZE VIEWPORT
canvas = document.getElementById("canvas");
ctx = canvas.getContext("2d");
let scale = 25;
// INITIALIZE RAY
let x = 0;
let y = 0;
let a = 0;
function gameloop() {
ctx.fillStyle = "white";
ctx.beginPath();
ctx.rect(0, 0, 480, 360);
ctx.fill();
ctx.fillStyle = "red";
for (i = 0; i < 48; i++) {
ctx.beginPath();
ctx.moveTo(scale * i, 0);
ctx.lineTo(scale * i, 360);
ctx.stroke()
}
for (i = 0; i < 36; i++) {
ctx.beginPath();
ctx.moveTo(0, scale * i);
ctx.lineTo(480, scale * i);
ctx.stroke()
}
if (a < 1.57) {
a += 0.001;
} else {
a = 0;
}
let px = x;
let py = y;
let dx = Math.cos(a);
let dy = Math.sin(a);
let slope = dy / dx;
let slopeR = dx / dy;
let horStepX = x;
let horStepY = y;
let vertStepX = x;
let vertStepY = y;
ctx.fillStyle = "green";
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(1000 * dx, 1000 * dy);
ctx.stroke();
ctx.fillStyle = "purple";
for (i = 0; i < 35; i++) {
if (Math.sqrt((horStepX + slopeR) ** 2 + (horStepY + 1) ** 2) < Math.sqrt((vertStepX + 1) ** 2 + (vertStepY + slope) ** 2)) {
horStepX += 1;
horStepY += slope;
px = horStepX;
py = horStepY;
} else {
vertStepX += slopeR;
vertStepY += 1;
px = vertStepX;
py = vertStepY;
}
ctx.fillStyle = "orange"
ctx.beginPath();
ctx.arc(px * scale, py * scale, 3, 0, 6.29);
ctx.fill();
}
requestAnimationFrame(gameloop);
}
requestAnimationFrame(gameloop);
</script>
</body>
</html>
I remember using it years ago, but now its just a knock-off chat GPT.
<!DOCTYPE html>
<html>
<head>
<title>DDA RAYCAST</title>
<style>
* {
padding: 0px;
margin: 0px;
border-width: 0px;
}
canvas {
width: 100vw;
}
</style>
</head>
<body>
<canvas id="canvas" width="480" height="360"></canvas>
<script>
/* NOT WRITTEN BY AI, AND F*CK "VIBE CODING". */
/* Note: I knoe the period is supposed to go before the quotation mark, but who cares?*/
// INITALIZE VIEWPORT
canvas = document.getElementById("canvas");
ctx = canvas.getContext("2d");
let scale = 25;
// DRAW GRID
ctx.fillStyle = "red";
for (i = 0; i < 48; i++) {
ctx.beginPath();
ctx.moveTo(scale * i, 0);
ctx.lineTo(scale * i, 360);
ctx.stroke()
}
for (i = 0; i < 36; i++) {
ctx.beginPath();
ctx.moveTo(0, scale * i);
ctx.lineTo(480, scale * i);
ctx.stroke()
}
ctx.fillStyle = "green";
// INITIALIZE RAY
let x = 0;
let y = 0;
let dx = Math.floor(Math.random() * 1000);
let dy = Math.floor(Math.random() * 1000);
// DRAW RAY FOR COMPARISON
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(1000 * dx, 1000 * dy);
ctx.stroke();
ctx.fillStyle = "purple";
let slope = dy / dx;
let slopeR = dx / dy;
let horStepX = x;
let horStepY = y;
let vertStepX = x;
let vertStepY = y;
for (i = 0; i < 35; i++) {
if (Math.sqrt((horStepX + slopeR) ** 2 + (horStepY + 1) ** 2) < Math.sqrt((vertStepX + 1) ** 2 + (vertStepY + slope) ** 2)) {
horStepX += 1;
horStepY += slope;
x = horStepX;
y = horStepY;
} else {
vertStepX += slopeR;
vertStepY += 1;
x = vertStepX;
y = vertStepY;
}
ctx.beginPath();
ctx.arc(x * scale, y * scale, 3, 0, 6.29);
ctx.fill();
}
</script>
</body>
</html>
/////////////////////
// Instruction Set //
/////////////////////
//
// LOGIC
// AND R1 R2 R3
// OR R1 R2 R3
// XOR R1 R2 R3
// NOT R1 R2 R3
// ----------------
// ARITHMETIC
// ADD R1 R2 R3
// SUB R1 R2 R3
// ----------------
// STORAGE
// MOV R1 R2
// LOAD R1 R2
// STOR R1 R2
// ----------------
// FLOW
// JUMP R1
// JEQU R1
// CALL R1
// RET
//
// ECHO R1
// QUIT
//
/////////////////////
// //
/////////////////////
/////////////////////
// Instruction Set //
/////////////////////
//
// LOGIC
// AND R1 R2 R3
// OR R1 R2 R3
// XOR R1 R2 R3
// NOT R1 R2 R3
// ----------------
// ARITHMETIC
// ADD R1 R2 R3
// SUB R1 R2 R3
// ----------------
// STORAGE
// MOV R1 R2
// LOAD R1 R2
// STOR R1 R2
// ----------------
// FLOW
// JUMP R1
// JEQU R1
// CALL R1
// RET
//
// ECHO R1
// QUIT
//
/////////////////////
// //
/////////////////////