• fullscreen
  • firstprogramever.pde
  • color c = color(200,50,200);
    float x = 0;
    float y = 100;
    float speed = 1;
    
    void setup() {
      size(200,200);
      
    }
    
    void draw() {
    background(0,50,120);
    move();
      display();
    }
    
    void move() {
      x = x + speed;
      
      if (x >= width) {
        x = 0;
      }
      
      else if (x <= 0) {
        x = width;
      }
        
       if(mousePressed) x=x-speed*4; 
      
      
      
      }
    
    
    void display() {
      fill(c);
      rect(x,y,60,20);
    }
    
    
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    Christian Martin

    first program

    Add to Faves Me Likey@!
    You must login/register to add this sketch to your favorites.

    the screen can be clicked to move backwards at 3X speed.

    You need to login/register to comment.