Why do my X/O's not show in my tictactoe game


hi, I was working on updating my code for my tictactoe, I’m only a beginner and thought this would be a good place to start, the game used to work, but when I added the minim library and set up a song to play in the background, all hell came loose. The version you have here is one where i disabled all elements of minim, whether it was enabled or disabled, it would still do 2 things, when I clicked, it would not produce X/O or print in the console and when it was enabled no song would play. The size of the canvas is the same as the XOB (XO board)

/*import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;

import ddf.minim.*;
Minim minim;
AudioPlayer player;*/

PImage X;
PImage O;
PImage XOB;

boolean Xb = true;
boolean Ob = false; 

void setup() { 
 X = loadImage("X.png");
 O = loadImage("O.png");
 XOB = loadImage("XOB.png");
/*   minim = new Minim(this);
 player = minim.loadFile("RetroVision.mp3", 1000);

void mousePressed() {
  if (Xb == true) {image(X,mouseX,mouseY,120,120); Xb = false; Ob = true; println("X");}
else if (Ob == true) {image(O,mouseX,mouseY,120,120); Ob = false; Xb = true; println("O");}

void keyPressed() {
if (key == 'r' || key == 'R') {background(255); image(XOB,0,0);}
/*else if (player.isPlaying() && key == 'p' || key == 'P') {player.pause(); };
if (key == 'o') {player.play();}*/

please dont go too hard on me if it is obvious as I am not experienced in processing


what happened with

void draw() {
  // ???

keyboard, mouse and minim need that i think.


nah i wasnt using void draw at all


If you want an interactive sketch – including keyboard / mouse events, audio events, etc – then you need draw() – even if it is empty. You can confirm @kll’s advice by testing:

Does nothing:

//void draw() {
void mouseMoved() {
  rect(mouseX, mouseY, 10, 10);

Does something:

void draw() {
void mouseMoved() {
  rect(mouseX, mouseY, 10, 10);

From the overview:

A program written as a list of statements (like the previous examples) is called a static sketch. In a static sketch, a series of functions are used to perform tasks or create a single image without any animation or interaction. Interactive programs are drawn as a series of frames, which you can create by adding functions titled setup() and draw() as shown in the code below. These are built-in functions that are called automatically. https://processing.org/tutorials/overview/


Thank you, as a beginner I was not aware of this


Glad it is helpful. Follow up in this thread if you have any more questions about your sketch in progress, and good luck!