Loading...
Logo
Processing Forum
processingxaccount's Profile
4 Posts
13 Responses
0 Followers

Activity Trend

Last 30 days

Loading Chart...

Show:
Private Message
    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;
          }
    }



    }
    }
    Hey guys,

    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!
    Hey guys,

    I have another problem with processing. 
    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){
        this.xPos = xPos;
        this.yPos = yPos;
        this.weite = weite;
        this.hoehe = hoehe;
        img = loadImage("moorhuhn.png");
      }
      
      void zeichne () {
        yPos = yPosneu + 30*sin(radians(xPos));
        image (img, xPos++, yPos, weite, hoehe);
         if (xPos > width)
          {
            xPos = 0;
          } 
        }

      
      boolean darueber () {
        if (mouseX > xPos
         &&mouseX < xPos+weite
         &&mouseY > yPos
         &&mouseY < yPos+hoehe)
          {
             return true;
          }
         
        else
          {
            return false;
          }
      }
        
      boolean klick () {
          if (darueber () && mousePressed)
           { 
             xPos = random (0, 390);
             yPosneu = random (0, 390);
             return true;
           }
          
          else
           {
           return false;
           }
         }
       }

    Thanks for your help.
    hey guys,

    I need help.
    I would like to have an object which disappears and reappears on a random spot. 
    I can make it dissapear with one click but it reappears on the same spot with another click.
    So can somebody tell me what I could look for, I don't find anything that could help me on the reference sheet.

    Here is my code that I already have:

    Button knopf;

    void setup () {
      size (400, 400);
      knopf = new Button ( random (0, 400), random (0, 400), 50, 50);
    }


    void draw () {
      background (0);
      knopf.zeichne () ;
    }

    void mousePressed () {
      knopf.klick ();
      println (knopf.onoff);
    }

    and this is the class:
    class Button {
      float xPos;
      float yPos;
      int weite;
      int hoehe;
      String onoff = "off";
      
      Button (float xPos, float yPos, int weite, int hoehe){
        this.xPos = xPos;
        this.yPos = yPos;
        this.weite = weite;
        this.hoehe = hoehe;
      }
      
      void zeichne () {
      if (onoff == "on") {
        }
      else {
        rect (xPos, yPos, weite, hoehe);
      }
      
      stroke (255, 0, 0);
      strokeWeight (5);
      }
      
      boolean darueber () {
       
       if (mouseX > xPos
         &&mouseX < xPos+weite
        &&mouseY > yPos
       && mouseY < yPos+hoehe)
      {
       return true;
      }
     else
    {
     return false;
    }
      }
      boolean klick () {
        
       if (darueber () && mousePressed) {
         if (onoff == "off") onoff = "on";
         else onoff = "off";
         return true;
       }
       else
       {
         return false;
       }
      }
      
      }

    Could somebody please help me? :)