Can't run code due to syntax errors

<
public class Person{
float x;
float y;
float xspeed;
float yspeed;

}
Person (float tempX, float tempY) {
x=tempX;
y=tempY;
xspeed = 4;
yspeed = 4;
}

void move() {
x = x+xspeed;
if (x>1000||x<0){
xspeed= -xspeed;
}
if (mousePressed){
y=y+yspeed;
if (y<0||y>1000){
yspeed = -yspeed;
}
}

}
void display(){
fill(100,50,300);
circle(x,y,50);
line(x, y+25, x, y+100);
line (x, y+100, x-20, y +120);
line (x, y+100, x+20, y+120);
line (x-40, y+50, x+40, y+50);
}
void settings (){
size(1000, 1000);
}
ArrayList people;
void setup(){
size(1000,1000)
people = new ArrayList();
people.add (new Person(500,400));
}
void draw(){
background (150,350,200);
for (int i = people.size()1; i >=0;i++){
Person person = people.get(i);
person.move();
person.display();
}
}
voice keyPressed(){
if (key==" "){
people.add(new Person(x,y,));
}
}

please help I have no idea what I’m doing I’m just trying to make a guy populate everytime you press the space bar. i was following the examples on the processing site but for some reason its not working please tell me why.

it also says im mixing active and static modes and i dont know what that means

at a glance your “Person” class constructor and methods are outside of its scope. to begin with you can change it to this and work from there.

class Person{
    float x;
    float y;
    float xspeed;
    float yspeed;

    Person (float tempX, float tempY) {
        x=tempX;
        y=tempY;
        xspeed = 4;
        yspeed = 4;
    }

    void move() {
        x = x+xspeed;
        if (x>1000||x<0){
            xspeed= -xspeed;
        }
        if (mousePressed){
            y=y+yspeed;
        }
        if (y<0||y>1000){
            yspeed = -yspeed;
        }
    }

    void display(){
        fill(100,50,300);
        circle(x,y,50);
        line(x, y+25, x, y+100);
        line (x, y+100, x-20, y +120);
        line (x, y+100, x+20, y+120);
        line (x-40, y+50, x+40, y+50);
    }
}

note: the move method of the person class will probably need work too.

the debugger should tell you everything you need to know just start at the beginning and work your way through. You have open/closing brace issues and one of your methods is defined with “voice” type which should be void.

Hello,

Please post formatted code as a courtesy to everyone:
https://discourse.processing.org/faq#format-your-code

A good place to start!

I will help you help yourself.

There are resources here:

Start with small working code and build on that.
Comment your code.
Save each working version with comments… you can add number to the saved versions.

Tutorial:

Example:

In the Processing IDE you should see the errors:

Move your mouse over the red underlined errors.

Look up the references.
The keywords (usually highlighted) such as key have references; a right mouse press over a keyword may also give you options to “Find in Reference”.
x and y are underlined… what error shows up?

There are other errors in your code.
You can work on them one at a time.

Since this is homework your growth and development as a programmer means an investment of work on your part.

Enjoy the growing pains… you come out stronger in the end!

I did manage to correct the code and get this out of it:

:)

2 Likes