SineWave wave; void setup(){ size(500,300); stroke(255);//set color for point wave = new SineWave(); } void draw(){ background(0); wave.move(); } class SineWave{ int i = 0; // increment to create wave effect int _x = 0; // x position of drawn object float _y; // y position of drawn object int _width = 10; // width of object int _height = 10; // height of object int speed = 4; // speed of object boolean metLimit = false; // determines whether or not the object has reached the edge of the applet //constructor SineWave(){} void move(){ _y=(sin(i*.4))*20+(height/2);//y position is sine function(which gives a value from -1 to 1)*20 for more effect + (half of height to center) _x+=setX();//add the x position of point ellipse(_x, _y, _width, _height); // set position of point i++; // increment variable i } int setX(){ if(_x>=width && metLimit==false){ metLimit = true; speed*=-1; // send left }else if(_x <= 0 && metLimit == true){ metLimit = false; speed*=-1; // send left } return speed; } }