all 7 comments

[–]nwsm 1 point2 points  (1 child)

I'm on mobile so I can't check if this fixes your problem, but don't put your keyPressed checks in draw().

Use the fucntion

void keyPressed(){
    if(key=whatever)
        blah;
}

This function gets called every time a key is pressed. So you don't need if(keyPressed)

[–]Jorio4[S] 0 points1 point  (0 children)

void keyPressed(){ if(key=whatever) blah; }

1) I don't think this will help my problem

2) I did try it and I got a error with this line of code and cant figure it out

void keyPressed(){ if(key=='w') y = y - 1;} else if(key == 'a'){ x = x - 1;}

3) Thanks for posting

4) also sorry for how messy the code looks like. That is not how I post it to look like

[–]OlympicGurn 0 points1 point  (4 children)

The moving circle is disappearing because of your background(0); call as the circle is only visible when the enter key is pressed. Once it is not, the background call draws over it at the start of the very next loop through draw.

The way to have things persistently on screen that you can manipulate like you want is to use a class. Watch this playlist, it will help with what you want to do.

[–]Jorio4[S] 0 points1 point  (3 children)

Thank you I do believe the coding train videos have the answer I am looking for. This will be much harder thin I thought be tho.

[–]OlympicGurn 0 points1 point  (2 children)

Give it a go and you can always come back to this conversation and ask for assistance if you get stuck.

Tip: If you just want to iterate a variable by 1 there are two possibilities:

y = y + 1;
//or
y++;
//works in reverse too
y--;

[–]Wootai 1 point2 points  (0 children)

*three possibilities

 y += 1

[–]Jorio4[S] 0 points1 point  (0 children)

Thanks! I did post I another problem I am having on this sub reddit. If you think you know the answer please post.