add
December 3, 2022, 7:57pm
1
int h,m;
void setup(){
size (800,600);
frameRate(10);
}
void draw (){
// if (framec==0){
background (180);
stroke (0);
fill(255);
rect (0,500,width,height);//chenar jos
h=nf(hits);
m=nf(misses);
fill(0);
h="HITS:"+h+"/MISSES:"+m;
textAlign(CENTER); textSize(50);
text (h,width/2,570);
float x=20+random (width-20);
float y=20+random (height-120);
fill (random(255),random(255),random(255),50);
noStroke(); /*int c1=int(random(255)); int c2=int(random (255)); int c3= int (random (255));*/// fill(c1,c2,c3); noStroke();
ellipse (x,y,40,40);
q=char( int (97+random(26)));
textSize(40);
textAlign(CENTER); fill(0);
text (q,x,y+10);
}
else d= key;
if (fc==fl)
if (d==q) hits++; else misses++;
fc++;
if(fc>fl) fc=0
}
void keyPressed()
{
d=key; fc=fl;
}
if(misses>3)
{
fill(255,0,0);
rect(0,0,width,height-100);
fill(0);
textAlign (CENTER);
text("GAME OVER!", width/2,height/2);
noLoop();
}
here is what the result should be:
mnse
December 3, 2022, 8:23pm
2
Hi @add ,
What happens if you run your code in PDE ?
Do you get any hints in the editor pane and/or console window ?
Have you tried to follow these hints?
I would recommend that you go through your code (line by line) and try to add comments what each line is doing or what it should doing and what possible went wrong.
Don’t hesitate to come back if you have concrete questions…
Cheers
— mnse
Summary (TL;DR)
Ask complete questions to get better answers!
Be specific. For example: I want to load an image. I tried using createImg() , and I expected the image to be on canvas, but what happened instead was the image showing up below the canvas.
Isolate your problem and work in small steps. Share only the code directly related to your problem if it is part of a bigger project, and if something isn’t working, try the smallest code that could do the thing you want.
Can we run your code …
1 Like
debxyz
December 3, 2022, 8:45pm
3
Hello again @add
Can you sum up in a sentence what your program is supposed to do?
How are we to evaluate it when we do not know what the end result is supposed to be?
Concrete help requires concrete question(s).
Your question is much too general.
1 Like