Program which draws an `I` if no keys are pressed, and an `E`or an `F`if those keys are pressed

I’m trying to write a program which draws an I if no keys are pressed, and an Eor an Fif those keys
are pressed. Use straight lines to draw these letters. The window size is (120,120).

very good idea,
show us your code ( in </> formatter )
and detail description of problems or questions.

Do you want that somebody code it for you? Do you need help? Be more detailed as kll said

Yes I want that somebody code it

Ok, ‘challenge’ accepted, Java right?
(You know that theres text() and no need to draw with lines right?)

Yes java and yes I know there’s text and no need to draw with lines

int width = 120;
int height = 120;


void setup(){
size(120,120);
fill(0);
}

void draw(){
  background(255);
  if (keyPressed){
    if (key == 'E'){
      line(width/2 -20,20,width/2 - 20,height - 20);
      line(width/2 -20,20,width/2 + 20 , 20);
      line(width/2 -20,height/2,width/2 + 20 , height/2);
      line(width/2 -20,height/2 + 50,width/2 + 20 , height/2 + 50);
    }
    else if (key == 'F'){
      line(width/2 -20,20,width/2 - 20,height - 20);
      line(width/2 -20,20,width/2 + 20 , 20);
      line(width/2 -20,height/2,width/2 + 20 , height/2);
    }
  }
  else{
    line(width/2 - 20,20,width/2 + 20,20);
    line(width/2 ,20,width/2 ,height - 20);
    line(width/2 - 20,height - 20,width/2 + 20,height - 20);
  }
  
}

Remember to caps lock bc key is case sensitive

for the code, if no keys are pressed the program draws an I, but when I press E or F, it draws neither of those letters

use caps lock, i made it that if you press uppercase E and uppercase F, but you can add
if(key == ‘E’ || key == ‘e’){}, so it works for lowercase too

OK it’s working perfectly now.
Thank you very much for your help

1 Like