Simple Case‎ > ‎

### Exp1. A Multiplication Table

This shows a multiplication table on screen.    You may find the similar examples on other books for programming practice.    For making it more attractive , I did some tricks in the program.    It will change to green and red color when the loop enter certain row and column.    And the box number will change by the loop too.
A typical and good for logic practice.

This shows the icon image.
 if( aTick%6 == 1) xi++;    if( xi > 9 ) { xi = 1; yi++; }    if( yi > 9 ) yi = 1;    for(int i=0 ; i < yi ; i++ ) {        animRect.x = 10 + i * 40 ;        animRect.y = 200;        SDL_BlitSurface( anim[0] , NULL , screen , &animRect );        }    for(int i=0 ; i < xi ; i++ ) {        animRect.x = 10 + i * 40 ;        animRect.y = 240;        SDL_BlitSurface( anim[0] , NULL , screen , &animRect );        }

This shows the table and color.
 // A Multiplication Table    for(int i = 1 ; i <= 9 ; i++) {        for( int j = 1 ; j <= 9 ; j++) {            txtIt("%2d" , i*j );            fColor = fColorW; // Default is white color            if( i==1 && j==yi ) fColor = fColorG;            if( j==1 && i==xi ) fColor = fColorG;            if( i == xi && j == yi ) fColor = fColorR;            imgTxt = TTF_RenderText_Solid( font , string , fColor );            txtRect.x = 30 + i*30 ;            txtRect.y = 30 + j*15 ;            SDL_BlitSurface( imgTxt , NULL , screen , &txtRect );            } // for( int j = 1 ; j <= 9 ; j++) { END        } // for(int i = 1 ; i <= 9 ; i++) { END

Exp1 END

See the Food Box there ?   This animation effect is what I really wanna do !
I was thinking about using a mushroom or carrot to do that , but I can not find
the picture , so I pick up the Food Box !