Draw problems
in
Programming Questions
•
1 year ago
My current code:
- PImage img;
PFont font;
void setup()
{
size(300, 300);
background(0, 0, 255);
img = loadImage("background.png");
font = loadFont("Arial-BoldMT-48.vlw");
textFont(font, 32);
}
int x = 0;
boolean start = false; - void draw()
{
noLoop();
if (start == true)
{
image(img, 0, 0);
textAlign(CENTER);
fill(255, 0, 0);
text(""+x, width/2, height/2);
try
{
Thread.sleep(2000);
}
catch(InterruptedException e)
{
}
}
else
{
textAlign(CENTER);
fill(255, 0, 0);
image(img, 0, 0);
text(x, width/2, height/2);
try
{
Thread.sleep(2000);
}
catch(InterruptedException e)
{
}
}
x++;
}
void keyPressed()
{
if (keyCode == ENTER)
{
start = true;
}
} I am just trying to familiarize myself with processing before I try attempting harder things. I have two problems..
-
1: when I press enter, it doesn't do what I tell it ti do (I think);
-
2: In the beginning when I specify it should have a blue background, it stays like that for about 2 seconds before going into draw. Can someone explain why this is happening? I still do not fully understand draw and what it does.
1