Ask coding questions

← Back to all posts
1
Help! What language will run this?

I tried JS, but what I made is only compatible with a canvas-oriented JS language. Here is the code:

textSize(30);
fill(0, 0, 0);
text("Tic-Tac-Toe", 125, 50);
//title

fill(0, 0, 0);
strokeWeight(5);
line(155, 80, 155, 300);
line(230, 80, 230, 300);
line(80, 155, 305, 155);
line(80, 230, 305, 230);
//tic-tac-toe table

var Winner = [
{winx: "The x's won!", winxx: 225, winxy: 350},
{wino:"The o's won!", winox: 75, winoy: 350}
];
var mouseX = 200;
var mouseY = 200;
var numberCommands = [mouseClicked, keyPressed];
draw = function() {
if(keyIsPressed && keyCode === LEFT){
playSound(getSound("rpg/hit-clop"));
noFill();
ellipse(mouseX, mouseY, 45, 45);
//o's
}
if(keyIsPressed && keyCode === RIGHT){
playSound(getSound("rpg/hit-clop"));
fill(255, 255, 255);
line(mouseX-15, mouseY-20, mouseX+15, mouseY+15);
line(mouseX+15, mouseY-20, mouseX-15, mouseY+15);
//x's
}
if(keyIsPressed && keyCode === ALT){
textSize(20);
text("Who Won? down=o and up=x", 65, 320);
}
if(keyIsPressed && keyCode === UP){
fill(0, 0, 0);
textSize(15);
text(Winner[0].winx, Winner[0].winxx, Winner[0].winxy);
}
if(keyIsPressed && keyCode === DOWN){
fill(0, 0, 0);
textSize(15);
text(Winner[1].wino, Winner[1].winox, Winner[1].winoy);
}
};

Answered by
Scoder12 (294)
[earned 5 cycles]
View Answer
Commentshotnewtop
3

This definitely looks like processing.js. Have you tried loading that and then this code in a web repl?]

I am a repl.it helper. If this is a good answer, please upvote.

1

@Scoder12 No I haven't. Actually, how do I do that?

2

@CPPStudent7308 Its easy. Just put this snippet in the <body>

<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.js"></script>

before the script you have above in a web repl.

1

this is 100% p5.js code but it is slightly odd p5 code since p5 has a setup function and a draw function and this has no setup function and the draw function is defined in a different way in your code

1

Where did you find the code?

1

@themaka I made it myself in Khan Academy as an assignment.

1

I don’t know for certain, but that looks like p5.js.