That is because you have commented this:
//Campus = loadImage("Egbertbackground.jpg");
Try this example and tell me what you are seeing:
Arduino Code < Click to open!
void setup()
{
Serial.begin(9600);
delay(500);
}
int c;
void loop()
{
float angle = c*TWO_PI/360;
int x = int(200*cos(angle));
int y = int(200*sin(angle));
Serial.print(x);
Serial.print(',');
Serial.print(y);
Serial.print(',');
Serial.println(c);
delay(10); // delay in between reads for stability
c++;
if(c>359) c = 0;
}
Processing Code < Click to open!
/*
DATE: 23_10_2022
CREATIVE CHALLENGE 2: EGBERT THE FISH GAME_version_3
AUTHOR: TAISSIA VISSER
REFERENCES:
https://www.youtube.com/watch?v=jUmjbFsA2zw&ab_channel=Crazy-Logic
*/
// Modified by glv for testing. 2022/10/24
// Importing the serial library.
import processing.serial.*;
// Declare serial communication port
Serial myPort;
//String inString;
String[] data = {"0", "0", "0"}; // Array of data received from the serial port
void setup()
{
size (400, 400);
String myPortName = Serial.list()[5];
myPort = new Serial(this, myPortName, 9600);
myPort.bufferUntil('\n');
//PrintArray(Serial.list());
}
void draw() {
//background(Campus);
background(0);
int xPos = int(data[0])/2;
int yPos = int(data[1])/2;
int Pressed = int(data[2]);
//image(Egbert, xPos, yPos);
circle(xPos+200, yPos+200, 30);
}
// will get called every time data comes in
// storing the data string here
void serialEvent(Serial myPort) {
String inString = myPort.readStringUntil('\n');
if (inString != null)
{
// removing the whitespace
inString = trim(inString);
// Splitting the string at the commas and
// seperating the variables out into an array
data = split(inString, ",");
}
}
I initialized data to avoid the null until you received data:
String[] data = {"0", "0", "0"};
Focus on receiving data for now and refine and add to the code later.
I am just helping you along…
What operating system and which version of Processing?
Related:
https://discourse.processing.org/t/text-indicator-not-in-the-right-place/32073/3
The Processing Preferences has something related HiDPI to scaling:
I am using W10 and Processing 4.01.
:)