core: add Snake using Typescript #7

Merged
Trianta merged 35 commits from snake into main 2024-11-09 01:26:09 -06:00
Showing only changes of commit 33d5c491c2 - Show all commits

View File

@ -81,7 +81,7 @@ class SnakeCore {
} }
reset() { reset() {
console.log("[LOG] Reset was triggered"); console.debug("[TRACE] Reset was triggered");
this.gameover = false; this.gameover = false;
this.foodAte = true; this.foodAte = true;
for (let i = 0; i < this.height; i++) { for (let i = 0; i < this.height; i++) {
@ -105,6 +105,7 @@ class SnakeCore {
foodRegen() { foodRegen() {
if (!this.foodAte) if (!this.foodAte)
return; return;
console.debug("[TRACE] Food reset was triggered");
this.foodAte = false; this.foodAte = false;
while (true) { while (true) {
let tmp = new Point(Math.floor(Math.random() * this.width), Math.floor(Math.random() * this.height)); let tmp = new Point(Math.floor(Math.random() * this.width), Math.floor(Math.random() * this.height));