[SDL] (no subject)

sdl at jokawalli.de sdl at jokawalli.de
Mon Aug 6 08:59:56 PDT 2007


Hi!

Can anybody help?
I took the demo "Sinus Font" and tried to modify it, such like the
string scrolls from rigth into the window and scrolls at the left of
the window out.

Some pieces of the source code:

for (i=0; i < stringlength; i++) {
		letter[0] = string[i];
		letter[1] = '\0';
		letter_surf[i] = TTF_RenderText_Solid(font, letter, white);
		letter_rect[i].w = letter_surf[i]->w;
		letter_rect[i].h = letter_surf[i]->h;
	}
.......
while(!keypressevent()){


for (i=0; i < 40+b; i++)
		SDL_FillRect(screen, &letter_rect[i], black);


		for (i=0; i < stringlength; i++) {

            if (i==0){
				xpos = first_x;
				     }

			letter_rect[i].x = xpos;
			xpos +=width_of_letter;
			letter_rect[i].y = ypos;

SDL_BlitSurface(letter_surf[i], NULL, screen,&letter_rect[i]);

		}
	SDL_Flip(screen);
	first_x -= speed_of_text;

	SDL_Flip(screen);


My problem:

The whole text jitters, if the speed is greater than e.g. 10

Is there a better way to do the same?

A second problem:
If the width of the letters>50, than the text may not be longer than
1300 words otherwise there is I think a bufferoverflow.. (or something
similar);

Hoping for some helpful hints.

Thanks Walter




More information about the SDL mailing list