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);
Sorry to bother you, but I'm a complete newbie in processing and I can't think of any help than from you.
I have to program a labyrinth game, where a object isn't allowed to collide with the black borders, so I thought I could use a background picture of a labyrinth, program an object, that I can controll with the left/right/up/down buttons and this object isn't allowed to collide with the black pixels of this picture. I have no clue what I could do, do you have any tips, suggestions? I really need!! your help!
I have two objects, which appear on the screen and which disappear when I click on them. These two objects are one picture, but I want one object with one picture and the other object with another pictures. This doesn't seem to work, so I wanted to ask you guys, what you would do.
This is my code so far. Please help me!
FIRST PAGE:
Button knopf;
Button knopf2;
int showklick = 0;
void setup () {
size (400, 400);
knopf = new Button ( random (0, 390), random (0, 390),140,100);
knopf2 = new Button ( random (0, 390), random (0, 390),70, 50);
}
void draw () {
background (0);
knopf.zeichne ();
knopf2.zeichne ();
}
void mousePressed () {
if(knopf.klick() || knopf2.klick()){
showklick = showklick+1;
println (showklick);
}
}
SECOND "CLASS" PAGE:
class Button {
float xPos;
float yPos;
float yPosneu;
int weite;
int hoehe;
PImage img;
Button (float xPos, float yPos, int weite, int hoehe){