Hi I'm making a scrollbar program for an eyelash website. There's a problem with my code to make it scroll however. It works for <80 entries in the text array but when there are more then 80 the text goes off the screen... kinda hard to explain so just run the program to see what I'm on about!
Code:
PFont font;
int maxim;
String[] textArray;
boolean locked;
float pos,sPos,x;
void setup(){
size(300,400);
background(0);
font = loadFont("ArialMT-11.vlw");
textFont(font,11);
x = 1;
sPos = 3;
textArray = new String[] {
"Eyelash extensions are an entirely new method of",
"enhancing the length and thickness of eyelashes.",
"Extensions are applied on a lash-by-lash basis for",
"a totally natural look. When properly applied,",
"Lashes Couture® eyelash extensions can last from up" ,
"to six to eight weeks. Lashextensions.ie® attracts",
"everyone in Ireland who is looking for eyelash",
"extensions.",
"",
"Lashes Couture® is one of the highest ranked eyelash",
"extension systems in the world! A significant portion",
"of this traffic is from potential clients seeking a",
"professional, in their area, who can apply extensions",
"to them. When your name is listed, you will understand",
"the value of an exceptional referral program. If you",
"are a Lashes Couture Professional and want to attract",
"new and potential clients in your area please contact",
"us and we will be happy to list you on the first",
"website in ireland dedicated to Lashes Couture Eyelash",
"Extensions.",
"",
"We recieve hundreds of calls every month from people",
"looking for the nearest Lashes Couture Professional",
"in there area. Premium quality speaks for itself!",
"When you carry the highest quality products, when you",
"have received exceptional hands-on eyelash extension",
"training and certification options from Lashes Couture®,",
"your clients will be thrilled and grateful.",
"",
"You owe it to yourself and to your clients to align",
"yourself with the only company that is committed to",
"upholding critical standards, committed to continual",
"improvement and committed to the long term success of",
"the eyelash extension industry. We welcome you as a",
"member of our dedicated team of professionals.",
"Lashes Couture® wants to be an integral part of your",
"success in this revolutionary new and exciting industry." };
//doesnt work after 80 lines
noStroke();
smooth();
}
void draw(){
background(0);
for(int i = 0; i <= textArray.length - 1; i++){
fill(200);
text(textArray[i], 5, (i + 1) * 14 + x);
}
maxim = height/2+(textArray.length*14)-(height-2);
pos = sPos/(height-52);
x = 5-pos*maxim;
if(mousePressed && over() || locked) {
locked = true;
if (mouseY-50 <= 2){
sPos = 3;
}
else if (mouseY+50 >= height - 2){
sPos = height - 103;
}
else {
sPos = mouseY - 50;
}
}
if(!mousePressed) {
locked = false;
}
fill(250);
rect(width - 8, sPos, 6,100);
ellipse(width - 5, sPos,6,6);
ellipse(width - 5, sPos+100,6,6);
}
boolean over(){
return mouseX > width - 8 && mouseX < width - 2 && mouseY > sPos && mouseY < sPos + 100;
}