Felix/ProcessingWithJavi: Difference between revisions

From XPUB & Lens-Based wiki
Line 1: Line 1:
==Screensaver Code==
==Screensaver Code==
  float x = 0.0;
  float x = 0.0;
float y = 200.0;
float y = 200.0;
float speed = 1.0;
float speed = 1.0;
float speedY = 1.0;
float speedY = 1.0;


void setup(){
void setup(){
  size(800,600);  
  size(800,600);  
  frameRate(300);
  frameRate(300);
}
}


void draw(){
void draw(){
   background(255,255,255);
   background(255,255,255);
   fill(255,0,150);
   fill(255,0,150);
Line 35: Line 35:




}
}

Revision as of 18:14, 21 January 2019

Screensaver Code

float x = 0.0;
float y = 200.0;
float speed = 1.0;
float speedY = 1.0;
void setup(){
size(800,600); 
frameRate(300);
}
void draw(){
  background(255,255,255);
  fill(255,0,150);
  noStroke();
  rect(x,y,55,55);
  x = x + speed;
  y=y+speedY;
  
  if(x == width-55 || x <= 0)
  {
    speed = speed * -1.0;
  }
  


   if(y == height-55 || y <= 0)
  {
  
    speedY = speedY * -1.0;
  
  }
  
  


}