meowmeow | MeowMeow - A Toy File Encoder/Decoder
kandi X-RAY | meowmeow Summary
kandi X-RAY | meowmeow Summary
This project implements two commands in C, meow and unmeow, that will encode and decode a file in the MeowMeow encoding scheme. While not intended to be useful in and of itself, the program is an example of how to structure a small to medium sized C command-line program.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of meowmeow
meowmeow Key Features
meowmeow Examples and Code Snippets
Community Discussions
Trending Discussions on meowmeow
QUESTION
let playerX;
let playerY;
let playerSize = 15;
let playerSpeed = (playerSize / Math.pow(playerSize, 1.44)) * 10;
let Newcelltimer = 0;
let cell = []
let zoom = 1;
let n = 0;
let Xgrid = 600;
let Ygrid = 600;
let cpu = [];
let x = 0;
let y = 10;
let OffSetX = [];
let OffSetY = [];
let CPUteam = 2;
function setup() {
smooth();
frameRate(999)
createCanvas(600, 450);
playerX = 500;
playerY = 100;
}
function draw() {
let cellDist = [];
let cpuDist = [];
background(220);
push();
//Changes the FOV depending on your size
let Newzoom = 10 / playerSize
let newnewZoom = 1.3 * lerp(0.9, 10 / playerSize, 0.5)
Newzoom = lerp(zoom, Newzoom, 0.3)
translate(Xgrid / 2, Ygrid / 2 - 50);
scale(newnewZoom)
translate(-playerX, -playerY);
// Player's speed
playerSpeed = round((playerSize / Math.pow(playerSize, 1.44)) * 10000) / 1000
Newcelltimer++;
//Adds in new cells
if (Newcelltimer % 40 == 0) {
cell.push(ceil(random(0 - Xgrid, 2 * Xgrid)),
ceil(random(0 - Ygrid, 2 * Ygrid)))
}
//Adds in new AI's
if (Newcelltimer % 200 == 0) {
cpu.push(ceil(random(-Xgrid, 2 * Xgrid)), ceil(random(-Ygrid, 2 * Ygrid)), 20, CPUteam)
OffSetX.push(ceil(random(0, 1000000)))
OffSetY.push(ceil(random(1000000, 2000000)))
CPUteam++;
}
//Creates AI when you start playing
if (Newcelltimer == 1 || Newcelltimer == 2) {
cpu.push(ceil(random(-Xgrid, 2 * Xgrid)), ceil(random(-Ygrid, 2 * Ygrid)), 20, CPUteam)
OffSetX.push(ceil(random(0, 1000000)))
OffSetY.push(ceil(random(1000000, 2000000)))
cell.push(ceil(random(0 - Xgrid, 2 * Xgrid)),
ceil(random(0 - Ygrid, 2 * Ygrid)))
CPUteam++;
}
//Checks if cell is eaten
for (let i = 0; i < cell.length / 2; i++) {
let d = int(dist(cell[i * 2], cell[i * 2 + 1], playerX, playerY))
if (d <= playerSize / 2) {
playerSize += 5;
cell.splice(i * 2, 2)
celliseaten = true;
}
else{
fill(0,255,255,180);
circle(i*2,i*2+1,8);
}
}
//The cells disappear after a bit
if (Newcelltimer % 200 == 0) {
cell.splice(0, 2)
}
//Everything to do with the AI system
for (let j = 0; j < (cpu.length / 4); j++) {
let cpuDist = [];
let distance = int(dist(cpu[j * 4], cpu[j * 4 + 1], playerX, playerY)) //Distance between AI and player
if (distance <= playerSize / 2 && cpu[j * 4 + 2] < playerSize) {
playerSize += floor(cpu[j * 4 + 2]);
cpu.splice(j * 4, 4)
}
else if(distance<=cpu[j*4+2]/2&&cpu[j*4+2] cpu[j * 4 + 2]) ? cpu[m * 4 + 2] : cpu[j * 4 + 2];
if (higher > distant) {
if (cpu[m * 4 + 2] > cpu[j * 4 + 2]) {
cpu[m * 4 + 2] += cpu[j * 4 + 2]
cpu.splice(j * 4, 4)
} else {
cpu[j * 4 + 2] += cpu[m * 4 + 2]
cpu.splice(m * 4, 4)
} //Else
} //If
//If AI didn't eat another AI, return the distance
else {
cpuDist.push(distant);
} //Else
} //If
} //If
} //For
let ClosestCpu = min(cpuDist);
let ClosestCpupos;
//Index value of the closest cpu (NOT WORKINGS)
for (var q = 0; q < cpu.length / 4; q++) {
if (ClosestCpu == int(dist(cpu[q * 4], cpu[q * 4 + 1], cpu[j * 4], cpu[j * 4 + 1]))) {
ClosestCpupos = q;
break;
}
}
//Checks if AI ate cell
for (let n = 0; n < cell.length / 2; n++) {
let dis = int(dist(cell[n * 2], cell[n * 2 + 1], cpu[j * 4], cpu[j * 4 + 1]))
if (dis <= cpu[j * 4 + 2] / 2) {
cpu[j * 4 + 2] += 5;
cell.splice(n * 2, 2)
} else {
//If it didn't eat the cell, does the same idea with the AI from before
cellDist.push(dis)
}
}
let ClosestCell = min(cellDist);
let ClosestCellpos;
for (let r = 0; r < cell.length / 2; r++) {
if (ClosestCell == int(dist(cell[r * 2], cell[r * 2 + 1], cpu[j * 4], cpu[j * 4 + 1]))) {
ClosestCellpos = r;
break;
}
}
//AI sppeed
let amp = round((cpu[j * 4 + 2] / Math.pow(cpu[j * 4 + 2], 1.44)) * 70000) / 7000;
if (dist(playerX, playerY, cpu[j * 4], cpu[j * 4 + 1]) < 150 && playerSize > cpu[j * 4 + 2]) {
let distXpos = cpu[j * 4]-playerX;
let distYpos = cpu[j * 4 + 1]-playerY;
let higherVal = (abs(distXpos) > abs(distYpos)) ? distXpos : distYpos;
let MultVal = 150/abs(higherVal);
distXpos*=MultVal;
distYpos*=MultVal;
distXpos = map(distXpos, -150, 150, -1, 1);
distYpos = map(distYpos, -150, 150, -1, 1);
cpu[j * 4] += distXpos * amp;
cpu[j * 4 + 1] += distYpos * amp;
} else if (dist(playerX, playerY, cpu[j * 4], cpu[j * 4 + 1]) < 150 && playerSize < cpu[j * 4 + 2]) {
let distXpos = cpu[j * 4]-playerX;
let distYpos = cpu[j * 4 + 1]-playerY;
let higherVal = (abs(distXpos) > abs(distYpos)) ? distXpos : distYpos;
let MultVal = 150/abs(higherVal);
distXpos*=MultVal;
distYpos*=MultVal;
distXpos = map(distXpos, -150, 150, -1, 1);
distYpos = map(distYpos, -150, 150, -1, 1);
cpu[j * 4] -= distXpos * amp;
cpu[j * 4 + 1] -= distYpos * amp;
}
else if (dist(cpu[ClosestCpupos * 4], cpu[ClosestCpupos * 4 + 1], cpu[j * 4], cpu[j * 4 + 1]) < 150 && cpu[j * 4 + 2] > cpu[ClosestCpupos * 4 + 2]) {
let distXpos = cpu[ClosestCpupos * 4] - cpu[j * 4];
let distYpos = cpu[ClosestCpupos * 4 + 1] - cpu[j * 4 + 1];
let higherVal = (abs(distXpos) > abs(distYpos)) ? distXpos : distYpos;
let MultVal = 150/abs(higherVal);
distXpos*=MultVal;
distYpos*=MultVal;
distXpos = map(distXpos, -150, 150, -1, 1);
distYpos = map(distYpos, -150, 150, -1, 1);
cpu[j * 4] += distXpos * amp;
cpu[j * 4 + 1] += distYpos * amp;
} else if (dist(cpu[ClosestCpupos * 4], cpu[ClosestCpupos * 4 + 1], cpu[j * 4], cpu[j * 4 + 1]) < 150 && cpu[j * 4 + 2] > cpu[ClosestCpupos * 4 + 2]) {
let distXpos = cpu[ClosestCpupos * 4] - cpu[j * 4];
let distYpos = cpu[ClosestCpupos * 4 + 1] - cpu[j * 4 + 1];
let higherVal = (abs(distXpos) > abs(distYpos)) ? distXpos : distYpos;
let MultVal = 150/abs(higherVal);
distXpos*=MultVal;
distYpos*=MultVal;
distXpos = map(distXpos, -150, 150, -1, 1);
distYpos = map(distYpos, -150, 150, -1, 1);
cpu[j * 4] -= distXpos * amp;
cpu[j * 4 + 1] -= distYpos * amp;
} else if (dist(cell[ClosestCellpos * 2], cell[ClosestCellpos * 2 + 1], cpu[j * 4], cpu[j * 4 + 1]) < 150) {
let distXpos = cell[ClosestCellpos * 2] - cpu[j * 4];
let distYpos = cell[ClosestCellpos * 2 + 1] - cpu[j * 4 + 1];
let higherVal = (abs(distXpos) > abs(distYpos)) ? distXpos : distYpos;
let MultVal = 150/abs(higherVal);
distXpos*=MultVal;
distYpos*=MultVal;
distXpos = map(distXpos, -150, 150, -1, 1);
distYpos = map(distYpos, -150, 150, -1, 1);
cpu[j * 4] += distXpos * amp;
cpu[j * 4 + 1] += distYpos * amp;
} else {
x += 0.003;
y += 0.003;
let offsetX = map(noise(x + OffSetX[j]), 0, 1, -1, 1) * amp;
let offsetY = map(noise(y + OffSetY[j]), 0, 1, -1, 1) * amp;
cpu[j * 4] += offsetX;
cpu[j * 4 + 1] += offsetY;
}
if (cpu[j * 4 + 3] % 2 == 0) {
fill(0, 0, 255)
circle(cpu[j * 4], cpu[j * 4 + 1], cpu[j * 4 + 2]);
} else {
fill(255, 0, 0)
circle(cpu[j * 4], cpu[j * 4 + 1], cpu[j * 4 + 2])
} // Else
} //Cpu for
//Draws player
fill(255, 255, 0)
circle(playerX, playerY, playerSize)
pop();
}
...ANSWER
Answered 2021-May-12 at 19:02This is happening because the AI moves more quickly and more efficiently than the player. Suppose the CPU moves 3 pixels per frame and the player moves 1. Now consider the following:
- The CPU is 149 pixels away from the player, so it moves 3 pixels away from the player and the player moves 1 pixel toward the CPU
- Next frame: CPU is 151 pixels away, so it reverts to its normal behavior.
- Next frame: the player has moved closer, so it reverts to being chased.
- repeat
This alternating between states is what causes the vibration you see. How do you solve this? One solution is to give each CPU a boolean value for being chased. You can set this to true when the CPU comes within 150 of the player, and then set it back to false when it gets to be 200 away. That way, it won't oscillate because it needs to move 50 pixels in order to change behavior. In order to do this, you need to change all of the instances of j * 4
to j * 5
and give cpu[j * 5 + 4]
an initial boolean value. Here's my solution for testing:
QUESTION
var playerX;
var playerY;
var playerSize = 15;
var playerSpeed = (playerSize / Math.pow(playerSize, 1.44)) * 10;
var Newcelltimer = 0;
var cell = []
var cellEaten = 0;
var celliseaten = false;
var eaten = false;
var zoom = 1;
var n = 0;
var Xgrid = 600;
var Ygrid = 600;
var cpu = [];
var x = 0;
var y = 10;
var z = 100;
var OffSetX = [];
var OffSetY = [];
var lost = false;
var CPUteam = 2;
function setup() {
smooth();
frameRate(999)
createCanvas(600, 450);
playerX = 500;
playerY = 100;
}
function draw() {
var TotalBlue = 0;
var TotalRed = 0;
var Total = 0;
var cellDist = [];
if (lost) {
noLoop()
fill(255)
textSize(40)
background(0)
text("You lost", width / 2.5, height / 2)
textSize(20)
text("Final Board: ", 350, 60)
} else {
background(220);
push();
var Newzoom = 10 / playerSize
let newnewZoom = 1.3 * lerp(0.9, 10 / playerSize, 0.5)
Newzoom = lerp(zoom, Newzoom, 0.3)
translate(Xgrid / 2, Ygrid / 2 - 50);
scale(newnewZoom)
translate(-playerX, -playerY);
playerSpeed = round((playerSize / Math.pow(playerSize, 1.44)) * 10000) / 1000
Newcelltimer++;
if (Newcelltimer % 40 == 0) {
cell.push(ceil(random(0 - Xgrid, 2 * Xgrid)),
ceil(random(0 - Ygrid, 2 * Ygrid)))
}
if (Newcelltimer % 200 == 0) {
cpu.push(ceil(random(-Xgrid, 2 * Xgrid)), ceil(random(-Ygrid, 2 * Ygrid)), 20, CPUteam)
OffSetX.push(ceil(random(0, 1000000)))
OffSetY.push(ceil(random(1000000, 2000000)))
CPUteam++;
}
if (Newcelltimer == 1 || Newcelltimer == 2) {
cpu.push(ceil(random(-Xgrid, 2 * Xgrid)), ceil(random(-Ygrid, 2 * Ygrid)), 20, CPUteam)
OffSetX.push(ceil(random(0, 1000000)))
OffSetY.push(ceil(random(1000000, 2000000)))
CPUteam++;
}
//Checks if player Ate cell
for (var i = 0; i < cell.length / 2; i++) {
let d = int(dist(cell[i * 2], cell[i * 2 + 1], playerX, playerY))
if (d <= playerSize / 2) {
playerSize += 5;
cell.splice(i * 2, 2)
celliseaten = true;
}
}
if (keyIsDown(UP_ARROW) && playerY > 0 - Ygrid) {
playerY -= playerSpeed;
}
if (keyIsDown(RIGHT_ARROW) && playerX < 2 * Xgrid) {
playerX += playerSpeed;
}
if (keyIsDown(DOWN_ARROW) && playerY < 2 * Ygrid) {
playerY += playerSpeed;
}
if (keyIsDown(LEFT_ARROW) && playerX > 0 - Xgrid) {
playerX -= playerSpeed;
}
if (Newcelltimer % 200 == 0) {
cell.splice(0, 2)
}
for (var j = 0; j < (cpu.length / 4); j++) {
var cpuDist = [];
//Checks if AI ate cell
for (var n = 0; n < cell.length / 2; n++) {
let dis = int(dist(cell[n * 2], cell[n * 2 + 1], cpu[j * 4], cpu[j * 4 + 1]))
if (dis <= cpu[j * 4 + 2] / 2) {
cpu[j * 4 + 2] += 5;
cell.splice(n * 2, 2)
} else {
cellDist.push(dis)
}
}
var ClosestCell = min(cellDist);
var ClosestCellpos;
for (var r = 0; r < cell.length / 2; r++) {
if (ClosestCell == dist(cpu[j * 4], cpu[j * 4 + 1], cell[r * 2], cell[r * 2 + 1])) {
ClosestCellpos = r;
break;
}
}
let amp = round((cpu[j * 4 + 2] / Math.pow(cpu[j * 4 + 2], 1.44)) * 10000) / 1000;
if (r < 100 && dist(playerX, playerY, cpu[j * 4], cpu[j * 4 + 1]) > 100 || cpu[j * 4 + 2] > playerSize) {
var disXpos = cell[r * 2] - cpu[j * 4];
var disYpos = cell[r * 2 + 1] - cpu[j * 4 + 1];
disXpos = map(disXpos, -100, 100, -1, 1);
disYpos = map(disYpos, -100, 100, -1, 1);
cpu[j * 4] += disXpos * amp;
cpu[j * 4 + 1] += disYpos * amp;
} else {
x += 0.003;
y += 0.003;
let offsetX = map(noise(x + OffSetX[j]), 0, 1, -1, 1) * amp;
let offsetY = map(noise(y + OffSetY[j]), 0, 1, -1, 1) * amp;
cpu[j * 4] += offsetX;
cpu[j * 4 + 1] += offsetY;
}
//Draws the AI's
if (cpu[j * 4 + 3] % 2 == 0) {
fill(0, 0, 255)
circle(cpu[j * 4], cpu[j * 4 + 1], cpu[j * 4 + 2]);
} else {
fill(255, 0, 0)
circle(cpu[j * 4], cpu[j * 4 + 1], cpu[j * 4 + 2])
}
//Checks if player ate AI or vice versa
let distance = int(dist(cpu[j * 4], cpu[j * 4 + 1], playerX, playerY))
if (distance <= playerSize / 2 && cpu[j * 4 + 2] < playerSize) {
playerSize += floor(cpu[j * 4 + 2]);
cpu.splice(j * 4, 4)
}
if (distance <= cpu[j * 4 + 2] && cpu[j * 4 + 2] > playerSize) {
lost = true;
}
//Checks if one AI eats another
for (var m = 0; m < cpu.length / 4; m++) {
if (m != j) {
if (cpu[j * 4 + 3] % 2 != cpu[m * 4 + 3] % 2) {
distant = dist(cpu[m * 4], cpu[m * 4 + 1], cpu[j * 4], cpu[j * 4 + 1])
let higher = (cpu[m * 4 + 2] > cpu[j * 4 + 2]) ? cpu[m * 4 + 2] : cpu[j * 4 + 2]
if (higher > distant) {
if (cpu[m * 4 + 2] > cpu[j * 4 + 2]) {
cpu[m * 4 + 2] += cpu[j * 4 + 2]
cpu.splice(j * 4, 4)
} else {
cpu[j * 4 + 2] += cpu[m * 4 + 2]
cpu.splice(m * 4, 4)
} //Else
} // If
} //If
} //If
} //If
} //Nested For
} // For
//Draws all the "cells"
for (var k = 0; k < cell.length / 2; k++) {
fill(0, 255, 255, 100)
circle(cell[k * 2], cell[k * 2 + 1], 7)
}
//Nothing important, drawing the smiley face character
fill(255, 255, 0)
circle(playerX, playerY, playerSize)
fill(0)
ellipse(playerX - playerSize / 5, playerY - playerSize / 10, playerSize / 5, playerSize / 3)
ellipse(playerX + playerSize / 5, playerY - playerSize / 10, playerSize / 5, playerSize / 3)
arc(playerX, playerY + playerSize / 5, playerSize / 2, playerSize / 5, 0, 3.2, PIE)
fill(255, 255, 0)
noStroke()
arc(playerX, (playerY + playerSize / 5) - 1, playerSize / 2, playerSize / 5, 0, 3.2, PIE)
stroke(0)
//Limits the max player size
if (playerSize >= 3 * Xgrid | playerSize >= 3 * Ygrid) {
if (Xgrid > Ygrid) {
playerSize = 3 * Ygrid;
} else {
playerSize = 3 * Xgrid;
}
}
}
VS
var playerX;
var playerY;
var playerSize = 15;
var playerSpeed = (playerSize / Math.pow(playerSize, 1.44)) * 10;
var Newcelltimer = 0;
var cell = []
var cellEaten = 0;
var celliseaten = false;
var eaten = false;
var zoom = 1;
var n = 0;
var Xgrid = 600;
var Ygrid = 600;
var cpu = [];
var x = 0;
var y = 10;
var z = 100;
var OffSetX = [];
var OffSetY = [];
var lost = false;
var CPUteam = 2;
function setup() {
smooth();
frameRate(999)
createCanvas(600, 450);
playerX = 500;
playerY = 100;
}
function draw() {
var TotalBlue = 0;
var TotalRed = 0;
var Total = 0;
var cellDist = [];
if (lost) {
noLoop()
fill(255)
textSize(40)
background(0)
text("You lost", width / 2.5, height / 2)
textSize(20)
text("Final Board: ", 350, 60)
} else {
background(220);
push();
var Newzoom = 10 / playerSize
let newnewZoom = 1.3 * lerp(0.9, 10 / playerSize, 0.5)
Newzoom = lerp(zoom, Newzoom, 0.3)
translate(Xgrid / 2, Ygrid / 2 - 50);
scale(newnewZoom)
translate(-playerX, -playerY);
playerSpeed = round((playerSize / Math.pow(playerSize, 1.44)) * 10000) / 1000
Newcelltimer++;
if (Newcelltimer % 40 == 0) {
cell.push(ceil(random(0 - Xgrid, 2 * Xgrid)),
ceil(random(0 - Ygrid, 2 * Ygrid)))
}
if (Newcelltimer % 200 == 0) {
cpu.push(ceil(random(-Xgrid, 2 * Xgrid)), ceil(random(-Ygrid, 2 * Ygrid)), 20, CPUteam)
OffSetX.push(ceil(random(0, 1000000)))
OffSetY.push(ceil(random(1000000, 2000000)))
CPUteam++;
}
if (Newcelltimer == 1 || Newcelltimer == 2) {
cpu.push(ceil(random(-Xgrid, 2 * Xgrid)), ceil(random(-Ygrid, 2 * Ygrid)), 20, CPUteam)
OffSetX.push(ceil(random(0, 1000000)))
OffSetY.push(ceil(random(1000000, 2000000)))
CPUteam++;
}
//Checks if player Ate cell
for (var i = 0; i < cell.length / 2; i++) {
let d = int(dist(cell[i * 2], cell[i * 2 + 1], playerX, playerY))
if (d <= playerSize / 2) {
playerSize += 5;
cell.splice(i * 2, 2)
celliseaten = true;
}
}
if (keyIsDown(UP_ARROW) && playerY > 0 - Ygrid) {
playerY -= playerSpeed;
}
if (keyIsDown(RIGHT_ARROW) && playerX < 2 * Xgrid) {
playerX += playerSpeed;
}
if (keyIsDown(DOWN_ARROW) && playerY < 2 * Ygrid) {
playerY += playerSpeed;
}
if (keyIsDown(LEFT_ARROW) && playerX > 0 - Xgrid) {
playerX -= playerSpeed;
}
if (Newcelltimer % 200 == 0) {
cell.splice(0, 2)
}
for (var j = 0; j < (cpu.length / 4); j++) {
var cpuDist = [];
//Checks if AI ate cell
for (var n = 0; n < cell.length / 2; n++) {
let dis = int(dist(cell[n * 2], cell[n * 2 + 1], cpu[j * 4], cpu[j * 4 + 1]))
if (dis <= cpu[j * 4 + 2] / 2) {
cpu[j * 4 + 2] += 5;
cell.splice(n * 2, 2)
}
}
let amp = round((cpu[j * 4 + 2] / Math.pow(cpu[j * 4 + 2], 1.44)) * 10000) / 1000;
x += 0.003;
y += 0.003;
let offsetX = map(noise(x + OffSetX[j]), 0, 1, -1, 1) * amp;
let offsetY = map(noise(y + OffSetY[j]), 0, 1, -1, 1) * amp;
cpu[j * 4] += offsetX;
cpu[j * 4 + 1] += offsetY;
//Draws the AI's
if (cpu[j * 4 + 3] % 2 == 0) {
fill(0, 0, 255)
circle(cpu[j * 4], cpu[j * 4 + 1], cpu[j * 4 + 2]);
} else {
fill(255, 0, 0)
circle(cpu[j * 4], cpu[j * 4 + 1], cpu[j * 4 + 2])
}
//Checks if player ate AI or vice versa
let distance = int(dist(cpu[j * 4], cpu[j * 4 + 1], playerX, playerY))
if (distance <= playerSize / 2 && cpu[j * 4 + 2] < playerSize) {
playerSize += floor(cpu[j * 4 + 2]);
cpu.splice(j * 4, 4)
}
if (distance <= cpu[j * 4 + 2] && cpu[j * 4 + 2] > playerSize) {
lost = true;
}
//Checks if one AI eats another
for (var m = 0; m < cpu.length / 4; m++) {
if (m != j) {
if (cpu[j * 4 + 3] % 2 != cpu[m * 4 + 3] % 2) {
distant = dist(cpu[m * 4], cpu[m * 4 + 1], cpu[j * 4], cpu[j * 4 + 1])
let higher = (cpu[m * 4 + 2] > cpu[j * 4 + 2]) ? cpu[m * 4 + 2] : cpu[j * 4 + 2]
if (higher > distant) {
if (cpu[m * 4 + 2] > cpu[j * 4 + 2]) {
cpu[m * 4 + 2] += cpu[j * 4 + 2]
cpu.splice(j * 4, 4)
} else {
cpu[j * 4 + 2] += cpu[m * 4 + 2]
cpu.splice(m * 4, 4)
} //Else
} // If
} //If
} //If
} //If
} //Nested For
} // For
//Draws all the "cells"
for (var k = 0; k < cell.length / 2; k++) {
fill(0, 255, 255, 100)
circle(cell[k * 2], cell[k * 2 + 1], 7)
}
//Nothing important, drawing the smiley face character
fill(255, 255, 0)
circle(playerX, playerY, playerSize)
fill(0)
ellipse(playerX - playerSize / 5, playerY - playerSize / 10, playerSize / 5, playerSize / 3)
ellipse(playerX + playerSize / 5, playerY - playerSize / 10, playerSize / 5, playerSize / 3)
arc(playerX, playerY + playerSize / 5, playerSize / 2, playerSize / 5, 0, 3.2, PIE)
fill(255, 255, 0)
noStroke()
arc(playerX, (playerY + playerSize / 5) - 1, playerSize / 2, playerSize / 5, 0, 3.2, PIE)
stroke(0)
//Limits the max player size
if (playerSize >= 3 * Xgrid | playerSize >= 3 * Ygrid) {
if (Xgrid > Ygrid) {
playerSize = 3 * Ygrid;
} else {
playerSize = 3 * Xgrid;
}
}
}
...ANSWER
Answered 2021-May-04 at 01:49The reason the player instantly loses is because the code that the code that checks AI "cpu" distance to player doesn't work correctly.
QUESTION
https://editor.p5js.org/Meowmeow/sketches/b4AhGA4xH
This is created using a web editor for p5.js. Whenever you make something with j, it has an error message unless you do Cell =>. If you do it with i, there's no error message. The variables i,j are changed in the same places, unless I did something by accident. If I did please point it out, otherways can someone tell me why this happens?
...ANSWER
Answered 2021-Mar-01 at 19:52The issue is related to generation of the maze. Some cells are twice and some cells are missing in the check
array. You must add the next
cell to the array instead of the current
cell. The current cell contains the previous position in the maze:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install meowmeow
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page