// BGRoll2.java // Draw Rolling String // by nagatani@eken.phys.nagoya-u.ac.jp import java.applet.Applet; import java.awt.*; public class BGRoll2 extends StringRoll { int xPos, yPos; BGRoll2 (Image imageBG, int yOffset, Applet applet) { super (imageBG, 0, 0, applet); this.yOffset = yOffset; nMode = 0; } public void paint (Graphics g, Applet applet) { g.drawImage (imageString, xPos - xImage, yPos, applet); if (xPos < xWindow) g.drawImage (imageString, xPos, yPos, applet); } public void move () { // Every Time Displaying Mode double T = t + 0.01 * Math.sin ( 3 * 2.0*Math.PI*t + 0) + 0.003 * Math.sin ( 5 * 2.0*Math.PI*t + 2) + 0.001 * Math.sin (14 * 2.0*Math.PI*t + 4); xPos = (int) ((1.0 - T) * xImage); yPos = yOffset; t += 0.002; if (t >= 1.0) { t = 0.0; } return; } }