text only appears for a second, want it to stay longer
in
Programming Questions
•
8 months ago
I have a labyrinth game, where the ellipse isn't allowed to "touch" a black pixel. When the ellipse passes a black pixel, it should stop and a text should appear. Unfortunately the text appears just for a second, but I want it to appear longer. The code is bold. Do you know how to let the text appear for more than just a second?
PImage img;
Kreis kreis1;
void setup () {
size (997, 895);
img = loadImage ("labyrinth.png");
kreis1 = new Kreis (50,50,40,40);
}
void draw () {
background (img);
kreis1.bewegen();
kreis1.zeichne();
}
CLASS:
class Kreis
{
int xPos;
int yPos;
int hoehe;
int breite;
boolean heDied = false;
Kreis (int xPos, int yPos, int hoehe, int breite) {
this.xPos = xPos;
this.yPos = yPos;
this.hoehe = hoehe;
this.breite = breite;
}
void zeichne ()
{
ellipse (xPos, yPos, hoehe, breite);
}
void bewegen () {
if (key == CODED) {
if (keyCode == UP) {
yPos-=1;
}
if (keyCode == DOWN) {
yPos+=1;
}
if (keyCode == RIGHT) {
xPos+=1;
}
if (keyCode == LEFT) {
xPos-=1;
}
}
if (xPos == 980 && yPos == 860) {
}
loadPixels();
color nextPixel = pixels[yPos*width+xPos];
if (nextPixel == color (0)) {
background (0);
textSize (50);
textAlign(CENTER);
text("Fail - Press r to restart", width/2, height/2);
if ( key == 'r')
{
xPos = 50;
yPos = 50;
}
}
}
}
1