Well, im making a 'media player' typething, so the scrolling text in this case will be the title... Meaning its automatically assigned, so it neds to scroll on its own... Ok, i have enough room for 20 characters to fit until the title will need to scroll... Im having it delay 1/2 second which is used via: sceKernelDelayThread(250000*2); This isnt for windows, so thats my delay right there... Ok, so far ive been thinking how the im going to do this... so im just guessing here... (the string is just an example, its actually set to the name...) Code: char title[] = "abcdefghijklmnopqrstuvwxyz"; int titleLength = strlen(title), overChars; int scrollDistance; int titleX = 50, titleY = 5; while (1) { printTextScreen(titleX-scrollDistance, titleY, title, RGBA(255,255,255,100)); if ( titleLength > 20 ) { overChars = titleLength - 20; scrollDistance = overChars * 7; sceKernelDelayThread(250000*2); } } Well... i think this here will print out the title titleX - 42... but i want it to scroll character by character, meaning it will print itout -7, then -7 again, then -7 again, until it reaches 42... i know a for loop is necessary... could someone help me out on this?
Why dont you pad the string with the blank characters before and after depening on the position where you want to display the title Code: printTextScreen(" Title to display "); and change it with the spaces as the timer is triggered.
itd be much easier if i could just mess with it via titleX variable... not to mention i want it to scroll 1 character by 1 character... cant someone make or somehow help me towards just using integers to subtract and mess with the titleX variable to allow it to scroll 1 character at a time, then once it reaches the end/the character before the \0 character is showed, tehn reset it... cant some math wizzs help me out here?
Code: static int iStart = 0; static int iPad = 0; char title[] = "abcdefghijklmnopqrstuvwxyz"; int titleLength = strlen(title), overChars; char titleToShow[20]; if(titleLength > 20) { for(int i=iStart;i<20+iStart;i++) titleToShow[i] = title[i]; iStart++; titleToShow[i] = '\0'; } else { // Before padding with spaces for(int i=0;i<iPad;i++) titleToShow[i] = ' '; // Copying the characters for(;i<titleLength;i++) titleToShow[i] = title[i]; // After padding with spaces for(;i<20;i++) titleToShow[i] = ' '; } Just this is the handler to the timer where you pad based on the static variable.
Ok, and this will basically return titleToShow, only printing out the first 20 letters... Ok, maybe i shouldve told you my displaying right now... I have a little title bar which can hold 14 characters befreoy ou cant see them anymore... I have it printing the title beneathe the backround, and that title bar is transparent, so it shows up... So i have the title printed, and if it goes underneathe the backround (the length of the title is larger then 14 characters) then i want it to scroll 1 character left, every 1/2 second using the 'sceKernelDelayThrerad(250000*2);' call i stated earlier... The X co-ordinate is titleX=50 in this case...The title will be: title="abcdefghijklmnopqrstuvwxyz" So isnt there a way to subtract 7 from titleX for every character over 14 in the 'title', then reset it back to titleX = 50 once its finished the second to last character (the \0 is pointless to scroll :P )? (WHOA... i just said what i want to do... im going to give it a try... but i doubt ill be able to do it, but i cant ry until some programming person better then me helkps me out here...) P.S. oh and shabbir, if your snippet works for the titleX subtraction (i used dev-c++ and it just printed out 20 chractes) then im sorry, i dont see it
ok, here is my attempt that i think works, but i doubt it... Code: int TitleX = 9, titleLength = strlen(TITLE), w, overChars = titleLength-14; while(1) { printTextScreen(TitleX,TitleY, Title, colorOFtitle); for(w=titleLength;w>overChars;w--) { TitleX--; } } Im just trying to subtract 7 from an integer, every 1/2 second... Thus making text scroll by 7 chars to the left every 1/2 second...